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

          robsykes24 Robert Sykes created issue -
          cleclerc Cyrille Le Clerc made changes -
          Field Original Value New Value
          Assignee Alvaro Lobato [ alobato ] Cyrille Le Clerc [ cleclerc ]

          Can you confirm that you are referring to the org.apache.felix:maven-bundle-plugin:bundle goal ?

          Could you provide a sample of the usage of the maven-bundle-plugin similar to what we have https://github.com/jenkinsci/pipeline-maven-plugin/tree/master/jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects ?

           

           

          cleclerc Cyrille Le Clerc added a comment - Can you confirm that you are referring to the org.apache.felix:maven-bundle-plugin:bundle goal ? Could you provide a sample of the usage of the maven-bundle-plugin similar to what we have https://github.com/jenkinsci/pipeline-maven-plugin/tree/master/jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects  ?    
          robsykes24 Robert Sykes added a comment -

          Correct, I am referring to the org.apache.felix:maven-bundle-plugin:bundle goal.  I have included a sample project in PR-97.

          robsykes24 Robert Sykes added a comment - Correct, I am referring to the org.apache.felix:maven-bundle-plugin:bundle goal.  I have included a sample project in PR-97.

          Code changed in jenkins
          User: Robert Sykes
          Path:
          jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/pom.xml
          jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/print-api/pom.xml
          jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/print-api/src/main/java/jenkins/mvn/test/bundle/print/PrintService.java
          jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/print-impl/pom.xml
          jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/print-impl/src/main/java/jenkins/mvn/test/bundle/print/impl/PrintServiceImpl.java
          http://jenkins-ci.org/commit/pipeline-maven-plugin/a5ba8c6e0c32ae63c9549412c76aed0ac5e3e48e
          Log:
          JENKINS-47069 Add sample maven-bundle-plugin project

          A sample project that uses the maven-bundle-plugin to produce
          an OSGi bundle.

          Modules:

          • print-api - OSGi bundle that exports a package containing an API.
          • print-impl - Non-OSGi project that consumes the OSGi bundle as a
            plain jar dependency.
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Robert Sykes Path: jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/pom.xml jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/print-api/pom.xml jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/print-api/src/main/java/jenkins/mvn/test/bundle/print/PrintService.java jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/print-impl/pom.xml jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/print-impl/src/main/java/jenkins/mvn/test/bundle/print/impl/PrintServiceImpl.java http://jenkins-ci.org/commit/pipeline-maven-plugin/a5ba8c6e0c32ae63c9549412c76aed0ac5e3e48e Log: JENKINS-47069 Add sample maven-bundle-plugin project A sample project that uses the maven-bundle-plugin to produce an OSGi bundle. Modules: print-api - OSGi bundle that exports a package containing an API. print-impl - Non-OSGi project that consumes the OSGi bundle as a plain jar dependency.

          Code changed in jenkins
          User: Cyrille Le Clerc
          Path:
          jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/pom.xml
          jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/print-api/pom.xml
          jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/print-api/src/main/java/jenkins/mvn/test/bundle/print/PrintService.java
          jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/print-impl/pom.xml
          jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/print-impl/src/main/java/jenkins/mvn/test/bundle/print/impl/PrintServiceImpl.java
          http://jenkins-ci.org/commit/pipeline-maven-plugin/221da6c875c108d659ca0711764bbe468a6150c8
          Log:
          Merge pull request #97 from robsykes24/JENKINS-47069

          JENKINS-47069 Add sample maven-bundle-plugin project

          Compare: https://github.com/jenkinsci/pipeline-maven-plugin/compare/270f0c716946...221da6c875c1

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Cyrille Le Clerc Path: jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/pom.xml jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/print-api/pom.xml jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/print-api/src/main/java/jenkins/mvn/test/bundle/print/PrintService.java jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/print-impl/pom.xml jenkins-plugin/src/test/resources/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/print-impl/src/main/java/jenkins/mvn/test/bundle/print/impl/PrintServiceImpl.java http://jenkins-ci.org/commit/pipeline-maven-plugin/221da6c875c108d659ca0711764bbe468a6150c8 Log: Merge pull request #97 from robsykes24/ JENKINS-47069 JENKINS-47069 Add sample maven-bundle-plugin project Compare: https://github.com/jenkinsci/pipeline-maven-plugin/compare/270f0c716946...221da6c875c1
          cleclerc Cyrille Le Clerc added a comment - - edited

          Thanks robsykes24

          See jenkins-event-spy-logst here

           

          Maven Event Spy
          <ExecutionEvent type="ProjectSucceeded" class="org.apache.maven.lifecycle.internal.DefaultExecutionEvent" _time="2017-09-25 22:48:51.249">
              <project baseDir="/path/to/multi_module_bundle_project/print-api" file="/path/to/multi_module_bundle_project/print-api/pom.xml" groupId="jenkins.mvn.test.bundle" name="print-api" artifactId="print-api" version="0.0.1-SNAPSHOT">
                <build sourceDirectory="/path/to/multi_module_bundle_project/print-api/src/main/java" directory="/path/to/multi_module_bundle_project/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>/path/to/multi_module_bundle_project/print-api/target/print-api-0.0.1-SNAPSHOT.jar</file>
              </artifact>
              <attachedArtifacts/>
            </ExecutionEvent>
          
          OSGi Bundle pom.xml uploaded on Nexus
          <?xml version="1.0" encoding="UTF-8"?>
          <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
              <modelVersion>4.0.0</modelVersion>
              <parent>
                  <groupId>jenkins.mvn.test.bundle</groupId>
                  <artifactId>bundle-parent</artifactId>
                  <version>0.0.1-SNAPSHOT</version>
              </parent>
              <artifactId>print-api</artifactId>
              <packaging>bundle</packaging>
              <name>${project.artifactId}</name>
              <description>An OSGI bundle that defines an API</description>
              <build>
                  <plugins>
                      <plugin>
                          <groupId>org.apache.felix</groupId>
                          <artifactId>maven-bundle-plugin</artifactId>
                          <extensions>true</extensions>
                          <configuration>
                              <instructions>
                                  <Export-Package>jenkins.mvn.test.bundle.print</Export-Package>
                              </instructions>
                          </configuration>
                      </plugin>
                  </plugins>
              </build>
          </project>
          
          pom.xml of the downstream job
          <?xml version="1.0" encoding="UTF-8"?>
          <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
              <modelVersion>4.0.0</modelVersion>
              <parent>
                  <groupId>jenkins.mvn.test.bundle</groupId>
                  <artifactId>bundle-parent</artifactId>
                  <version>0.0.1-SNAPSHOT</version>
              </parent>
              <artifactId>print-impl</artifactId>
              <name>${project.artifactId}</name>
              <description>A project that consumes an API jar that happens to be an OSGi bundle</description>
              <dependencies>
                  <dependency>
                      <groupId>${project.groupId}</groupId>
                      <artifactId>print-api</artifactId>
                      <version>${project.version}</version>
                  </dependency>
              </dependencies>
          </project>
          

          Notes:

          • The problem is that org.jenkinsci.plugins.pipeline.maven.dao.PipelineMavenPluginH2Dao#recordGeneratedArtifact sees a jenkins.mvn.test.bundle:print-api:bundle:0.0.1-SNAPSHOT when the dependency used by downstream jobs is jenkins.mvn.test.bundle:print-api:jar:0.0.1-SNAPSHOT
          • The artifact is stored on Nexus as a "bundle" and NOT as a "jar"
          • The downstream job uses a standard dependency (a "jar") and Maven downloads the "bundle" as if the fact that the packaging on Nexus was seen as "bundle" was ignored

          Questions

          • Should we just "hack" the database column maven_artifact.type and overwrite the type "bundle" and store it as a "jar"?
          • Or should we do something much more sophisticated introducing an "extension" column in the maven_artifact table ? This would mess with the unique key...
          cleclerc Cyrille Le Clerc added a comment - - edited Thanks robsykes24 See jenkins-event-spy-logst here   Maven Event Spy <ExecutionEvent type= "ProjectSucceeded" class= "org.apache.maven.lifecycle.internal.DefaultExecutionEvent" _time= "2017-09-25 22:48:51.249" > <project baseDir= "/path/to/multi_module_bundle_project/print-api" file= "/path/to/multi_module_bundle_project/print-api/pom.xml" groupId= "jenkins.mvn.test.bundle" name= "print-api" artifactId= "print-api" version= "0.0.1-SNAPSHOT" > <build sourceDirectory= "/path/to/multi_module_bundle_project/print-api/src/main/java" directory= "/path/to/multi_module_bundle_project/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> /path/to/multi_module_bundle_project/print-api/target/print-api-0.0.1-SNAPSHOT.jar </file> </artifact> <attachedArtifacts/> </ExecutionEvent> OSGi Bundle pom.xml uploaded on Nexus <?xml version= "1.0" encoding= "UTF-8" ?> <project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" > <modelVersion> 4.0.0 </modelVersion> <parent> <groupId> jenkins.mvn.test.bundle </groupId> <artifactId> bundle-parent </artifactId> <version> 0.0.1-SNAPSHOT </version> </parent> <artifactId> print-api </artifactId> <packaging> bundle </packaging> <name> ${project.artifactId} </name> <description> An OSGI bundle that defines an API </description> <build> <plugins> <plugin> <groupId> org.apache.felix </groupId> <artifactId> maven-bundle-plugin </artifactId> <extensions> true </extensions> <configuration> <instructions> <Export-Package> jenkins.mvn.test.bundle.print </Export-Package> </instructions> </configuration> </plugin> </plugins> </build> </project> pom.xml of the downstream job <?xml version= "1.0" encoding= "UTF-8" ?> <project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" > <modelVersion> 4.0.0 </modelVersion> <parent> <groupId> jenkins.mvn.test.bundle </groupId> <artifactId> bundle-parent </artifactId> <version> 0.0.1-SNAPSHOT </version> </parent> <artifactId> print-impl </artifactId> <name> ${project.artifactId} </name> <description> A project that consumes an API jar that happens to be an OSGi bundle </description> <dependencies> <dependency> <groupId> ${project.groupId} </groupId> <artifactId> print-api </artifactId> <version> ${project.version} </version> </dependency> </dependencies> </project> Notes: The problem is that org.jenkinsci.plugins.pipeline.maven.dao.PipelineMavenPluginH2Dao#recordGeneratedArtifact sees a jenkins.mvn.test.bundle:print-api:bundle:0.0.1-SNAPSHOT when the dependency used by downstream jobs is jenkins.mvn.test.bundle:print-api:jar:0.0.1-SNAPSHOT The artifact is stored on Nexus as a "bundle" and NOT as a "jar" The downstream job uses a standard dependency (a "jar") and Maven downloads the "bundle" as if the fact that the packaging on Nexus was seen as "bundle" was ignored Questions Should we just "hack" the database column maven_artifact.type and overwrite the type "bundle" and store it as a "jar"? Or should we do something much more sophisticated introducing an "extension" column in the maven_artifact table ? This would mess with the unique key...
          robsykes24 Robert Sykes added a comment -

          That is interesting analysis. I was not aware that Nexus actually stored it internally as a bundle.  I was under the impression that the "magic" happened on the client side since Maven doesn't know what a 'bundle' type is until the maven-bundle-plugin is registered as an extension. 

          I was thinking that the database should actually have two entries: one for "bundle" and one for "jar" (assuming that 'type' is part of the key).  The reasoning is that an OSGi bundle is a jar that has extra manifest metadata that is meaningful in the context of OSGi.  So a non-OSGi client would consume it as an ordinary jar.  However, an OSGi developer may try to consume it as "bundle" because that is the context in which the developer is working/thinking.  Also if the developer is using the Eclipse m2e UI to graphically add dependencies from the published upstream repository metadata indexes, it will populate the 'bundle' type.  This would show up as a non-resolvable dependency error for non-OSGi projects, but for OSGi projects that have the maven-bundle-plugin registered with extensions=true, it would resolve.  The problem with that is that there would be no indication to make them change the type from 'bundle' to 'jar' and the triggering would quietly not work.  However, if there is no easy way to support both types, then I would probably just go with the "hack".  A bundle is a jar and as far as I know there is no behavioural difference if the dependency is consumed as a 'jar' or a 'bundle'; the developer would just have to know to consume it that way for triggering to work. An extra 'extension' column is probably overkill for behaviour that is probably limited only to the maven-bundle-plugin and  would probably reduce the cohesion of the current implementation.

           

          robsykes24 Robert Sykes added a comment - That is interesting analysis. I was not aware that Nexus actually stored it internally as a bundle.  I was under the impression that the "magic" happened on the client side since Maven doesn't know what a 'bundle' type is until the maven-bundle-plugin is registered as an extension.  I was thinking that the database should actually have two entries: one for "bundle" and one for "jar" (assuming that 'type' is part of the key).  The reasoning is that an OSGi bundle is a jar that has extra manifest metadata that is meaningful in the context of OSGi.  So a non-OSGi client would consume it as an ordinary jar.  However, an OSGi developer may try to consume it as "bundle" because that is the context in which the developer is working/thinking.  Also if the developer is using the Eclipse m2e UI to graphically add dependencies from the published upstream repository metadata indexes, it will populate the 'bundle' type.  This would show up as a non-resolvable dependency error for non-OSGi projects, but for OSGi projects that have the maven-bundle-plugin registered with extensions=true, it would resolve.  The problem with that is that there would be no indication to make them change the type from 'bundle' to 'jar' and the triggering would quietly not work.  However, if there is no easy way to support both types, then I would probably just go with the "hack".  A bundle is a jar and as far as I know there is no behavioural difference if the dependency is consumed as a 'jar' or a 'bundle'; the developer would just have to know to consume it that way for triggering to work. An extra 'extension' column is probably overkill for behaviour that is probably limited only to the maven-bundle-plugin and  would probably reduce the cohesion of the current implementation.  
          cleclerc Cyrille Le Clerc made changes -
          Status Open [ 1 ] In Progress [ 3 ]

          Code changed in jenkins
          User: Cyrille Le Clerc
          Path:
          jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/dao/PipelineMavenPluginH2Dao.java
          jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/PipelineGraphPublisher.java
          jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/AbstractIntegrationTest.java
          jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/DependencyGraphTest.java
          http://jenkins-ci.org/commit/pipeline-maven-plugin/f0f6ed44457059db2f1381e0344fc524a9bb0d35
          Log:
          JENKINS-47069 record jar generated by org.apache.felix:maven-bundle-plugin:bundle with both types "jar" and "bundle"

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Cyrille Le Clerc Path: jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/dao/PipelineMavenPluginH2Dao.java jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/PipelineGraphPublisher.java jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/AbstractIntegrationTest.java jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/DependencyGraphTest.java http://jenkins-ci.org/commit/pipeline-maven-plugin/f0f6ed44457059db2f1381e0344fc524a9bb0d35 Log: JENKINS-47069 record jar generated by org.apache.felix:maven-bundle-plugin:bundle with both types "jar" and "bundle"
          cleclerc Cyrille Le Clerc made changes -
          Status In Progress [ 3 ] In Review [ 10005 ]
          cleclerc Cyrille Le Clerc added a comment - https://github.com/jenkinsci/pipeline-maven-plugin/pull/100

          Code changed in jenkins
          User: Cyrille Le Clerc
          Path:
          jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/dao/PipelineMavenPluginH2Dao.java
          maven-spy/pom.xml
          http://jenkins-ci.org/commit/pipeline-maven-plugin/d7a55565a544f73d82e27d814b415c44e2af815a
          Log:
          JENKINS-47069 Fix findbugs issue

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Cyrille Le Clerc Path: jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/dao/PipelineMavenPluginH2Dao.java maven-spy/pom.xml http://jenkins-ci.org/commit/pipeline-maven-plugin/d7a55565a544f73d82e27d814b415c44e2af815a Log: JENKINS-47069 Fix findbugs issue

          Code changed in jenkins
          User: Cyrille Le Clerc
          Path:
          jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/dao/PipelineMavenPluginH2Dao.java
          jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/PipelineGraphPublisher.java
          jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/AbstractIntegrationTest.java
          jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/DependencyGraphTest.java
          maven-spy/pom.xml
          http://jenkins-ci.org/commit/pipeline-maven-plugin/34b7cd44081559ea4da539686f9009e7d165a0ae
          Log:
          JENKINS-47069 record jar generated by org.apache.felix:maven-bundle-plugin:bundle with both types "jar" and "bundle" (#100)

          JENKINS-47069 record jar generated by org.apache.felix:maven-bundle-plugin:bundle with both types "jar" and "bundle"

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Cyrille Le Clerc Path: jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/dao/PipelineMavenPluginH2Dao.java jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/PipelineGraphPublisher.java jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/AbstractIntegrationTest.java jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/DependencyGraphTest.java maven-spy/pom.xml http://jenkins-ci.org/commit/pipeline-maven-plugin/34b7cd44081559ea4da539686f9009e7d165a0ae Log: JENKINS-47069 record jar generated by org.apache.felix:maven-bundle-plugin:bundle with both types "jar" and "bundle" (#100) JENKINS-47069 record jar generated by org.apache.felix:maven-bundle-plugin:bundle with both types "jar" and "bundle"
          cleclerc Cyrille Le Clerc made changes -
          Summary Downstream pipelines are not triggered when the artifact is a bundle and consumed as a jar Downstream pipelines are not triggered when the artifact is an OSGi bundle and consumed as a jar
          cleclerc Cyrille Le Clerc added a comment - robsykes24 can you please test the version 3.0.1-beta-2? https://github.com/jenkinsci/pipeline-maven-plugin/releases/tag/pipeline-maven-3.0.1-beta-2

          Fixed in 3.0.1

          cleclerc Cyrille Le Clerc added a comment - Fixed in 3.0.1
          cleclerc Cyrille Le Clerc made changes -
          Resolution Fixed [ 1 ]
          Status In Review [ 10005 ] Closed [ 6 ]
          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: