Simplify the pipeline script

This commit is contained in:
Ovidio Mallo 2016-12-06 10:10:10 +01:00
parent abb1d8350c
commit 9a3f154c96

View file

@ -1,26 +1,13 @@
def oc(args) {
sh getOcCmd(args)
}
def ocPipe(args1, args2) {
def ocCmd1 = getOcCmd(args1)
def ocCmd2 = getOcCmd(args2)
sh "${ocCmd1} | ${ocCmd2}"
}
def getOcCmd(args) {
def ocBin = "oc --token=`cat /var/run/secrets/kubernetes.io/serviceaccount/token` --server=https://openshift.default.svc.cluster.local --certificate-authority=/run/secrets/kubernetes.io/serviceaccount/ca.crt"
return "${ocBin} ${args}"
}
node() {
def ocCmd = "oc --token=`cat /var/run/secrets/kubernetes.io/serviceaccount/token` --server=https://openshift.default.svc.cluster.local --certificate-authority=/run/secrets/kubernetes.io/serviceaccount/ca.crt"
stage('Build') {
oc "start-build frontend -w -n rubex-dev"
sh "${ocCmd} start-build frontend -w -n rubex-dev"
}
stage('Deploy to DEV') {
oc "tag rubex-dev/frontend:latest rubex-dev/frontend:dev"
oc "deploy frontend --latest --follow -n rubex-dev"
sh "${ocCmd} tag rubex-dev/frontend:latest rubex-dev/frontend:dev"
sh "${ocCmd} deploy frontend --latest --follow -n rubex-dev"
}
def isPromoteToTest = false
@ -30,8 +17,8 @@ node() {
if (isPromoteToTest) {
stage('Deploy to TEST') {
oc "tag rubex-dev/frontend:dev rubex-dev/frontend:test"
oc "deploy frontend --latest --follow -n rubex-test"
sh "${ocCmd} tag rubex-dev/frontend:dev rubex-dev/frontend:test"
sh "${ocCmd} deploy frontend --latest --follow -n rubex-test"
}
}
}