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

NODE_NAME not defined for master node

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: core
    • Labels:
      None
    • Environment:
      Windows Server 2003 master and slaves
    • Similar Issues:

      Description

      I was trying to setup my Clearcase views for my nodes based on the ${NODE_NAME} variable, so that each slave would have a unique view name. ${NODE_NAME} is empty on the master, so I cannot use it to create view on the master and have to hard code the view path for each slave, making it so I can't move builds between nodes easily. I have specific requirements to set a custom workspace based on the NODE_NAME.

        Attachments

          Issue Links

            Activity

            Hide
            slide_o_mix Alex Earl added a comment -
            Show
            slide_o_mix Alex Earl added a comment - Initial implementation in https://github.com/jenkinsci/jenkins/pull/120
            Hide
            dogfood dogfood added a comment -
            Show
            dogfood dogfood added a comment - Integrated in jenkins_main_trunk #803
            Hide
            slide_o_mix Alex Earl added a comment -

            Ran test with the following as a build step on master

            echo ${NODE_NAME} > node.txt

            The console log shows that NODE_NAME was expanded to "master" and the file node.txt contains "master" for content.

            Show
            slide_o_mix Alex Earl added a comment - Ran test with the following as a build step on master echo ${NODE_NAME} > node.txt The console log shows that NODE_NAME was expanded to "master" and the file node.txt contains "master" for content.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Slide
            Path:
            core/src/main/java/hudson/model/Run.java
            http://jenkins-ci.org/commit/jenkins/9610fe55c17853ef2f7e0eb39ce1333c6346270c
            Log:
            [FIXED JENKINS-9671] Set NODE_NAME to master for "master" node

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Slide Path: core/src/main/java/hudson/model/Run.java http://jenkins-ci.org/commit/jenkins/9610fe55c17853ef2f7e0eb39ce1333c6346270c Log: [FIXED JENKINS-9671] Set NODE_NAME to master for "master" node
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Slide
            Path:
            core/src/main/java/hudson/model/Run.java
            http://jenkins-ci.org/commit/jenkins/9610fe55c17853ef2f7e0eb39ce1333c6346270c
            Log:
            [FIXED JENKINS-9671] Set NODE_NAME to master for "master" node

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Slide Path: core/src/main/java/hudson/model/Run.java http://jenkins-ci.org/commit/jenkins/9610fe55c17853ef2f7e0eb39ce1333c6346270c Log: [FIXED JENKINS-9671] Set NODE_NAME to master for "master" node
            Hide
            owenmehegan Owen Mehegan added a comment -

            This seems to be broken in 1.465. $NODE_NAME is unset, but $NODE_LABELS includes "master" on the master node.

            Show
            owenmehegan Owen Mehegan added a comment - This seems to be broken in 1.465. $NODE_NAME is unset, but $NODE_LABELS includes "master" on the master node.
            Hide
            slide_o_mix Alex Earl added a comment -

            Looks like the way environment variables are gathered is now different with the new EnvironmentContributor. Though I am not sure why it would be missing, the same code as was used to set it from before has been moved to CoreEnvironmentContributor, so it should still be adding it.

            Show
            slide_o_mix Alex Earl added a comment - Looks like the way environment variables are gathered is now different with the new EnvironmentContributor. Though I am not sure why it would be missing, the same code as was used to set it from before has been moved to CoreEnvironmentContributor, so it should still be adding it.
            Hide
            slide_o_mix Alex Earl added a comment -

            Also, I am using 1.465 and don't see this issue.

            Show
            slide_o_mix Alex Earl added a comment - Also, I am using 1.465 and don't see this issue.
            Hide
            owenmehegan Owen Mehegan added a comment -

            I should have mentioned that I'm on Linux. Didn't notice that the env for this bug is described as Windows Server.

            I verified that I'm seeing the incorrect behavior. I created a matrix job, and assigned it to run on the master and a slave node. The job just runs 'echo "Node name is $NODE_NAME"'

            On the master:
            Building on master in workspace /home/br/hudson/hudson-data/jobs/matrix_test/workspace/label/lenny_32bit
            [lenny_32bit] $ /bin/sh -xe /tmp/hudson6521396441231883115.sh
            + echo 'Node name is '
            Node name is
            Finished: SUCCESS

            On the slave:
            Building remotely on jenkins-precise-64 in workspace /home/br/hudson-data/workspace/matrix_test/label/precise_64bit
            [precise_64bit] $ /bin/sh -xe /tmp/hudson5676803587228444916.sh
            + echo Node name is jenkins-precise-64
            Node name is jenkins-precise-64
            Finished: SUCCESS

            Show
            owenmehegan Owen Mehegan added a comment - I should have mentioned that I'm on Linux. Didn't notice that the env for this bug is described as Windows Server. I verified that I'm seeing the incorrect behavior. I created a matrix job, and assigned it to run on the master and a slave node. The job just runs 'echo "Node name is $NODE_NAME"' On the master: Building on master in workspace /home/br/hudson/hudson-data/jobs/matrix_test/workspace/label/lenny_32bit [lenny_32bit] $ /bin/sh -xe /tmp/hudson6521396441231883115.sh + echo 'Node name is ' Node name is Finished: SUCCESS On the slave: Building remotely on jenkins-precise-64 in workspace /home/br/hudson-data/workspace/matrix_test/label/precise_64bit [precise_64bit] $ /bin/sh -xe /tmp/hudson5676803587228444916.sh + echo Node name is jenkins-precise-64 Node name is jenkins-precise-64 Finished: SUCCESS
            Hide
            owenmehegan Owen Mehegan added a comment -

            I don't know when this was fixed, but it's working now in 1.514 on Linux.

            Show
            owenmehegan Owen Mehegan added a comment - I don't know when this was fixed, but it's working now in 1.514 on Linux.
            Hide
            owenmehegan Owen Mehegan added a comment -

            This is broken again as of Jenkins 1.529. In a build on master where I do 'echo $NODE_NAME' I get:

            Building on master in workspace /home/us/jenkins/jenkins-data/jobs/matrix_test/workspace/label/lenny_32bit
            [lenny_32bit] $ /bin/sh -xe /tmp/hudson4009189070701021604.sh
            + echo

            Finished: SUCCESS

            On a slave I get the slave's label. This is breaking some builds where I gate stuff on master.

            Show
            owenmehegan Owen Mehegan added a comment - This is broken again as of Jenkins 1.529. In a build on master where I do 'echo $NODE_NAME' I get: Building on master in workspace /home/us/jenkins/jenkins-data/jobs/matrix_test/workspace/label/lenny_32bit [lenny_32bit] $ /bin/sh -xe /tmp/hudson4009189070701021604.sh + echo Finished: SUCCESS On a slave I get the slave's label. This is breaking some builds where I gate stuff on master.
            Hide
            slide_o_mix Alex Earl added a comment -

            I am seeing this issue again as well. I'll see what I can do to dig up the reason.

            Show
            slide_o_mix Alex Earl added a comment - I am seeing this issue again as well. I'll see what I can do to dig up the reason.
            Hide
            slide_o_mix Alex Earl added a comment -

            Seems like it was probably something in 9b74a88 that caused the issue

            Show
            slide_o_mix Alex Earl added a comment - Seems like it was probably something in 9b74a88 that caused the issue
            Hide
            bruce Dirk Kuypers added a comment -

            Ok, I am back from almost no internet holidays and as I don't understand how to interpret Alex' 9b74a88 (and as I do not know if my personal response email reached him) I will write a small comment here: I think the problem was introduced with 1.527, at least since then I am stuck with 1.526. I opened JENKINS-19222 describing my problems. From the changelog of 1.527 I guess the cause could be JENKINS-19042.

            Show
            bruce Dirk Kuypers added a comment - Ok, I am back from almost no internet holidays and as I don't understand how to interpret Alex' 9b74a88 (and as I do not know if my personal response email reached him) I will write a small comment here: I think the problem was introduced with 1.527, at least since then I am stuck with 1.526. I opened JENKINS-19222 describing my problems. From the changelog of 1.527 I guess the cause could be JENKINS-19042 .
            Hide
            slide_o_mix Alex Earl added a comment -

            @Dirk, the value I posted is the commit ID in Git that I think possibly caused the issue.

            Show
            slide_o_mix Alex Earl added a comment - @Dirk, the value I posted is the commit ID in Git that I think possibly caused the issue.
            Hide
            danielbeck Daniel Beck added a comment -

            Resolving this as fixed again. Whatever goes on with 1.52x+ is a different issue with the same symptoms – it doesn't happen on a pristine instance – and seems better tracked as JENKINS-19222.

            Show
            danielbeck Daniel Beck added a comment - Resolving this as fixed again. Whatever goes on with 1.52x+ is a different issue with the same symptoms – it doesn't happen on a pristine instance – and seems better tracked as JENKINS-19222 .

              People

              • Assignee:
                kohsuke Kohsuke Kawaguchi
                Reporter:
                slide_o_mix Alex Earl
              • Votes:
                1 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: