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

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

    XMLWordPrintable

Details

    • 1.3

    Description

      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.

      Attachments

        Activity

          jsoref Josh Soref added a comment - https://github.com/jenkinsci/command-launcher-plugin/pull/6
          jglick 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.)

          jglick 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.)

          People

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

            Dates

              Created:
              Updated:
              Resolved: