Chaining of pipelines

Asked

Viewed 40 times

0

I’ve got two Jenkins (A and B). What I need is that job A, after finishing, start the job execution B. Since I need a user’s approval for this to happen.

//algo do tipo
executarJobB = input(
    message: "Devo iniciar o job B",
    ok: "Encadear",
    submitterParameter: 'executarJobB')

if (executarJobB) {
    build job: "B", parameters: [[$class: 'String', name: 'image', value: $image ]]
}
  • How can I do that?
  • How to execute this code after the pipeline A have been successfully executed?

1 answer

1


The variable executarJobB There’s no need for that. If the user accepts with Encadear the job continues and goes straight to build.
But if it cancels, the build fails. Then maybe you didn’t want it, which can be solved with a try-catch.

To check whether a job has been successfully executed until a certain time Voce can do this, it returns a Boolean:

Leaving your code like this:

if (currentBuild.resultIsBetterOrEqualTo("SUCCESS")) {
    try {
       input message: "Devo iniciar o job", ok: "Encadear"

       build job: "B", parameters: [[$class: 'String', name: 'image', value: $image]]
   } catch (ignored) {
       echo "Job B não foi lançado pelo usuário"
   }
} 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.