Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
682 views
in Technique[技术] by (71.8m points)

jenkins - Return parameters/results from a job(triggered by pipeline) back to the same pipeline

Jenkins pipeline: I have a pipeline p1 that triggers a job j1 and then job j2. I want some parameters that are set by j1 and passed to j2 in pipeline p1. How do I implement this functionality using Jenkins pipeline plugin? Thanks in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It can be done using "env". If you manage to make j1 add its information into the build's env.

If j1 was a pipeline you could to env.MYKEY=MYVALUE. For a freestyle-job it should work using the EnvInject plugin (didn't try). In p1 then you will get a map with that information if you out of the build result.

So, if you do in p1 something line this:

// somewhere in your pipeline, i.e. p1:
def j1BuildResult = build job: 'J1'
def j1EnvVariables = j1BuildResult.getBuildVariables();

then j1EnvVariables will be a map containing the variables you set in j1.

PS: how to pass that info to as parameters p2 is e.g. covered here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...