1

Can an agent label make use of environment variable? Something like this:

pipeline {
    environment {
        SLAVE_NODE = 'MY_COMPUTER_NAME'
    }
    agent { label $SLAVE_NODE}
    ...

Since the editor for pipelines is so small, I would like to have the available space (visible by default) to be the "environment" block, so when I copy a jenkins job I just need to adjust a few environment variables used further in the script... I think I tried all the obvious syntax possibilities by now.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
ED8500
  • 41
  • 1
  • 9

1 Answers1

0

Stumbled upon it by try and error... (and found a duplicate here): Add a string parameter to your jenkins job (e.g. jenkinsNode) and use this in your script: agent { label "${jenkinsNode}" }

ED8500
  • 41
  • 1
  • 9