-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathques7
More file actions
109 lines (82 loc) · 2.61 KB
/
ques7
File metadata and controls
109 lines (82 loc) · 2.61 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
pipeline {
agent none
parameters {
string defaultValue: 'Jenkins', name: 'env_var1'
choice choices: ['Dev', 'Test', 'Prod'], name: 'env_var2'
booleanParam defaultValue: true, name: 'env_var3'
}
triggers{
cron '30 * * * *'
pollSCM '30 * * * *'
}
environment {
AWS_ACCESS_KEY=credentials('aws_access_key')
GITHUB_CRED=credentials('github_new')
MY_STRING = "${params.env_var1}"
MY_CHOICE = "${params.env_var2}"
MY_BOOLEAN = "${params.env_var3}"
}
stages {
stage('checkout') {
agent{label 'java'}
when{
anyOf{
branch 'main'
branch 'dev1'
}
}
steps {
git branch: 'main', url: 'https://github.com/Veena-devops/java-example.git'
}
}
stage('Test') {
agent{label 'java'}
steps {
echo 'Running unit test and integration test'
echo "Environment Variable MY_STRING: ${MY_STRING}"
echo "Environment Variable MY_CHOICE: ${MY_CHOICE}"
echo "Environment Variable MY_BOOLEAN: ${MY_BOOLEAN}"
}
}
stage('Build') {
agent {label 'Agent-2'}
when {
expression {
(currentBuild.result == null || currentBuild.result == 'SUCCESS')
}
}
steps {
// Using Global Variables
echo "jobname : '$JOB_NAME'"
echo "build no: '$BUILD_NUMBER'"
echo "job URL: '$BUILD_URL'"
echo "Jenkins URL: '$JENKINS_URL'"
}
}
stage('Push') {
agent{label 'Agent-2'}
when {
expression {
(currentBuild.result == null || currentBuild.result == 'SUCCESS')
}
}
steps {
echo 'Pusing artifact to artifactory'
sh 'echo $AWS_ACCESS_KEY'
sh 'echo USERNAME:PASSWORD:: $GITHUB_CRED'
sh 'echo username: $GITHUB_CRED_USR'
sh 'echo password: $GITHUB_CRED_PSW'
}
}
}
post {
always {
emailext body: '''
jobname : '$JOB_NAME'
build no: '$BUILD_NUMBER'
job URL: '$BUILD_URL'
build status: '$BUILD_STATUS'
''', subject: '$JOB_NAME' , from: '[email protected]', to: '[email protected]'
}
}
}