简体   繁体   English

如何在不构建上游作业的情况下将参数从上游作业传递给下游作业

[英]how to pass parmeter to downstream job from upstream job without building upstream job

I have two jobs which are pipeline, I want to send the Parameter (Branch name) info of upstream job to downstream.我有两个管道作业,我想将上游作业的参数(分支名称)信息发送到下游。

The main point is we shouldn't build upstream project before passing parameter to Downstream job.要点是我们不应该在将参数传递给下游作业之前构建上游项目。

Whenever I trigger the downstream job it need to get the Branch name parameter from the upstream job每当我触发下游作业时,它都需要从上游作业中获取分支名称参数

How can I do this?我怎样才能做到这一点?

Passing parameters from jobs to jobs within pipelines is very hard to maintain, I won't recommend it.在管道中将参数从作业传递到作业非常难以维护,我不会推荐它。 At first it seems logic but it's the old way of thinking with Jenkins and it leads to Frankenstein pipelines.起初它似乎合乎逻辑,但这是 Jenkins 的旧思维方式,它导致了科学怪人管道。

Learn how shared libraries work.了解共享库的工作原理。 It looks scary at first but it's simple.起初看起来很吓人,但它很简单。 The files in the folder vars/ define the custom steps you can trigger.文件夹 vars/ 中的文件定义了您可以触发的自定义步骤。 In src/ folder you put your code logic.在 src/ 文件夹中放置代码逻辑。

If you need several jobs, just create several jobs and reuse the code you wrote in the pipeline but try not to call jobs from jobs.如果您需要多个作业,只需创建多个作业并重用您在管道中编写的代码,但尽量不要从作业中调用作业。

I know it's not the answer you were expecting but hopefully by listening to my comment you will get happier times:)我知道这不是您所期望的答案,但希望通过聆听我的评论,您会获得更快乐的时光:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM