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

hpi:run uses wrong jpi/hpl from .jenkins-hpl-map

XMLWordPrintable

      When starting a plugin with hpi:run, using some dependencies locally built, the related the.hpl copied into work/plugins/xxx.jpi coming from /Users/XXX/.jenkins-hpl-map is not the one expected.

      This occurs when same repository is cloned in different paths

      IT reproduction

      Clone https://github.com/jenkinsci/maven-hpi-plugin

      Extract content of JENKINS-70329.zip into src/it/

      Execute mvn -Prun-its mrm:start invoker:run mrm:stop -Dinvoker.test=JENKINS-70329-dir-one,JENKINS-70329-dir-two

      See failure of IT

      Manual reproduction

      % cd ~
      % mkdir test
      % cd test
      % mkdir tmp1
      % clone https://github.com/jenkinsci/pipeline-model-definition-plugin
      % cd pipeline-model-definition-plugin
      % mvn install -DskipTests
      % cd ~
      % cd test
      % mkdir tmp2
      % clone https://github.com/jenkinsci/pipeline-model-definition-plugin
      % cd pipeline-model-definition-plugin
      % mvn install -DskipTests

      Notice ~/.jenkins-hpl-map now contains additional entries, some pointing to tmp1, some to tmp2:

      /Users/XXX/test/tmp1/pipeline-model-definition-plugin/pipeline-stage-tags-metadata/target/test-classes/the.hpl=org.jenkinsci.plugins\:pipeline-stage-tags-metadata\:hpi\:999999-SNAPSHOT
      /Users/XXX/test/tmp2/pipeline-model-definition-plugin/pipeline-model-api/target/test-classes/the.hpl=org.jenkinsci.plugins\:pipeline-model-api\:hpi\:999999-SNAPSHOT
      /Users/XXX/test/tmp2/pipeline-model-definition-plugin/pipeline-model-definition/target/test-classes/the.hpl=org.jenkinsci.plugins\:pipeline-model-definition\:hpi\:999999-SNAPSHOT
      /Users/XXX/test/tmp1/pipeline-model-definition-plugin/pipeline-model-api/target/test-classes/the.hpl=org.jenkinsci.plugins\:pipeline-model-api\:hpi\:999999-SNAPSHOT
      /Users/XXX/test/tmp1/pipeline-model-definition-plugin/pipeline-model-extensions/target/test-classes/the.hpl=org.jenkinsci.plugins\:pipeline-model-extensions\:hpi\:999999-SNAPSHOT
      /Users/XXX/test/tmp2/pipeline-model-definition-plugin/pipeline-stage-tags-metadata/target/test-classes/the.hpl=org.jenkinsci.plugins\:pipeline-stage-tags-metadata\:hpi\:999999-SNAPSHOT
      /Users/XXX/test/tmp1/pipeline-model-definition-plugin/pipeline-model-definition/target/test-classes/the.hpl=org.jenkinsci.plugins\:pipeline-model-definition\:hpi\:999999-SNAPSHOT
      /Users/XXX/test/tmp2/pipeline-model-definition-plugin/pipeline-model-extensions/target/test-classes/the.hpl=org.jenkinsci.plugins\:pipeline-model-extensions\:hpi\:999999-SNAPSHOT
      

      Now start sub-module pipeline-model-definition with hpi:run:

      % cd ~
      % cd test/tmp1/pipeline-model-definition-plugin/pipeline-model-definition
      % mvn hpi:run
      

      Notice the logs occurring during maven-hpi-plugin execution, and check some snapshot dependencies are not the ones expected:
      We expect /Users/xxx/test/tmp1/..., but some are /Users/xxx/test/tmp2/...

      [INFO] — maven-hpi-plugin:3.32:run (default-cli) @ pipeline-model-definition —
      [INFO] Logging initialized @9306ms to org.eclipse.jetty.util.log.Slf4jLog
      [INFO] Generating /Users/XXX/test/tmp1/pipeline-model-definition-plugin/pipeline-model-definition/work/plugins/pipeline-model-definition.hpl
      ...
      [INFO] Copying snapshot dependency Jenkins plugin /Users/XXX/test/tmp1/pipeline-model-definition-plugin/pipeline-stage-tags-metadata/target/test-classes/the.hpl
      ...
      [INFO] Copying snapshot dependency Jenkins plugin /Users/XXX/test/tmp1/pipeline-model-definition-plugin/pipeline-model-extensions/target/test-classes/the.hpl
      ...
      [INFO] Copying snapshot dependency Jenkins plugin /Users/XXX/test/tmp2/pipeline-model-definition-plugin/pipeline-model-api/target/test-classes/the.hpl
       

      Issue occurs here: https://github.com/jenkinsci/maven-hpi-plugin/blob/ab56c6d1257f5d58affe573af751a7bb32344600/src/main/java/org/jenkinsci/maven/plugins/hpi/PluginWorkspaceMapImpl.java#L46-L56
      We take the first matching declaration from /Users/XXX/.jenkins-hpl-map no matter the current mvn project basedir.

            jgreffe Julien Greffe
            jgreffe Julien Greffe
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: