This repository has been archived by the owner on Mar 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Jenkinsfile
191 lines (182 loc) · 7.28 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
pipeline {
agent { node { label 'zOS' } }
environment {
projectClean = 'true'
DBBClean = 'false'
projectDelete = 'false'
Debug = 'false'
CollectionName = 'Polycephaly'
libDir = 'lib'
classesDir = 'classes'
srcJavaZosFile = 'src/main/java/com/jenkins/zos/file'
srcJavaZosUtil = 'src/main/java/com/zos/java/utilities'
srcZosResbiuld = 'src/main/zOS/com.zos.resbuild'
srcGroovyZosLang = 'src/main/groovy/com/zos/language'
srcGrovoyZosUtil = 'src/main/groovy/com/zos/groovy/utilities'
srcGroovyPrgUtil = 'src/main/groovy/com/zos/program/utilities'
javaHome = '/usr/lpp/java/J8.0_64/bin'
groovyHome = '/opt/lpp/IBM/dbb/groovy-2.4.12/'
GROOVY_HOME = '/opt/lpp/IBM/dbb/groovy-2.4.12/'
groovyzHome = '/u/jerrye/bin'
DBB_HOME = '/opt/lpp/IBM/dbb'
DBB_CONF = "${WORKSPACE}/conf"
DBBLib = '/opt/lpp/IBM/dbb/lib/*'
ibmjzosJar = '/usr/lpp/java/J8.0_64/lib/ext/ibmjzos.jar'
DBBcoreJar = '/opt/lpp/IBM/dbb/lib/dbb.core_1.0.6.jar'
DBBhtmlJar = '/opt/lpp/IBM/dbb/lib/dbb.html_1.0.6.jar'
ibmjzos = '/usr/lpp/java/J8.0_64/lib/ext/ibmjzos.jar'
dbbJNI = '/opt/lpp/IBM/dbb/lib/libDBB_JNI64.so'
groovyJar = '/opt/lpp/IBM/dbb/groovy-2.4.12/lib/groovy-2.4.12.jar'
polycephalyJar = "${WORKSPACE}/${env.libDir}/polycephaly.jar"
javaClassPath = "${env.ibmjzos}:${env.DBBcoreJar}:${env.DBBhtmlJar}"
groovyClassPath = "${env.javaClassPath}:${env.polycephalyJar}"
groovyLibPath = "${env.DBBLib}:${env.dbbJNI}:${env.groovyClassPath}"
polyClassPath = "${env.polycephalyJar}:${env.ibmjzosJar}:${env.DBBLib}"
polyBuildGroovy = "$WORKSPACE/build/build.groovy"
polySrcPackage = "$WORKSPACE/conf/package.txt"
polyRuntime = "/u/jerrye/polyRuntime"
PolycephalyBuildDirectory = "$WORKSPACE/conf/"
PolycephalyBuildFile = "package.txt"
}
stages {
stage ('Start') {
steps {
// send to email
emailext (
subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'>
Check console output at;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]""",
recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)
}
}
stage('Clean workspace') {
when {
expression {
env.projectClean.toBoolean()
}
}
steps {
sh 'printf "running conditional clean of workspace"'
cleanWs()
}
}
stage("CheckOut") {
steps {
checkout scm
}
}
stage('Create Directories'){
steps {
sh "mkdir ${env.libDir}"
sh "mkdir ${env.classesDir}"
}
}
stage('Build zOS utilities') {
steps {
sh "${env.javaHome}/javac -d ${env.classesDir} ${env.srcJavaZosFile}/*.java"
sh "${env.javaHome}/javac -d ${env.classesDir} ${env.srcJavaZosUtil}/*.java"
sh "${env.javaHome}/javac -cp .:${env.javaClassPath} -d ${env.classesDir} ${env.srcZosResbiuld}/*.java"
}
}
stage('Create Java Jar file') {
steps {
sh "${env.javaHome}/jar cvf ${env.polycephalyJar} -C ${env.classesDir} . "
}
}
stage('Build Groovy zOS Utilities') {
steps {
sh "env"
sh "${env.groovyzHome}/groovyc -cp .:${env.groovyClassPath} -d ${env.classesDir} ${env.srcGrovoyZosUtil}/*.groovy"
}
}
stage('Add Groovy ZOS Utilities to JAR') {
steps {
sh "${env.javaHome}/jar uf ${env.polycephalyJar} -C ${env.classesDir} . "
}
}
stage('Build Groovy Language Utilities') {
steps {
sh "${env.groovyzHome}/groovyc -cp .:${env.groovyClassPath} -d ${env.classesDir} ${env.srcGroovyZosLang}/*.groovy"
}
}
stage('Add Groovy Language Utilities to JAR') {
steps {
sh "${env.javaHome}/jar uf ${env.polycephalyJar} -C ${env.classesDir} . "
}
}
stage('Build Groovy Program Utilities') {
steps {
sh "${env.groovyzHome}/groovyc -cp .:${env.groovyClassPath} -d ${env.classesDir} ${env.srcGroovyPrgUtil}/*.groovy"
}
}
stage('Add Groovy Program Utilities to JAR') {
steps {
sh "${env.javaHome}/jar uf ${env.polycephalyJar} -C ${env.classesDir} . "
sh "chmod 766 ${env.polycephalyJar}"
}
}
stage("Test-Debug") {
when {
expression { env.Debug.toBoolean()}
}
steps {
sh "export DBB_HOME=${env.DBB_HOME}"
sh "export DBB_CONF=${env.DBB_CONF}"
sh "export GROOVY_HOME=${env.GROOVY_HOME}"
sh "${env.groovyzHome}/groovy --classpath .:${env.groovyLibPath} ${env.polyBuildGroovy} --collection ${env.CollectionName} --debug --sourceDir ${env.polySrcPackage}"
}
}
stage("Test") {
when {
expression { !env.Debug.toBoolean()}
}
steps {
sh "export DBB_HOME=${env.DBB_HOME}"
sh "export DBB_CONF=${env.DBB_CONF}"
sh "export GROOVY_HOME=${env.GROOVY_HOME}"
sh "${env.groovyzHome}/groovy --classpath .:${env.groovyLibPath} ${env.polyBuildGroovy} --collection ${env.CollectionName} --sourceDir ${env.polySrcPackage}"
}
}
stage("Deploy") {
steps {
sh "cp -Rf ${env.polycephalyJar} ${env.polyRuntime}/${env.libDir}/"
sh "cp -Rf ${WORKSPACE}/conf/*.properties ${env.polyRuntime}/conf/"
sh "cp -Rf ${WORKSPACE}/conf/*.pw ${env.polyRuntime}/conf/"
sh "cp -Rf ${WORKSPACE}/conf/process_definitions.xml ${env.polyRuntime}/conf/"
}
}
stage('DBB clean collection') {
when {
expression {
env.DBBClean.toBoolean()
}
}
steps {
sh 'printf "running DBB delete collection"'
sh "export DBB_HOME=${env.DBB_HOME}"
sh "export DBB_CONF=${env.DBB_CONF}"
sh "export GROOVY_HOME=${env.GROOVY_HOME}"
sh "${env.groovyzHome}/groovy --classpath .:${env.polyClassPath} ${env.polyBuildGroovy} --clean --collection ${env.CollectionName}"
}
}
}
post {
success {
emailext (
attachLog: true, attachmentsPattern: '*.log',
subject: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}",
recipientProviders: [developers(), requestor()],
)
}
failure {
emailext (
attachLog: true, attachmentsPattern: '*.log',
body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}",
recipientProviders: [developers(), requestor()],
subject: "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}"
)
}
}
}