将工件或字符串传递给Jenkins Pipeline中的上游作业 [英] Pass Artifact or String to upstream job in Jenkins Pipeline

本文介绍了将工件或字符串传递给Jenkins Pipeline中的上游作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标

我正在尝试使用GitHub组织插件和jenkins管道来编排依赖链.

I'm trying to orchestrate a dependency chain using the GitHub organization plugin along with the jenkins pipeline.

由于我要构建的产品具有许多共享的依赖项,因此我正在使用nuget包来管理依赖项的版本和更新.

As the products I'm building have a number of shared dependencies, I'm using nuget packages to manage dependency versioning and updates.

但是,我在为进行业务流程的项目获取必要的工件/信息时遇到了麻烦.

However, I'm having trouble getting necessary artifacts/info to the projects doing the orchestration.

策略

在SCM更改中,任何上游共享库都应构建nuget包并编排需要新引用的任何下游构建:

On a SCM change any upstream shared libraries should build a nuget package and orchestrate any downstream builds that need new references:

  1. 我正在对每个上游项目中的下游业务流程进行硬编码.因此,如果构建了A,则将使用来自A的最新工件来构建依赖于A的B和C.此后,将使用D来构建依赖于B和C的D和依赖于A和C的E.根据需要来自A,B,C的最新工件.依此类推.这些都将通过A的Jenkinsfile分阶段触发,因为依赖项是使用构建作业:作业名"语法构建的.我找不到一个解决方案,我只能在每个步骤都将业务流程传递给下游,因为依赖项在下游分散并收敛,并且我不想触发对同一下游项目的多个构建,而对上游项目的引用却不同.
  2. 我可以将父项目的工件信息传递给任何下游作业,但是我面临的问题是,父项目没有任何下游工件的程序集版本信息(需要在下游进一步协调作业).Stash/Unstash似乎没有任何跨工作功能,并且已弃用了archive/unarchive.
  1. I am hardcoding the downstream orchestration in each upstream project. So if A is built, B and C with dependencies on A will be built with the latest artifact from A. After that, D with dependencies on B and C, and E with dependencies on A and C will be built with the latest artifacts from A, B, C as needed. And so on. These will all be triggered from the Jenkinsfile of A in stages as dependencies are built using the "Build Job: Jobname" syntax. I couldn't find a solution by which I could just pass the orchestration downstream at each step as the dependencies diverge and converge downstream and I don't want to trigger multiple builds of the same downstream project with different references to upstream projects.
  2. I can pass the artifact information for the parent project down to any downstream jobs, but the problem I'm facing is that, the parent project doesn't have any assembly versioning information for downstream artifacts (needed to orchestrate jobs further downstream). Stash/Unstash doesn't seem to have any cross-job functionality and archive/unarchive has been deprecated.

TLDR:我需要一种将字符串或文本文件上游传递给作业执行中(来自多个下游作业)的方法,或者我需要一种具有共享下游依赖项的多个dowstream作业来协调信息并将其共同传递给下游作业的方法(触发它只有一次).

TLDR: I need a method of either passing a string or text file upstream to a job mid-execution (from multiple downstream jobs) OR I need a method for multiple dowstream jobs with shared downstream dependencies to coordinate and jointly pass information to a downstream job (triggering it only once).

谢谢!

推荐答案

我最终使用了内置的存档"步骤(

I ended up using the built-in "archive" step (see syntax in pipeline syntax) in combination with copyArtifact plugin (must use Java style step with class name).

我希望能够合并工作流,而不是必须将每个构建中的下游构建与要构建的任何东西协调在一起,但是到目前为止,到目前为止还没有找到任何解决方案.

I would prefer to be able to merge the workflow rather than having to orchestrate the downstream builds in each build with anything to build downstream, but haven't been able to find any solutions to that end thus far.

这篇关于将工件或字符串传递给Jenkins Pipeline中的上游作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆