It would be useful and natural to be able to use env.NODE_NAME inside a node.

      Currently. the following code results in null:

      node('myNode') { echo "My name is ${env.NODE_NAME}" }
      

      Perhaps ExecutorStepExecution should define NODE_NAME for use by steps inside node.

          [JENKINS-28131] Pass NODE_NAME into node{}

          Anshu Arya created issue -

          Jesse Glick added a comment -

          Yes, JENKINS-27145 discusses a few variables which you would reasonably expect to be there but which for technical reasons are not (because they are normally implemented in AbstractProject/AbstractBuild).

          Jesse Glick added a comment - Yes, JENKINS-27145 discusses a few variables which you would reasonably expect to be there but which for technical reasons are not (because they are normally implemented in AbstractProject / AbstractBuild ).
          Jesse Glick made changes -
          Link New: This issue is blocking JENKINS-27145 [ JENKINS-27145 ]
          Jesse Glick made changes -
          Link New: This issue is related to JENKINS-28182 [ JENKINS-28182 ]

          A C added a comment -

          Workaround in Windows, use ${env.COMPUTERNAME} - not perfect, but close enough for most purposes.

          A C added a comment - Workaround in Windows, use ${env.COMPUTERNAME} - not perfect, but close enough for most purposes.
          Jesse Glick made changes -
          Description Original: It would be useful and natural to be able to use env.NODE_NAME inside a node{}.

          Currently. the following code results in null: node('myNode') { echo "My name is ${env.NODE_NAME}" }

          Perhaps ExecutorStepExecution should define NODE_NAME for use by steps inside node {}.
          New: It would be useful and natural to be able to use {{env.NODE_NAME}} inside a {{node}}.

          Currently. the following code results in null:

          {code}
          node('myNode') { echo "My name is ${env.NODE_NAME}" }
          {code}

          Perhaps {{ExecutorStepExecution}} should define {{NODE_NAME}} for use by steps inside {{node}}.

          Manuel Recena Soto added a comment - - edited

          There is an opened PR.

          Output result:

          Running: Allocate node : Start
          Running on test in /Users/recena/temp/jenkins-node/workspace/CJE-2418
          Running: Allocate node : Body : Start
          Running: Print Message
          My name is test
          Running: Allocate node : Body : End
          Running: Allocate node : End
          Running: End of Workflow
          Finished: SUCCESS
          

          Manuel Recena Soto added a comment - - edited There is an opened PR . Output result: Running: Allocate node : Start Running on test in /Users/recena/temp/jenkins-node/workspace/CJE-2418 Running: Allocate node : Body : Start Running: Print Message My name is test Running: Allocate node : Body : End Running: Allocate node : End Running: End of Workflow Finished: SUCCESS
          Manuel Recena Soto made changes -
          Assignee Original: Jesse Glick [ jglick ] New: Manuel Recena Soto [ recena ]
          Manuel Recena Soto made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Jesse Glick made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Progress [ 3 ] New: Resolved [ 5 ]

            recena Manuel Recena Soto
            anshuarya Anshu Arya
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: