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

Predefined parameters not passing correct NODE_LABELS environment variable information.

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • Jenkins version 1.482 running on CentOS 5.8

      The value of "master" gets passed to the down stream job when you define NODE_LABELS in the Predefined parameters section of an upstream job.

      See attached screenshot showing the "Predefined parameters section" of the upstream job and the console output of the downstream job.

          [JENKINS-15749] Predefined parameters not passing correct NODE_LABELS environment variable information.

          Jason Stanley added a comment -

          As you can see, I have $NODE_LABELS as a predefined parameter.

          Jason Stanley added a comment - As you can see, I have $NODE_LABELS as a predefined parameter.

          Jason Stanley added a comment -

          You can see the value for Node Label is "master".

          This is incorrect, see next screenshot for environment variable output from upstream build.

          Jason Stanley added a comment - You can see the value for Node Label is "master". This is incorrect, see next screenshot for environment variable output from upstream build.

          Jason Stanley added a comment -

          Please ignore first screenshot showing Predefined parameters section as the $NL was set incorrectly, it is now just NL=$NODE_LABELS.

          Jason Stanley added a comment - Please ignore first screenshot showing Predefined parameters section as the $NL was set incorrectly, it is now just NL=$NODE_LABELS.

          Jason Stanley added a comment -

          Correct NODE_LABEL value from upstream build.

          Jason Stanley added a comment - Correct NODE_LABEL value from upstream build.

          cjo9900 added a comment -

          From your description the issue is that you indicate that "master" should not be in the list of labels.

          However the list of labels does includes the self label (which is the name of slave its self) as indicated in getAssignedLabels()[1] which is called from the CoreEnvironmentContributor[3].

          So in this case I don't think this is an error, as I assume that upstream job was run on master.

          [1] http://javadoc.jenkins-ci.org/hudson/model/Node.html#getAssignedLabels()
          [2] http://javadoc.jenkins-ci.org/hudson/model/Node.html#getSelfLabel()
          [3] https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/jenkins/model/CoreEnvironmentContributor.java#L56

          cjo9900 added a comment - From your description the issue is that you indicate that "master" should not be in the list of labels. However the list of labels does includes the self label (which is the name of slave its self) as indicated in getAssignedLabels() [1] which is called from the CoreEnvironmentContributor [3] . So in this case I don't think this is an error, as I assume that upstream job was run on master. [1] http://javadoc.jenkins-ci.org/hudson/model/Node.html#getAssignedLabels( ) [2] http://javadoc.jenkins-ci.org/hudson/model/Node.html#getSelfLabel( ) [3] https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/jenkins/model/CoreEnvironmentContributor.java#L56

          Jason Stanley added a comment -

          In this case, the upstream job was not run on the master but a slave.

          If you look at the screenshot of the job output, you will see the value of NODE_LABELS is not master, but the name of the slave which the job is running on.

          All of the other environment variables are correctly passed to the downstream job except this one.

          Jason Stanley added a comment - In this case, the upstream job was not run on the master but a slave. If you look at the screenshot of the job output, you will see the value of NODE_LABELS is not master, but the name of the slave which the job is running on. All of the other environment variables are correctly passed to the downstream job except this one.

          cjo9900 added a comment -

          I think you have hit the issue that has already been fixed in commit
          https://github.com/jenkinsci/parameterized-trigger-plugin/commit/16586248c382ef417e0aaa1d2cdb00baee87ec18
          which has not yet been released.

          Where the Environment variables are not correct, due to using the Dependancy Graph to trigger the downstream builds which always runs on master therefore gets the node labels from there, rather than from the slave that the job ran on.

          cjo9900 added a comment - I think you have hit the issue that has already been fixed in commit https://github.com/jenkinsci/parameterized-trigger-plugin/commit/16586248c382ef417e0aaa1d2cdb00baee87ec18 which has not yet been released. Where the Environment variables are not correct, due to using the Dependancy Graph to trigger the downstream builds which always runs on master therefore gets the node labels from there, rather than from the slave that the job ran on.

          cjo9900 added a comment -

          Please retest with version 2.17 of the plugin and close if resolved.

          cjo9900 added a comment - Please retest with version 2.17 of the plugin and close if resolved.

          I checked below at 2.17:
          downstream triggered build got parameter NODE_LABELS and its value corerctly
          but build is not triggered on node which received in NODE_LABELS.
          downstream triggered job tested with below both parameters:
          label
          or
          node

          upstream build sending NODE_LABELS value by predefined parameter window.

          as an alternative solution: nodelabelparamter setting at config of "trigger/call build on other project " at upstream job allow downstream build on correct slave as defined in NODE_LABELS

          hiteswar kumar added a comment - I checked below at 2.17: downstream triggered build got parameter NODE_LABELS and its value corerctly but build is not triggered on node which received in NODE_LABELS. downstream triggered job tested with below both parameters: label or node upstream build sending NODE_LABELS value by predefined parameter window. as an alternative solution: nodelabelparamter setting at config of "trigger/call build on other project " at upstream job allow downstream build on correct slave as defined in NODE_LABELS

          ikedam added a comment -

          I tested and see fixed in latest Jenkins 1.532.2 + Parameterized Trigger 2.23.
          How I tested:

          1. Create a free style project "downstream"
            • Add "Execute Windows batch command" and call "set"
              • It would be same to add "Execute shell" and call "export"
          2. Create a free style project "upstream"
            • Add "Execute Windows batch command" and call "set"
              • It would be same to add "Execute shell" and call "export"
            • Add "Trigger parameterized builds on other projects"
              • set "Projects to build" to "downstream"
              • Add "Predefined parameters" and set "PASSED_NODE_LABELS=${NODE_LABELS}"
          3. Launch upstream build
          4. See console log of downstream build and see "PASSED_NODE_LABELS=master" is output.

          ikedam added a comment - I tested and see fixed in latest Jenkins 1.532.2 + Parameterized Trigger 2.23. How I tested: Create a free style project "downstream" Add "Execute Windows batch command" and call "set" It would be same to add "Execute shell" and call "export" Create a free style project "upstream" Add "Execute Windows batch command" and call "set" It would be same to add "Execute shell" and call "export" Add "Trigger parameterized builds on other projects" set "Projects to build" to "downstream" Add "Predefined parameters" and set "PASSED_NODE_LABELS=${NODE_LABELS}" Launch upstream build See console log of downstream build and see "PASSED_NODE_LABELS=master" is output.

            cjo9900 cjo9900
            jaystan Jason Stanley
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: