-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
116 lines (101 loc) · 4.3 KB
/
Jenkinsfile
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
110
111
112
113
114
115
116
jobID=''
jobID_instance_id=''
jobID_instance_status=''
pipeline {
agent any
environment {
MVN_HOME = '/Applications/apache-maven-3.6.1'
SAAGIE_CREDS = credentials('SaagieCreds')
SAAGIE_URL = 'https://saagie-workspace.prod.saagie.io'
}
stages {
stage('Clone Repo') {
steps {
git 'https://github.com/sgokaram-saagie/preprocesscustomer-aws-python-saagie.git'
}
}
stage('Build') {
steps{
sh 'zip -r -X preprocesscustomer.zip preprocess-customerdata-demo.py requirements.txt'
}
}
//Starting of Deploy Stage
stage('Deploy Job on Saagie Demo Environment') {
environment {
SAAGIE_PROJECT = 'cad415fc-a809-4f5a-919e-668dccb4a2de'
SAAGIE_PLATFORM = '4'
}
steps{
script{
sh "gradle projectCreateJob1 -b ./build.gradle.projectsCreateJob -Psaagieuserid=$SAAGIE_CREDS_USR -Psaagiepassword=$SAAGIE_CREDS_PSW -Psaagieplatformid=$SAAGIE_PLATFORM -Psaagieurl=$SAAGIE_URL -Psaagieprojectid=$SAAGIE_PROJECT -Psaagiejobid1_file='./job1_id' "
if (fileExists('./job1_id')) {
jobID = readFile('./job1_id')
println(jobID)
new File('./job1_id').delete()
} else {
return
}
}
}
}
//Starting of Test Stage
stage('Test Job on Saagie Demo Environment') {
environment {
SAAGIE_PROJECT = 'cad415fc-a809-4f5a-919e-668dccb4a2de'
SAAGIE_PLATFORM = '4'
}
steps{
script{
sh "gradle projectRunJob1 -b ./build.gradle.projectsCreateJob -Psaagieuserid=$SAAGIE_CREDS_USR -Psaagiepassword=$SAAGIE_CREDS_PSW -Psaagieplatformid=$SAAGIE_PLATFORM -Psaagieurl=$SAAGIE_URL -Psaagieprojectid=$SAAGIE_PROJECT -Psaagiejobid=${jobID} -Psaagiejobid1_instance_file='./job1_id_instance' "
if (fileExists('./job1_id_instance')){
jobID_instance_id = readFile('./job1_id_instance')
println(jobID_instance_id)
new File('./job1_id_instance').delete()
}
for (int i = 0; i < 10; i++) {
sh "gradle projectGetJobInstance1Status -b ./build.gradle.projectsCreateJob -Psaagieuserid=$SAAGIE_CREDS_USR -Psaagiepassword=$SAAGIE_CREDS_PSW -Psaagieplatformid=$SAAGIE_PLATFORM -Psaagieurl=$SAAGIE_URL -Psaagieprojectid=$SAAGIE_PROJECT -Psaagiejobinstanceid=${jobID_instance_id} -Psaagiejobid1_instancerun_file='./job1_id_instance_run' "
if(fileExists('./job1_id_instance_run')) {
jobID_instance_status = readFile('./job1_id_instance_run')
new File('./job1_id_instance_run').delete()
println("Job Status is $jobID_instance_status")
if (jobID_instance_status == 'QUEUED' || jobID_instance_status == 'RUNNING') {
println("Job Status is ${jobID_instance_status}. Sleeping for 30s")
sleep 5
}
else {
break;
}
}
}
if (jobID_instance_status != 'SUCCEEDED'){
return
}
}
}
}
//End of Test Stage
// Deploy to Production
stage('Deploy Job on Saagie Production Environment') {
input{
message "Do you want to proceed for production deployment?"
}
environment {
SAAGIE_PROJECT = 'bdbd16b2-9010-4fe4-b355-65af1c586c8f'
SAAGIE_PLATFORM = '4'
}
steps{
script{
sh "gradle projectCreateJob1 -b ./build.gradle.projectsCreateJob -Psaagieuserid=$SAAGIE_CREDS_USR -Psaagiepassword=$SAAGIE_CREDS_PSW -Psaagieplatformid=$SAAGIE_PLATFORM -Psaagieurl=$SAAGIE_URL -Psaagieprojectid=$SAAGIE_PROJECT -Psaagiejobid1_file='./job1_id' "
if (fileExists('./job1_id')) {
jobID = readFile('./job1_id')
println(jobID)
new File('./job1_id').delete()
} else {
return
}
}
}
}
// End Deploy to Production
}
}