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

Properties are not passed to Maven command by Maven build step

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: core
    • Environment:
      ubuntu linux 15.10 64bit
      jenkins v2.27
      maven integration plugin v2.14
    • Similar Issues:

      Description

      The command I'm trying to get jenkins to execute is like this:

      mvn -Dparam1=val1 -Dparam2=val2 -f bdd/pom.xml test

      My pom.xml has param1 and param2 properties whose values need to be passed in to work, and the above command, when run manually, works.

      When I try to set that command up in a "Invoke top-level Maven targets" build step, as shown in the fails.png screenshot I attached (putting param1 and param2 in the Properties field, as the help/hint states I should), they are not provided in the maven command (confirmed with jenkins console output and observation that the build fails because of those missing values).

      As a workaround, I can provide them explicitly in the Goals section (as shown by succeeds.png), but that strikes me as a hack, given the way the maven integration plugin separates goals and properties into separate input fields.

        Attachments

        1. fails.png
          fails.png
          39 kB
        2. succeeds.png
          succeeds.png
          38 kB

          Activity

          Hide
          victor Victor Ott added a comment - - edited

          I can confirm this issue with following versions:

          • Jenkins ver. 2.19.2 (LTS)
          • Maven Integration plugin 2.14
          • SUSE Linux Enterprise Server 11 (x86_64) Patch 4
          • Java build 1.8.0_92-b14, 64-Bit Server VM (build 25.92-b14, mixed mode)

          Note: if you set the checkbox "Inject build variables", then not only all job parameters are injected into the Maven command line, as expected, BUT also the definitions from "Properties" sections. This is not the expected behaviour.

          In my opinion this isn't a minor issue, because it affects LOTS of jobs, without error messages, and it causes therefore inconsistent builds without anyone noticing that!

          Show
          victor Victor Ott added a comment - - edited I can confirm this issue with following versions: Jenkins ver. 2.19.2 (LTS) Maven Integration plugin 2.14 SUSE Linux Enterprise Server 11 (x86_64) Patch 4 Java build 1.8.0_92-b14, 64-Bit Server VM (build 25.92-b14, mixed mode) Note: if you set the checkbox "Inject build variables", then not only all job parameters are injected into the Maven command line, as expected, BUT also the definitions from "Properties" sections. This is not the expected behaviour. In my opinion this isn't a minor issue, because it affects LOTS of jobs, without error messages, and it causes therefore inconsistent builds without anyone noticing that!
          Hide
          victor Victor Ott added a comment - - edited

          The problem lies within class hudson.tasks.Maven, which afaik is part of "core" Jenkins, and was introduced with following commit:
          https://github.com/jenkinsci/jenkins/commit/e66e719f1e6caa54b546a5bdee5ab062089d21c2

          Show
          victor Victor Ott added a comment - - edited The problem lies within class hudson.tasks.Maven , which afaik is part of "core" Jenkins, and was introduced with following commit: https://github.com/jenkinsci/jenkins/commit/e66e719f1e6caa54b546a5bdee5ab062089d21c2
          Hide
          victor Victor Ott added a comment -
          Show
          victor Victor Ott added a comment - Submitted pull request: https://github.com/jenkinsci/jenkins/pull/2638
          Hide
          oleg_nenashev Oleg Nenashev added a comment -

          Marked as lts-candidate according to the proposal from Mark Waite

          Show
          oleg_nenashev Oleg Nenashev added a comment - Marked as lts-candidate according to the proposal from Mark Waite
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Victor
          Path:
          core/src/main/java/hudson/tasks/Maven.java
          test/src/test/java/hudson/tasks/MavenTest.java
          http://jenkins-ci.org/commit/jenkins/138ce3d8d191daab42ed986254ae689ceb836aad
          Log:
          [FIX JENKINS-39268] Properties are not passed to Maven command by Maven build step (#2638)

          • [FIX JENKINS-39268] Properties are not passed to Maven command by Maven build step
          • [FIX JENKINS-39268] Properties are not passed to Maven command by Maven build step
          • [FIX JENKINS-39268] Properties are not passed to Maven command by Maven build step
          • [FIX JENKINS-39268] Changed order in which properties are appended to command line: properties appended later win in case of conflicts
          • [FIX JENKINS-39268] More precise messages in some assertions
          • [FIX JENKINS-39268] Cleanup unused imports
          • [FIX JENKINS-39268] Added functional tests for Maven task.
          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Victor Path: core/src/main/java/hudson/tasks/Maven.java test/src/test/java/hudson/tasks/MavenTest.java http://jenkins-ci.org/commit/jenkins/138ce3d8d191daab42ed986254ae689ceb836aad Log: [FIX JENKINS-39268] Properties are not passed to Maven command by Maven build step (#2638) [FIX JENKINS-39268] Properties are not passed to Maven command by Maven build step [FIX JENKINS-39268] Properties are not passed to Maven command by Maven build step [FIX JENKINS-39268] Properties are not passed to Maven command by Maven build step [FIX JENKINS-39268] Changed order in which properties are appended to command line: properties appended later win in case of conflicts [FIX JENKINS-39268] More precise messages in some assertions [FIX JENKINS-39268] Cleanup unused imports [FIX JENKINS-39268] Added functional tests for Maven task.
          Hide
          victor Victor Ott added a comment - - edited

          Fix should be available starting with Jenkins 2.39.

          Show
          victor Victor Ott added a comment - - edited Fix should be available starting with Jenkins 2.39.
          Hide
          victor Victor Ott added a comment -

          First LTS version containing fix is 2.32.2

          Show
          victor Victor Ott added a comment - First LTS version containing fix is 2.32.2

            People

            • Assignee:
              michaeln Michael Nachtigal
              Reporter:
              michaeln Michael Nachtigal
            • Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: