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

Launch command should include an env var for the name of the node

    • 1.3

      I'd like to be able to do:

      Launch command:

      start-agent $NODE_NAME 

      I know there are fancier ways to deal w/ launching nodes, but for now, it would be nice to be able to use the "copy node" and just give it another node whose template includes Launch method which can access a variable that corresponds to the node's name so that I don't have to do anything other than "OK".

      My first draft doesn't actually support that notation, instead:

      Launch command:

      script-to-start-agent-using-node-name-env-var

       Where that script does:

      exec start-agent $NODE_NAME

      There appear to be some things which interfere with $ and _ in the Launch command field. But, I think that exposing the variable is a good step forward.

          [JENKINS-54786] Launch command should include an env var for the name of the node

          Josh Soref created issue -

          Josh Soref added a comment -

          Josh Soref added a comment - https://github.com/jenkinsci/command-launcher-plugin/pull/6
          Josh Soref made changes -
          Assignee New: Josh Soref [ jsoref ]
          Josh Soref made changes -
          Description Original: I'd like to be able to do:

          {{Launch command}}:
          {code:java}
          start-agent $NODE_NAME {code}
          I know there are fancier ways to deal w/ launching nodes, but for now, it would be nice to be able to use the "copy node" and just give it another node whose template includes Launch method includes a variable so that I don't have to do anything other than "OK".
          New: I'd like to be able to do:

          {{Launch command}}:
          {code:java}
          start-agent $NODE_NAME {code}
          I know there are fancier ways to deal w/ launching nodes, but for now, it would be nice to be able to use the "copy node" and just give it another node whose template includes {{Launch method}} which can access a variable that corresponds to the node's name so that I don't have to do anything other than "OK".

          My first draft doesn't actually support that notation, instead:

          {{Launch command}}:
          {code:java}
          script-to-start-agent-using-node-name-env-var{code}
           Where that script does:
          {code:java}
          exec start-agent $NODE_NAME{code}
          There appear to be some things which interfere with {{$}} and {{_}} in the {{Launch command}} field. But, I think that exposing the variable is a good step forward.
          Jesse Glick made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Fixed but Unreleased [ 10203 ]
          Jesse Glick made changes -
          Issue Type Original: Bug [ 1 ] New: Improvement [ 4 ]

          Jesse Glick added a comment -

          There appear to be some things which interfere with $ and _ in the Launch command field.

          Because the launch command is tokenized by Jenkins and then exec’d as is—it does not run a Bourne shell. You can probably use something like

          sh -c "exec start-agent $NODE_NAME"
          

          (Note that Jenkins treats " as an indication to not tokenize the interior; it does not interpolate variables in any event. So this may look confusing.)

          Jesse Glick added a comment - There appear to be some things which interfere with $ and _ in the Launch command field. Because the launch command is tokenized by Jenkins and then exec’d as is—it does not run a Bourne shell. You can probably use something like sh -c "exec start-agent $NODE_NAME" (Note that Jenkins treats " as an indication to not tokenize the interior; it does not interpolate variables in any event. So this may look confusing.)
          Jesse Glick made changes -
          Released As New: 1.3
          Status Original: Fixed but Unreleased [ 10203 ] New: Resolved [ 5 ]
          Josh Phillips made changes -
          Assignee Original: Josh Soref [ jsoref ] New: Harold Jackson [ 19jacksonh ]

            19jacksonh Harold Jackson
            jsoref Josh Soref
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: