forked from saikiran-private/java-example
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAssi7Jenk
More file actions
83 lines (79 loc) · 1.93 KB
/
Assi7Jenk
File metadata and controls
83 lines (79 loc) · 1.93 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{label 'master'}
parameters {
string defaultValue: 'Hari', name: 'var1'
choice choices: ['Dev', 'Test', 'Prod'], description: 'Select a Choice Parameter', name: 'var2'
booleanParam defaultValue: true, name: 'var3'
}
triggers{
cron 'H * * * *'
pollSCM 'H * * * *'
}
environment {
AWS_ACCESS_KEY=credentials('aws_access_key')
GITHUB_CRED=credentials('Lavi')
SSH_CRED=credentials('ssh_key')
My_String="${params.var1}"
My_Choice="${params.var2}"
My_Boolean="${params.var3}"
}
stages {
stage('checkout') {
when{
anyOf{
branch 'main'
branch 'Dev'
}
}
steps {
git branch: 'main', url: 'https://github.com/HariGangaiah/java-example.git'
echo "Checking the trigger"
}
}
stage('Test') {
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 and Global Variables') {
when {
expression {
(currentBuild.result == null || currentBuild.result == 'SUCCESS')
}
}
steps {
echo "jobname:: '$JOB_NAME'"
echo "build no:: '$BUILD_NUMBER'"
echo "job URL:: '$BUILD_URL'"
echo "Jenkins URL:: '$JENKINS_URL'"
}
}
stage('Push') {
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]'
}
}
}