Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-46152

Pipeline jobs should have a property to skip triggering downstream jobs

      JENKINS-44721 added the ability for jobs leveraging withMaven() to be triggered by jobs that deploy SNAPSHOT dependencies. There should be an option for specific jobs to NOT trigger any downstream jobs. The use case here is specific jobs that many other jobs depend on can cause an "avalanche" of builds every time they build.

       

      I would imagine the call in the Jenkinsfile to look something like:

      properties( [skipDownstreamJobTrigger()] ) // /!\ WARNING NOT THE DEFINITIVE SYNTAX. SEE DOCS

          [JENKINS-46152] Pipeline jobs should have a property to skip triggering downstream jobs

          Fixed in 3.0.0-beta-4

          Samples at the pipeline level (can also be defined globally)

          properties([pipelineTriggers([snapshotDependencies()])])
          ...
          withMaven(options: [pipelineGraphPublisher(skipDownstreamTriggers: true)]) {
             // trigger this pipeline when dependencies are generated by upstream pipelines but don't trigger downstream pipelines according to the generated artifact of this maven project
             sh "mvn package"
          }
          
          properties([pipelineTriggers([snapshotDependencies()])])
          ...
          withMaven() {
             sh "mvn package"
          }
          
          dir("another-maven-project")
          withMaven(options: [pipelineGraphPublisher(ignoreUpstreamTriggers: true)]) {
             // Don't get this pipeline triggered when dependencies of this this 'another-maven-project' are generated by an upstream build
             sh "mvn package"
          }
          

          Cyrille Le Clerc added a comment - Fixed in 3.0.0-beta-4 Samples at the pipeline level (can also be defined globally) properties([pipelineTriggers([snapshotDependencies()])]) ... withMaven(options: [pipelineGraphPublisher(skipDownstreamTriggers: true )]) { // trigger this pipeline when dependencies are generated by upstream pipelines but don't trigger downstream pipelines according to the generated artifact of this maven project sh "mvn package " } properties([pipelineTriggers([snapshotDependencies()])]) ... withMaven() { sh "mvn package " } dir( "another-maven-project" ) withMaven(options: [pipelineGraphPublisher(ignoreUpstreamTriggers: true )]) { // Don 't get this pipeline triggered when dependencies of this this ' another-maven-project' are generated by an upstream build sh "mvn package " }

          Markus Dlugi added a comment -

          Somewhat related to this feature (but might also be better suited for a separate JIRA ticket?) is the feature "Block downstream trigger when building" of the old Maven project type. That feature doesn't skip all the downstream triggers, but only the triggers of those downstream dependencies which will later on be triggered by other downstream dependencies. Without that feature, many unnecessary builds would be triggered, so the purpose is the same as for the flag introduced here, but without disabling triggers completely.

          For those unaware of the functionality of that feature: imagine Maven projects A, B, and C, where B depends on A and C depends on both A and B. Currently, when A is built, C gets triggered twice, once by A and once by B. But with the proposed feature, C only gets triggered by B, because A knows that B will trigger C later on.

          Markus Dlugi added a comment - Somewhat related to this feature (but might also be better suited for a separate JIRA ticket?) is the feature "Block downstream trigger when building" of the old Maven project type. That feature doesn't skip all the downstream triggers, but only the triggers of those downstream dependencies which will later on be triggered by other downstream dependencies. Without that feature, many unnecessary builds would be triggered, so the purpose is the same as for the flag introduced here, but without disabling triggers completely. For those unaware of the functionality of that feature: imagine Maven projects A, B, and C, where B depends on A and C depends on both A and B. Currently, when A is built, C gets triggered twice, once by A and once by B. But with the proposed feature, C only gets triggered by B, because A knows that B will trigger C later on.

          Thanks markusdlugi, can you create a dedicated JIRA ticket please?

          Cyrille Le Clerc added a comment - Thanks markusdlugi , can you create a dedicated JIRA ticket please?

          Markus Dlugi added a comment -

          cleclerc Okay, see JENKINS-46313.

          Markus Dlugi added a comment - cleclerc Okay, see  JENKINS-46313 .

          Thanks markusdlugi. By the way, did you test 3.0.0-beta-4?

          Cyrille Le Clerc added a comment - Thanks markusdlugi . By the way, did you test 3.0.0-beta-4?

          Markus Dlugi added a comment -

          cleclerc Yes, I tested it. The triggering is working correctly, but there are some differences in behavior compared to the old Maven projects. The first one is that sometimes multiple builds are triggered as described in JENKINS-46313. The second one is that some dependencies between projects are not established even though they were with the old project type, for example parent dependencies. The setup is as follows:

          Jenkins project A builds Maven modules a0, a1, a2, and so on. a0 is the parent POM of all a* modules.

          Jenkins project B builds Maven modules b0, b1, b2, and so on. b0 is the parent POM of all b* modules. b0 uses a2 as its parent POM.

          In the old Maven project, a dependency between A and B would have been established because of the parent dependency between b0 and a2. With the pipeline-maven-plugin, this is currently not the case, so a build of A does not trigger a new build of B.

          Now the question is whether this use case should be supported again?

          Markus Dlugi added a comment - cleclerc Yes, I tested it. The triggering is working correctly, but there are some differences in behavior compared to the old Maven projects. The first one is that sometimes multiple builds are triggered as described in JENKINS-46313 . The second one is that some dependencies between projects are not established even though they were with the old project type, for example parent dependencies. The setup is as follows: Jenkins project A builds Maven modules a0, a1, a2, and so on. a0 is the parent POM of all a* modules. Jenkins project B builds Maven modules b0, b1, b2, and so on. b0 is the parent POM of all b* modules. b0 uses a2 as its parent POM. In the old Maven project, a dependency between A and B would have been established because of the parent dependency between b0 and a2. With the pipeline-maven-plugin, this is currently not the case, so a build of A does not trigger a new build of B. Now the question is whether this use case should be supported again?

          Thanks markusdlugi

          > ...parent pom changes triggering builds...
          > Now the question is whether this use case should be supported again?

          We don't look at the parent pom for the moment, this could be an enhancement.

          Source code: https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.0.0-beta-4/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/PipelineGraphPublisher.java#L79

          Cyrille Le Clerc added a comment - Thanks markusdlugi > ...parent pom changes triggering builds... > Now the question is whether this use case should be supported again? We don't look at the parent pom for the moment, this could be an enhancement. Source code: https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.0.0-beta-4/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/PipelineGraphPublisher.java#L79

          Markus Dlugi added a comment -

          cleclerc, I don't think you would actually have to look at the parent POM to do this. I think it would be enough to read the parent artifact from the POM and declare it as additional dependency, wouldn't it? That should then recreate this behavior.

          I can create an additional ticket for that as well, if you like.

          Markus Dlugi added a comment - cleclerc , I don't think you would actually have to look at the parent POM to do this. I think it would be enough to read the parent artifact from the POM and declare it as additional dependency, wouldn't it? That should then recreate this behavior. I can create an additional ticket for that as well, if you like.

          > I don't think you would actually have to look at the parent POM to do this. I think it would be enough to read the parent artifact from the POM

          You are right, my phrasing was not clear. We could track the parent pom identifier and trigger builds upon changes.

          > I can create an additional ticket for that as well, if you like.

          Please yes

          Cyrille Le Clerc added a comment - > I don't think you would actually have to look at the parent POM to do this. I think it would be enough to read the parent artifact from the POM You are right, my phrasing was not clear. We could track the parent pom identifier and trigger builds upon changes. > I can create an additional ticket for that as well, if you like. Please yes

          Fixed in 3.0.0

          Cyrille Le Clerc added a comment - Fixed in 3.0.0

            cleclerc Cyrille Le Clerc
            nv035674 Nathan Vahrenberg
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: