I have a declarative pipeline where I’m trying to run Jenkinsfile script for all agents with a specific label.
I have added agent any in the beginning, but I also tried to add label into my agent at beginning of my script, as much as, inside of each stage, which it didn’t work. At the moment it just takes arbitrarily an agent and run the Jenkinsfile script against it.
My intention is to run the whole Jenkinsfile script against an agent, and go to the next till it finishes this loop for all agents.
Is that going to run the entirely script for all my nodes/agents sequentially?
I actually don’t need to run them in parallel, but rather sequentially.
Also, I was not able to find too much documentation on scripted pipeline, mostly about declarative pipelines. If you know some page please post it here.
Thank you very much for your help. Much appreciated!
No. That will run a single stage on one of the nodes that has the label mylabel. If you want to run on multiple nodes, you’ll either need to use matrix in declarative as described by @halkeye or you’ll need to declare multiple stages, whether sequential or parallel.
If you’re running a current version of declarative Pipeline, you already have the matrix step in your Jenkins installation. No additional plugins are needed.
The Declarative directive generator on your Jenkins installation at /directive-generator/ will guide you to define the matrix directive.
It is good to know about that. I will try it out, thank you!
As you can see I’m not much experienced on Jenkins.
What is the best approach to run my entire Jenkinsfile for each agent that has a specific label sequentially? Declarative or Scripted pipelines? Or, both can do the job just fine?