forked from shobarani15/devops-jan-22
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjenkins.txt
80 lines (57 loc) · 1.98 KB
/
jenkins.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Jenkins pipeline
- This is type of job we got in jenkins where all the configuration of the job
is done through code.
- Groovy is the language used to write pipeline jobs in jenkins.
- The main pipeline is writen in a file called Jenkinsfile.
Types of jenksin pipeline jobs
scripted pipeline
- Old way of defining jenkins pipeline job.
- All the code /configuration is writen inside node block
node {
}
Declarative pipeline
- New way of defining jenkins pipeline job.
- All the code /configuration is writen inside pipeline block
pipeline {
}
How to define a pipeline job ?
1. - We can directly write the pipeline script inside the job using inline script block.
- It is difficult to main the versioning of job.
2. we write the script in a file called Jenkinsfile and we source it from a SCM (Source code management).
Declarative pipeline
The required block are AGENT, STAGES - STAGE, STEPS - STEPS
pipeline {
agent any
stages {
stage('Build') {
steps {
}
}
stage('Test'){
steps {
}
}
stage('Deploy'){
steps {
}
}
stage('My-stage'){
steps {
}
}
}
}
AGENT
- An agent is used to define the execution scope of the stage.
- AGENT is used to distribute the workload of different stages.
- each stage will be assigned with a executor based on agent configuration.
Types of agent
any - Runs pipeline agents on any available executors.
none - If we define agent as none at the pipeline level, it means we need to
define agent at the stage level.
- If we want to control the execution of each stage we need to use agent
as none at pipeline level and we can define agent for each stage.
IQ - How to run a particular stage on a node ?
label - Both at agent and pipeline level we can use this type of agent.
docker -
Note: Install blueocen plugin dashborad for pipeline jobs