-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathassign pipe10
More file actions
83 lines (68 loc) · 2.26 KB
/
assign pipe10
File metadata and controls
83 lines (68 loc) · 2.26 KB
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
81
82
83
pipeline {
agent none
options {
timestamps()
}
environment {
name='sushmitha'
}
parameters {
string (defaultValue: 'sushmitha', description: 'Enter the username value', name: 'user_name')
choice (name: 'env', choices: ['dev', 'qa', 'prod'],description: 'choose any one')
booleanParam(defaultValue: true, name: 'my_boolean')
}
triggers {
// Periodically trigger every 12 hours
cron('H H/12 * * *')
// Poll SCM every 15 minutes for changes
pollSCM('H/15 * * * *')
}
stages {
stage('Stage-1') {
agent { label 'java'}
when{
anyOf{
branch 'main'
branch 'dev1'
}
}
steps {
sh 'touch tomcat'
echo "this stage is executing by ${params.user_name}"
echo 'Using Secret Text and Username/Password credentials'
}
}
stage('Stage-2') {
agent { label 'java'}
steps {
sh 'touch master'
echo "executing in ${params.dev}"
echo "my boolean value=${params.my_boolean}"
echo "Executing Stage 2"
// Simulate success; this stage should succeed for Stage 3 to run
}
}
stage('Stage-3') {
agent { label 'Agent-2'}
when {
expression { currentBuild.result == null || currentBuild.result == 'SUCCESS' }
}
steps {
sh 'touch tomcat'
echo "echo "Job ${env.JOB_NAME} is running on ${env.JENKINS_URL} and having build no: ${env.BUILD_ID}"" //global variable directly we can reference them
echo "Name is: ${name}" /top levl variable,we need to define
echo " echo 'Executing Stage 3 on agent3 (only on master or dev branch after Stage 2 success)'"
}
}
stage('Stage-4') {
agent { label 'Agent-2'}
when {
// This stage will run only if Stage 3 was successful
expression { currentBuild.result == null || currentBuild.result == 'SUCCESS' }
steps {
echo "executing stage4"
}
}
}
}
}