Jenkins fails to build follow-up

I am trying to start transition work from my current job, for example

pipeline { stages { stage('foo') { steps{ build job: 'my-job', propagate: true, wait: true } } } } 

The goal is to wait for the result of the task and fail or succeed in accordance with this result. Jenkins always fails with the message Waiting for non-job items is not supported . The work mentioned above does not have any parameters and is defined as the rest of my assignments using the cross-platform pipeline plugin.

All I can think of is that this jenkins element type is not supported as input to the build step, but it seems inconsistent and will turn out to be blocking for me. Can anyone confirm if this is true?

If so, can anyone suggest any workarounds?

thanks

+5
source share
2 answers

I really managed to fix it, paying more attention to determining the build step. Since all my downstream jobs are defined as work jobs with a multi-channel pipeline, their structure is similar to a folder, with each item in the folder representing a separate task. Thus, the correct way to call subsequent jobs was not build job: 'my-job', propagate: true, wait: true , but rather build job: "my-job/my-branch-name", propagate: true, wait: true

Also, not related to the question, but related to the problem, make sure you always have at least one more executor on the jenkins machine, as the wait syntax will consume one thread to set the wait, and another for the work you are expecting , and you can easily find yourself in a "source of hunger" situation.

Hope this helps

+9
source

It looks like JENKINS-45443 , which includes a comment

The pipeline does not support the upstream / downstream system, partly due to technical limitations, partly due to the fact that there is no static configuration of tasks that would make this possible, except by checking the latest metadata of the assembly.

But he also offers a workaround:

while the solution is still ongoing, I am including our workaround here. It is based on the rtp (Rich Text Publisher) plugin, which you must install to make it work:

At the end of our Jenkins file and after the job starts, we will wait for it to complete. In this case, build() returns the object used to complete the job downstream. We get information from him.

Warning: the getAbsoluteUrl() function is critical. Use it at your own peril and risk!

 def startedBld = build( job: YOUR_DOWNSTREAM_JOB, wait: true, // VERY IMPORTANT, otherwise build () does not return expected object propagate: true ) // Publish the started build information in the Build result def text = '<h2>Downstream jobs</h2>Started job <a href="' + startedBld.rawBuild.getAbsoluteUrl () + '">' + startedBld.rawBuild.toString () + '</a>' rtp (nullAction: '1',parserName: 'HTML', stableText: text) 

This issue is part of JENKINS-29913 , discovered over the past two years:

Currently, DependencyGraph limited to AbstractProject , which makes it impossible for Workflow to participate in an up / down relationship (in cases where a task chain is required, for example, due to security restrictions).

It refers to JENKINS-37718 's RFE (Request for Enhancement), based on another (unanswered) Stack Overflow Question .

+1
source

Source: https://habr.com/ru/post/1272195/


All Articles