According to https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-JenkinsSetEnvironmentVariables JOB_NAME should only be the project name, but it actually includes parameters, e.g. job_name/parameter1=value2,parameter2=value2

      Workaround:

      JOB_NAME=$(echo $JOB_NAME | cut -d '/' -f 1)
      

          [JENKINS-39189] JOB_NAME includes parameters

          Rachel M. added a comment -

          Please, where are you writing $JOB_NAME value? What job configuration option?

          Rachel M. added a comment - Please, where are you writing $JOB_NAME value? What job configuration option?

          Xian Yi Teng added a comment -

          In an execute shell build step and also an execute shell post-build action.

          Also, this is unrelated, but I think there are two separate logins for the Jenkins Jira? accounts.jenkins.io and the link on the top right. I had to log in to both of them... Took me a while to figure that out.

          Xian Yi Teng added a comment - In an execute shell build step and also an execute shell post-build action. Also, this is unrelated, but I think there are two separate logins for the Jenkins Jira? accounts.jenkins.io and the link on the top right. I had to log in to both of them... Took me a while to figure that out.

          Rachel M. added a comment -

          Please, give us more details: Jenkins version, execution example, console output, ...

          According to logins, accounts.jenkins.io is only to manage your account. You don't need to login twice to use JIRA. Only in https://issues.jenkins-ci.org.

          Rachel M. added a comment - Please, give us more details: Jenkins version, execution example, console output, ... According to logins, accounts.jenkins.io is only to manage your account. You don't need to login twice to use JIRA. Only in https://issues.jenkins-ci.org .

          Xian Yi Teng added a comment -

          Job config attached. config.xml

          Jenkins ver. 1.642.4
          
          Started by upstream project "XIAN_TENG_TEST_JOB" build number 1
          originally caused by:
           Started by user xian.teng
          [EnvInject] - Loading node environment variables.
          Building remotely on ubuntu-1204-03-64 (qa_runner admin_linux build_docs 12.04 amd64-Ubuntu Ubuntu amd64-Ubuntu-12.04 Ubuntu-12.04 amd64) in workspace /jenkins_data/jenkins/workspace/XIAN_TENG_TEST_JOB/parameter1_axis/value1/parameter2_axis/value2
          [value2] $ /bin/sh -xe /tmp/hudson5641186992722460038.sh
          + echo build step
          build step
          + echo value1
          value1
          + echo value2
          value2
          + echo XIAN_TENG_TEST_JOB/parameter1_axis=value1,parameter2_axis=value2
          XIAN_TENG_TEST_JOB/parameter1_axis=value1,parameter2_axis=value2
          Finished: SUCCESS
          

          Xian Yi Teng added a comment - Job config attached. config.xml Jenkins ver. 1.642.4 Started by upstream project "XIAN_TENG_TEST_JOB" build number 1 originally caused by: Started by user xian.teng [EnvInject] - Loading node environment variables. Building remotely on ubuntu-1204-03-64 (qa_runner admin_linux build_docs 12.04 amd64-Ubuntu Ubuntu amd64-Ubuntu-12.04 Ubuntu-12.04 amd64) in workspace /jenkins_data/jenkins/workspace/XIAN_TENG_TEST_JOB/parameter1_axis/value1/parameter2_axis/value2 [value2] $ /bin/sh -xe /tmp/hudson5641186992722460038.sh + echo build step build step + echo value1 value1 + echo value2 value2 + echo XIAN_TENG_TEST_JOB/parameter1_axis=value1,parameter2_axis=value2 XIAN_TENG_TEST_JOB/parameter1_axis=value1,parameter2_axis=value2 Finished: SUCCESS

          Sean Sutherland added a comment - - edited

          This looks like behavior as intended. For Matrix projects, the individual sub-projects have names according to parameter names, which is independent from the parent name (the name of the matrix project). See https://github.com/jenkinsci/matrix-project-plugin/blob/master/src/main/java/hudson/matrix/MatrixConfiguration.java#L97

          In your environment JOB_NAME is being set to the full path to the job. In XIAN_TENG_TEST_JOB/parameter1_axis=value1,parameter2_axis=value2, XIAN_TENG_TEST_JOB refers to the parent of your job (like with folders), and parameter1_axis=value1,parameter2_axis=value2 is the actual job name.

          In newer versions of Jenkins, the environment will also contain JOB_BASE_NAME, which in your case would just be parameter1_axis=value1,parameter2_axis=value2. As far as I know, the parent name is not injected into the environment, though that might be a decent feature ask to put in (at least for matrix jobs?)

          Sean Sutherland added a comment - - edited This looks like behavior as intended. For Matrix projects, the individual sub-projects have names according to parameter names, which is independent from the parent name (the name of the matrix project). See https://github.com/jenkinsci/matrix-project-plugin/blob/master/src/main/java/hudson/matrix/MatrixConfiguration.java#L97 In your environment JOB_NAME is being set to the full path to the job. In XIAN_TENG_TEST_JOB / parameter1_axis=value1,parameter2_axis=value2 , XIAN_TENG_TEST_JOB refers to the parent of your job (like with folders), and parameter1_axis=value1,parameter2_axis=value2 is the actual job name. In newer versions of Jenkins, the environment will also contain JOB_BASE_NAME, which in your case would just be parameter1_axis=value1,parameter2_axis=value2 . As far as I know, the parent name is not injected into the environment, though that might be a decent feature ask to put in (at least for matrix jobs?)

          Oleg Nenashev added a comment -

          From what I see it is a duplicate of JENKINS-28176 

          The documentation is just outdated, but actually the full name with parameters is valid for Matrix projects

          Oleg Nenashev added a comment - From what I see it is a duplicate of  JENKINS-28176   The documentation is just outdated, but actually the full name with parameters is valid for Matrix projects

            Unassigned Unassigned
            xytxytxyt Xian Yi Teng
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: