DenCowboy
DenCowboy

Reputation: 15136

When do you need node inside a stage in Jenkins Pipeline

What is the difference between the following two? When do you have to use the node part and when not?

stage ("stage") {
    node ("NodeName"){
        xxx
    }
}

vs

stage ("stage") {
  xxx
}

I'm defining agent any in the beginning of my pipeline.

Upvotes: 3

Views: 1358

Answers (1)

mkobit
mkobit

Reputation: 47319

node allocates an executor to run steps on. If a step implementation requires a FilePath as part of it's execution context,it will fail if it is not in a node body. Some step implementations require that context, some don't:

A few examples of steps requiring a FilePath would be:

A few that don't:

Some plugin steps will not be clear if they require an executor or not, so it can just be easiest to try it out.

Upvotes: 1

Related Questions