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

Maven 2 Extra Steps does not use private Maven repository if set on project

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      If "Use private Maven repository" is set for maven build, then it should also be
      set for any configured M2 Extra Build Steps.

      Currently, the flags passed to the main mvn task to use the private repository
      i.e.:
      Executing Maven: -B -f /opt/hudson/.hudson/jobs/MYJOB/workspace/pom.xml
      -Dmaven.repo.local=/opt/hudson/.hudson/jobs/MYJOB/workspace/.repository package

      are not passed to the maven that is invoked from any of these extra build steps.
      i.e.:
      [workspace] $ /opt/apache-maven-2.0.9/bin/mvn clean

        Attachments

          Activity

          Hide
          abayer Andrew Bayer added a comment -

          The m2-extra-steps plugin doesn't actually handle the Maven execution (or shell,
          or Ant, etc) of the extra steps - they run the same as they would in a freestyle
          project. As a result, they're completely unaware of anything set for the POM,
          MAVEN_OPTS, private repository, etc for the main Maven execution of the job. If
          you want to have the extra steps use the main Maven execution's private
          repository, you'll want to click on the Advanced button for your Maven extra
          step, and add "maven.repo.local=${WORKSPACE}/.repository" to the Properties
          field. That'll make sure the Maven invocation in your extra step has the needed
          -Dmaven.repo.local=... in its arguments.

          Show
          abayer Andrew Bayer added a comment - The m2-extra-steps plugin doesn't actually handle the Maven execution (or shell, or Ant, etc) of the extra steps - they run the same as they would in a freestyle project. As a result, they're completely unaware of anything set for the POM, MAVEN_OPTS, private repository, etc for the main Maven execution of the job. If you want to have the extra steps use the main Maven execution's private repository, you'll want to click on the Advanced button for your Maven extra step, and add "maven.repo.local=${WORKSPACE}/.repository" to the Properties field. That'll make sure the Maven invocation in your extra step has the needed -Dmaven.repo.local=... in its arguments.
          Hide
          radaczynski radaczynski added a comment -

          @abayer: why then there is a checkbox in the UI for the pre build steps that says "Use private Maven repository". I think the checkbox should be either removed or made to work.

          Show
          radaczynski radaczynski added a comment - @abayer: why then there is a checkbox in the UI for the pre build steps that says "Use private Maven repository". I think the checkbox should be either removed or made to work.
          Hide
          radaczynski radaczynski added a comment -

          as per comment - there is still a checkbox in the ui that states "use private maven repository", which should be removed.

          Show
          radaczynski radaczynski added a comment - as per comment - there is still a checkbox in the ui that states "use private maven repository", which should be removed.
          Hide
          oakinger Erich Eichinger added a comment -

          actually in v1.480 using an maven2 job, I see the opposite problem: when checked "use private repository" on a pre/post build extra step, the repo gets properly passed on. But...

          The problem is

          1) uncheck the box and "Save" the job configuration
          the build properly using the global repo
          2) open the job configuration again
          -> the checkbox is ticked again!

          after saving the job config with unchecked "use private repo" the job.xml correctly shows <usePrivateRepository>false</usePrivateRepository>. When you reopen the configuration the boxes are magically checked again - unfortunately that is hidden because it is an advanced setting

          Show
          oakinger Erich Eichinger added a comment - actually in v1.480 using an maven2 job, I see the opposite problem: when checked "use private repository" on a pre/post build extra step, the repo gets properly passed on. But... The problem is 1) uncheck the box and "Save" the job configuration the build properly using the global repo 2) open the job configuration again -> the checkbox is ticked again! after saving the job config with unchecked "use private repo" the job.xml correctly shows <usePrivateRepository>false</usePrivateRepository>. When you reopen the configuration the boxes are magically checked again - unfortunately that is hidden because it is an advanced setting
          Hide
          frido82 Federico Paolantoni added a comment -

          I'm running jenkins 1.466.2 LTS and i have the same issue of Erich Eichinger.
          I have several jobs with multiple maven invocation. This issue should be promoved to blocker.

          Show
          frido82 Federico Paolantoni added a comment - I'm running jenkins 1.466.2 LTS and i have the same issue of Erich Eichinger. I have several jobs with multiple maven invocation. This issue should be promoved to blocker.
          Hide
          wjg57 Wolf Geldmacher added a comment -

          In Jenkins 1.531 the behaviour is still as described by Erich.

          What's even uglier is that when leaving the box ticked a workspace local repository will always be used, even if default and/or job settings specify a repository local to the executor. In my use case that results in (matrix-)builds that take a lot longer than they should.

          It is not possible to configure executor-local repositories, except by turning off "use private repository" every time the job is modified and hard-coding -Dmaven.repo.local=$HOME/jenkins/maven-repositories/$EXECUTOR_NUMBER into the argument of the pre-build job.

          Should the checkbox be removed (as per suggestions by radaczynski) I definitely would expect the pre/post jobs to use the same maven.repo.local configuration as the main job.

          Show
          wjg57 Wolf Geldmacher added a comment - In Jenkins 1.531 the behaviour is still as described by Erich. What's even uglier is that when leaving the box ticked a workspace local repository will always be used, even if default and/or job settings specify a repository local to the executor. In my use case that results in (matrix-)builds that take a lot longer than they should. It is not possible to configure executor-local repositories, except by turning off "use private repository" every time the job is modified and hard-coding -Dmaven.repo.local=$HOME/jenkins/maven-repositories/$EXECUTOR_NUMBER into the argument of the pre-build job. Should the checkbox be removed (as per suggestions by radaczynski) I definitely would expect the pre/post jobs to use the same maven.repo.local configuration as the main job.
          Hide
          enrice Erich Mauerböck added a comment - - edited

          Jenkins 1.643: Here the opposite happens. I check the private repository and save (this is working thereafter), but when I reopen the config, the checkbox is unset again. So I have to re-set it each time I change the config. This is a duplicate of JENKINS-41296

          Show
          enrice Erich Mauerböck added a comment - - edited Jenkins 1.643: Here the opposite happens. I check the private repository and save (this is working thereafter), but when I reopen the config, the checkbox is unset again. So I have to re-set it each time I change the config. This is a duplicate of JENKINS-41296

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jchristi jchristi
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated: