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

Downstream pipelines are not triggered when the artifact is an OSGi bundle and consumed as a jar

    XMLWordPrintable

Details

    Description

      When a SNAPSHOT artifact is built with packaging = 'bundle' (using maven-bundle-plugin), downstream pipelines that consume the artifact as a jar dependency are not triggered.

      Artifact A:

      <groupId>my.org</groupId>
      <artifactId>event-api</artifactId>
      <packaging>bundle</packaging>
       
      

      Artifact B:

      <dependency>
          <groupId>my.org</groupId>
          <artifactId>event-api</artifactId>
      </dependency>

      Attachments

        Activity

          Fixed in 3.0.1

          cleclerc Cyrille Le Clerc added a comment - Fixed in 3.0.1
          robsykes24 Robert Sykes added a comment -

          cleclerc Sorry for the delay in testing this – I was out of town. I was not able to get this to work using 3.0.1-beta-2.  This is what I did to test using the multi_module_bundle_project test project:

          I created three jenkins pipelines (one for each of the modules) that are exactly the same except for the mvn command:

          • test-parent: mvn -N clean install
          • test-api: mvn -f print-api/pom.xml clean install
          • test-impl: mvn -f print-impl/pom.xml clean install

          I then executed test-parent, test-api, and test-impl to establish the relationships in the H2 database.  I then executed the test-api again expecting the test-impl pipeline to be triggered, but it did not.  In the spy log for the test-api pipeline, I only see the 'bundle' artifact captured from the test-api pipeline. 

          // Sample pipeline script for test-api
          node {
             stage('Preparation') { // for display purposes
                git url: 'file:///var/jenkins_home/.scm/multi_module_bundle_project', branch: 'master'
             }
             stage('Build') {
                withMaven(
                  maven: 'Maven') {
                    writeFile file: '.archive-jenkins-maven-event-spy-logs', text: ''
                    sh "mvn -f print-api/pom.xml clean install"
                }
             }
          }
          
          
           <ExecutionEvent type="ProjectSucceeded" class="org.apache.maven.lifecycle.internal.DefaultExecutionEvent" _time="2017-10-12 16:22:09.117">
              <project baseDir="/var/jenkins_home/workspace/test-api/print-api" file="/var/jenkins_home/workspace/test-api/print-api/pom.xml" groupId="jenkins.mvn.test.bundle" name="print-api" artifactId="print-api" version="0.0.1-SNAPSHOT">
                <build sourceDirectory="/var/jenkins_home/workspace/test-api/print-api/src/main/java" directory="/var/jenkins_home/workspace/test-api/print-api/target"/>
              </project>
              <no-execution-found/>
              <artifact extension="jar" baseVersion="0.0.1-SNAPSHOT" groupId="jenkins.mvn.test.bundle" artifactId="print-api" id="jenkins.mvn.test.bundle:print-api:bundle:0.0.1-SNAPSHOT" type="bundle" version="0.0.1-SNAPSHOT" snapshot="true">
                <file>/var/jenkins_home/workspace/test-api/print-api/target/print-api-0.0.1-SNAPSHOT.jar</file>
              </artifact>
              <attachedArtifacts/>
            </ExecutionEvent>
          

           

          robsykes24 Robert Sykes added a comment - cleclerc Sorry for the delay in testing this – I was out of town. I was not able to get this to work using 3.0.1-beta-2.  This is what I did to test using the multi_module_bundle_project test project: I created three jenkins pipelines (one for each of the modules) that are exactly the same except for the mvn command: test-parent: mvn -N clean install test-api: mvn -f print-api/pom.xml clean install test-impl: mvn -f print-impl/pom.xml clean install I then executed test-parent, test-api, and test-impl to establish the relationships in the H2 database.  I then executed the test-api again expecting the test-impl pipeline to be triggered, but it did not.  In the spy log for the test-api pipeline, I only see the 'bundle' artifact captured from the test-api pipeline.  // Sample pipeline script for test-api node {    stage( 'Preparation' ) { // for display purposes       git url: 'file: /// var /jenkins_home/.scm/multi_module_bundle_project' , branch: 'master'    }    stage( 'Build' ) {       withMaven(         maven: 'Maven' ) {           writeFile file: '.archive-jenkins-maven-event-spy-logs' , text: ''           sh "mvn -f print-api/pom.xml clean install"       }    } }  <ExecutionEvent type= "ProjectSucceeded" class= "org.apache.maven.lifecycle.internal.DefaultExecutionEvent" _time= "2017-10-12 16:22:09.117" > <project baseDir= "/ var /jenkins_home/workspace/test-api/print-api" file= "/ var /jenkins_home/workspace/test-api/print-api/pom.xml" groupId= "jenkins.mvn.test.bundle" name= "print-api" artifactId= "print-api" version= "0.0.1-SNAPSHOT" > <build sourceDirectory= "/ var /jenkins_home/workspace/test-api/print-api/src/main/java" directory= "/ var /jenkins_home/workspace/test-api/print-api/target" /> </project> <no-execution-found/> <artifact extension= "jar" baseVersion= "0.0.1-SNAPSHOT" groupId= "jenkins.mvn.test.bundle" artifactId= "print-api" id= "jenkins.mvn.test.bundle:print-api:bundle:0.0.1-SNAPSHOT" type= "bundle" version= "0.0.1-SNAPSHOT" snapshot= " true " > <file>/ var /jenkins_home/workspace/test-api/print-api/target/print-api-0.0.1-SNAPSHOT.jar</file> </artifact> <attachedArtifacts/> </ExecutionEvent>  
          cleclerc Cyrille Le Clerc added a comment - - edited

          robsykes24 Can you please test version 3.0.1, it should solve your problem.

          The fix of your problem is not in the XML file, it's a hack is in the Java code of the Jenkins Plugin that consumes the XML file:
          https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.0.1/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/PipelineGraphPublisher.java#L183

          if ("bundle".equals(artifact.type) && "jar".equals(artifact.extension)) {
              // JENKINS-47069 org.apache.felix:maven-bundle-plugin:bundle uses the type "bundle" for "jar" files
              // record artifact as both "bundle" and "jar"
              dao.recordGeneratedArtifact(run.getParent().getFullName(), run.getNumber(),
                      artifact.groupId, artifact.artifactId, artifact.version, "jar", artifact.baseVersion,
                      skipDownstreamPipelines);
          }
          

          https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.0.1/jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/DependencyGraphTest.java#L190

          @Test
          public void verify_osgi_bundle_recorded_as_bundle_and_as_jar() throws Exception {
             ...
          }
          
          cleclerc Cyrille Le Clerc added a comment - - edited robsykes24 Can you please test version 3.0.1, it should solve your problem. The fix of your problem is not in the XML file, it's a hack is in the Java code of the Jenkins Plugin that consumes the XML file: https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.0.1/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/PipelineGraphPublisher.java#L183 if ( "bundle" .equals(artifact.type) && "jar" .equals(artifact.extension)) { // JENKINS-47069 org.apache.felix:maven-bundle-plugin:bundle uses the type "bundle" for "jar" files // record artifact as both "bundle" and "jar" dao.recordGeneratedArtifact(run.getParent().getFullName(), run.getNumber(), artifact.groupId, artifact.artifactId, artifact.version, "jar" , artifact.baseVersion, skipDownstreamPipelines); } https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.0.1/jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/DependencyGraphTest.java#L190 @Test public void verify_osgi_bundle_recorded_as_bundle_and_as_jar() throws Exception { ... }
          robsykes24 Robert Sykes added a comment -

          cleclerc I ran the test again with 3.0.1 with the same result.  Executing the test-api pipeline did not trigger the test-impl pipeline. Is there any required relationship between the pipeline name and the artifacts that it produces?  Does the H2 database ever need to be cleared?

          This is the output from the test-impl pipeline showing the dependency on the print-api artifact:

          <DependencyResolutionRequest class="org.apache.maven.project.DefaultDependencyResolutionRequest" _time="2017-10-12 20:04:37.394">
              <project baseDir="/var/jenkins_home/workspace/pipeline-triggering-test/test-impl/print-impl" file="/var/jenkins_home/workspace/pipeline-triggering-test/test-impl/print-impl/pom.xml" groupId="jenkins.mvn.test.bundle" name="print-impl" artifactId="print-impl" version="0.0.1-SNAPSHOT">
                <build sourceDirectory="/var/jenkins_home/workspace/pipeline-triggering-test/test-impl/print-impl/src/main/java" directory="/var/jenkins_home/workspace/pipeline-triggering-test/test-impl/print-impl/target"/>
              </project>
            </DependencyResolutionRequest>
          <DependencyResolutionResult class="org.apache.maven.project.DefaultDependencyResolutionResult" _time="2017-10-12 20:04:37.416">
              <resolvedDependencies>
                <dependency extension="jar" baseVersion="0.0.1-SNAPSHOT" groupId="jenkins.mvn.test.bundle" scope="compile" name="print-api-0.0.1-SNAPSHOT.jar" classifier="" artifactId="print-api" optional="false" id="print-api" type="jar" version="0.0.1-SNAPSHOT" snapshot="true">
                  <file>/var/jenkins_home/.m2/repository/jenkins/mvn/test/bundle/print-api/0.0.1-SNAPSHOT/print-api-0.0.1-SNAPSHOT.jar</file>
                </dependency>
              </resolvedDependencies>
            </DependencyResolutionResult>
          

          This is the output from the test-api pipeline showing the built artifact:

          <ExecutionEvent type="ProjectSucceeded" class="org.apache.maven.lifecycle.internal.DefaultExecutionEvent" _time="2017-10-12 20:04:46.716">
              <project baseDir="/var/jenkins_home/workspace/pipeline-triggering-test/test-api/print-api" file="/var/jenkins_home/workspace/pipeline-triggering-test/test-api/print-api/pom.xml" groupId="jenkins.mvn.test.bundle" name="print-api" artifactId="print-api" version="0.0.1-SNAPSHOT">
                <build sourceDirectory="/var/jenkins_home/workspace/pipeline-triggering-test/test-api/print-api/src/main/java" directory="/var/jenkins_home/workspace/pipeline-triggering-test/test-api/print-api/target"/>
              </project>
              <no-execution-found/>
              <artifact extension="jar" baseVersion="0.0.1-SNAPSHOT" groupId="jenkins.mvn.test.bundle" artifactId="print-api" id="jenkins.mvn.test.bundle:print-api:bundle:0.0.1-SNAPSHOT" type="bundle" version="0.0.1-SNAPSHOT" snapshot="true">
                <file>/var/jenkins_home/workspace/pipeline-triggering-test/test-api/print-api/target/print-api-0.0.1-SNAPSHOT.jar</file>
              </artifact>
              <attachedArtifacts/>
            </ExecutionEvent>
          
          
          robsykes24 Robert Sykes added a comment - cleclerc I ran the test again with 3.0.1 with the same result.  Executing the test-api pipeline did not trigger the test-impl pipeline. Is there any required relationship between the pipeline name and the artifacts that it produces?  Does the H2 database ever need to be cleared? This is the output from the test-impl pipeline showing the dependency on the print-api artifact: <DependencyResolutionRequest class= "org.apache.maven.project.DefaultDependencyResolutionRequest" _time= "2017-10-12 20:04:37.394" >     <project baseDir= "/ var /jenkins_home/workspace/pipeline-triggering-test/test-impl/print-impl" file= "/ var /jenkins_home/workspace/pipeline-triggering-test/test-impl/print-impl/pom.xml" groupId= "jenkins.mvn.test.bundle" name= "print-impl" artifactId= "print-impl" version= "0.0.1-SNAPSHOT" >       <build sourceDirectory= "/ var /jenkins_home/workspace/pipeline-triggering-test/test-impl/print-impl/src/main/java" directory= "/ var /jenkins_home/workspace/pipeline-triggering-test/test-impl/print-impl/target" />     </project>   </DependencyResolutionRequest> <DependencyResolutionResult class= "org.apache.maven.project.DefaultDependencyResolutionResult" _time= "2017-10-12 20:04:37.416" >     <resolvedDependencies>       <dependency extension= "jar" baseVersion= "0.0.1-SNAPSHOT" groupId= "jenkins.mvn.test.bundle" scope= "compile" name= "print-api-0.0.1-SNAPSHOT.jar" classifier= "" artifactId=" print-api " optional=" false " id=" print-api " type=" jar " version=" 0.0.1-SNAPSHOT " snapshot=" true ">         <file>/ var /jenkins_home/.m2/repository/jenkins/mvn/test/bundle/print-api/0.0.1-SNAPSHOT/print-api-0.0.1-SNAPSHOT.jar</file>       </dependency>     </resolvedDependencies>   </DependencyResolutionResult> This is the output from the test-api pipeline showing the built artifact: <ExecutionEvent type= "ProjectSucceeded" class= "org.apache.maven.lifecycle.internal.DefaultExecutionEvent" _time= "2017-10-12 20:04:46.716" >     <project baseDir= "/ var /jenkins_home/workspace/pipeline-triggering-test/test-api/print-api" file= "/ var /jenkins_home/workspace/pipeline-triggering-test/test-api/print-api/pom.xml" groupId= "jenkins.mvn.test.bundle" name= "print-api" artifactId= "print-api" version= "0.0.1-SNAPSHOT" >       <build sourceDirectory= "/ var /jenkins_home/workspace/pipeline-triggering-test/test-api/print-api/src/main/java" directory= "/ var /jenkins_home/workspace/pipeline-triggering-test/test-api/print-api/target" />     </project>     <no-execution-found/>     <artifact extension= "jar" baseVersion= "0.0.1-SNAPSHOT" groupId= "jenkins.mvn.test.bundle" artifactId= "print-api" id= "jenkins.mvn.test.bundle:print-api:bundle:0.0.1-SNAPSHOT" type= "bundle" version= "0.0.1-SNAPSHOT" snapshot= " true " >       <file>/ var /jenkins_home/workspace/pipeline-triggering-test/test-api/print-api/target/print-api-0.0.1-SNAPSHOT.jar</file>     </artifact>     <attachedArtifacts/>   </ExecutionEvent>
          cleclerc Cyrille Le Clerc added a comment - robsykes24 can you please reopen the issue if you still have the problem?   If you still have a problem, please review the test case DependencyGraphTest#verify_osgi_bundle_recorded_as_bundle_and_as_jar that is inspired by your sample.   https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.0.2/jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/DependencyGraphTest.java#L190   https://github.com/jenkinsci/pipeline-maven-plugin/tree/pipeline-maven-3.0.2/jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project    

          People

            cleclerc Cyrille Le Clerc
            robsykes24 Robert Sykes
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: