forked from sudheer76R/java-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
82 lines (76 loc) · 2.03 KB
/
Jenkinsfile
File metadata and controls
82 lines (76 loc) · 2.03 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
pipeline{
agent none
triggers {
cron '* * * * *'
pollSCM 'H/15 * * * *'
}
environment{
AWS_ACCESS_KEY=credentials('aws_access_key')
GITHUB_CRED=credentials('github_cred')
STRING='${params.evar1}'
CHOICE='${params.evar2}'
BOOLEAN='${params.evar3}'
}
parameters{
string(name:'evar1',defaultValue:'jenkins-user',description:'enter your ID')
choice (choices: ['DEV','QA','PROD'],description: 'choose among the choices', name:'evar2')
booleanParam(defaultValue: true, name: 'evar3')
}
stages{
stage('checkout'){
agent {label 'master'}
when{
anyOf{
branch 'main'
branch 'dev'
}
}
steps{
git branch: 'main', url: 'https://github.com/BinduPrivate/java-example.git'
echo 'Hello!!this is user: $STRING'
echo 'checking from the environment: $CHOICE'
echo 'my boolean value is:$BOOLEAN'
}
}
stage('Test'){
agent {label 'java'}
steps{
echo 'Running job ${env.JOB_NAME} on build_id ${env.BUILD_ID} on machine ${env.JENKINS_URL} and build triggered by ${env.USER}'
}
}
stage('Build'){
agent {label 'master'}
when{
expression { currentBuild.result == null || currentBuild.result == 'SUCCESS' }
}
steps{
echo 'bulding artifacts'
echo 'my aws access key is:: $AWS_ACCESS_KEY'
}
}
stage('Deploy'){
agent {label 'java'}
when{
expression { currentBuild.result == null || currentBuild.result == 'SUCCESS' }
}
steps{
echo 'deploying artifacts to environment'
echo 'my github username and password is :: $GITHUB_CRED'
}
}
}
post {
success {
script {
emailext(
subject: "Build Success: ${env.JOB_NAME} #${env.BUILD_NUMBER}",
body: """Build Successful
Job: ${env.JOB_NAME}
Build #: ${env.BUILD_NUMBER}
Job URL: "${env.BUILD_URL}""",
to: '[email protected]'
)
}
}
}
}