0

Two jenkins jobs are connected as: Upstream job is a pipeline and triggers a freestyle job.

Is it possible in Jenkins to get the following scenario:

If downstream job is aborted the upstream job gets aborted. But if the upstream job is aborted the downstream job should not abort, but continue running.

Upstream job :
    node('upstream_node'){
    build job: 'downstream_job', wait:true, propagate:false
    }

I have tried all possible combinations with 'wait' and 'propagate' options, but non of them will work.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
edla
  • 1
  • 1

2 Answers2

1

Use propagate:true instead of false.

This is from the documentation :

  • propagate (optional)
    If set, then if the downstream build is anything but successful (blue ball), this step fails. If disabled, then this step succeeds even if the downstream build is unstable, failed, etc.; use the result property of the return value as needed.
Arnaud Claudel
  • 3,000
  • 19
  • 25
  • The propagate:true satisfies one condition. 1 - If downstream job is aborted the upstream job gets aborted. But it will also do : 2 - If upstream job is aborted the downstream job gets aborted. While what I want is the nr 1. and 3- If upstream job is aborted the downstream continues – edla Jul 19 '19 at 11:02
  • Then I think it's with `wait:false`. There is an option to block on downstream job with the [Parameterized Trigger Plugin](https://wiki.jenkins.io/display/JENKINS/Parameterized+Trigger+Plugin) but I'm not sure if's the same as `wait`. You should try – Arnaud Claudel Jul 19 '19 at 11:15
  • wait:false does not satisfy condition nr. 1. Whatever happens with the downstream job, the upstream will not be affected since does not wait about it. Already tried all combinations. While the options from 'Parameterized Trigger Plugin' can't be used in a pipeline only a freestyle job. But thank you anyway for your reply – edla Jul 19 '19 at 11:30
  • Oh indeed, but now I don't understand the purpose, why would you continue the downstream job if you already canceled the upstream one ? – Arnaud Claudel Jul 19 '19 at 11:33
  • Because the upstream job is such a process that if it has already started it should finish, regardless of what happens. It should not stop, otherwise breaks some other things. But the result of it is not always considered. It is important that once started finishes till the end. – edla Jul 19 '19 at 11:49
0

Found the solution.

Using the lock plugin in Jenkins

How can I block a Jenkins 2.x Pipeline job while dependent jobs are building

edla
  • 1
  • 1