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

Predefined parameters not passing correct NODE_LABELS environment variable information.

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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.

        Attachments

          Activity

          jaystan Jason Stanley created issue -
          Hide
          jaystan Jason Stanley added a comment -

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

          Show
          jaystan Jason Stanley added a comment - As you can see, I have $NODE_LABELS as a predefined parameter.
          jaystan Jason Stanley made changes -
          Field Original Value New Value
          Attachment Upstream job predefined parameters.jpg [ 22805 ]
          Hide
          jaystan 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.

          Show
          jaystan 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.
          jaystan Jason Stanley made changes -
          Hide
          jaystan 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.

          Show
          jaystan 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.
          Hide
          jaystan Jason Stanley added a comment -

          Correct NODE_LABEL value from upstream build.

          Show
          jaystan Jason Stanley added a comment - Correct NODE_LABEL value from upstream build.
          jaystan Jason Stanley made changes -
          Hide
          cjo9900 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

          Show
          cjo9900 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
          Hide
          jaystan 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.

          Show
          jaystan 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.
          Hide
          cjo9900 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.

          Show
          cjo9900 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 cjo9900 made changes -
          Assignee huybrechts [ huybrechts ] cjo9900 [ cjo9900 ]
          Hide
          cjo9900 cjo9900 added a comment -

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

          Show
          cjo9900 cjo9900 added a comment - Please retest with version 2.17 of the plugin and close if resolved.
          Hide
          hiteswar_kumar 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

          Show
          hiteswar_kumar 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
          Hide
          ikedam 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.
          Show
          ikedam 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.
          ikedam ikedam made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Resolved [ 5 ]
          rtyler R. Tyler Croy made changes -
          Workflow JNJira [ 146550 ] JNJira + In-Review [ 191971 ]

            People

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

              Dates

              Created:
              Updated:
              Resolved: