1
votes

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.

1
Stumbled upon it by accident... and found a duplicate here:ED8500

1 Answers

0
votes

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}" }