24

I am trying to use jenkins. But when I reading the Declarative Pipeline Syntax, I confused by the agent term

  1. What does the agent stand for?
  2. Is that mean I can set the pipeline runtime folder path?
  3. How to create an agent?
  4. How set a label for agent?
Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
Rhysol
  • 481
  • 1
  • 3
  • 12

2 Answers2

22

I can feel you :-D. Here are the answers:

  1. The agent section specifies where the entire Pipeline, or a specific stage, will execute in the Jenkins environment depending on where the agent section is placed. The section must be defined at the top-level inside the pipeline block, but stage-level usage is optional. - Content copied from the agent section

  2. NO, this has nothing to do with the pipeline runtime folder path.

  3. You can for example Create an agent/node by the following tutorial: How to Setup Jenkins Agent/Slave Using Password and ssh Keys. - But there are many other ways to create an agent e.g. using a Docker-Container (...).

  4. You can Set a label under the Configuration of the Node. You can use a label in your pipeline like:

     pipeline {
     agent { label 'labelName' }
     (...)
     }
    
Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
adbo
  • 767
  • 1
  • 8
  • 23
2

While @adbo covered questions asked, Jenkins glossary describes agent really well:

typically a machine, or container, which connects to a Jenkins controller and executes tasks when directed by the controller.

You can choose to run entire pipeline on any available agent (agent any at the top of the pipeline) or run a specific stage on the agent of choice e.g. run build stage in a specific environ by overriding agent in that stage:

agent { docker { image 'my image' } }

Amit
  • 677
  • 8
  • 15