Some cleanup
This commit is contained in:
parent
d4f404ea70
commit
470201c159
2 changed files with 9 additions and 9 deletions
|
@ -2,10 +2,10 @@ def getOcCmd() {
|
||||||
return "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 "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"
|
||||||
}
|
}
|
||||||
|
|
||||||
def getReplicasOpt(deploymentConfig, project) {
|
def getReplicasOrDefault(deploymentConfig, project, defaultReplicas) {
|
||||||
def ocCmd = getOcCmd()
|
def ocCmd = getOcCmd()
|
||||||
def replicas = sh(script: "${ocCmd} get dc ${deploymentConfig} --template='{{ .spec.replicas }}' -n ${project} || true", returnStdout: true).trim()
|
def replicas = sh(script: "${ocCmd} get dc ${deploymentConfig} --template='{{ .spec.replicas }}' -n ${project} || true", returnStdout: true).trim()
|
||||||
return replicas ? "-v REPLICAS=${replicas}" : ""
|
return replicas ?: defaultReplicas
|
||||||
}
|
}
|
||||||
|
|
||||||
node() {
|
node() {
|
||||||
|
@ -21,8 +21,8 @@ node() {
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Deploy to DEV') {
|
stage('Deploy to DEV') {
|
||||||
def replicasOpt = getReplicasOpt("frontend", "rubex-dev")
|
def replicas = getReplicasOrDefault("frontend", "rubex-dev", 1)
|
||||||
sh "${ocCmd} process -f ${appManifest} -v ENV=dev ${replicasOpt} -n rubex-dev | ${ocCmd} apply -f - -n rubex-dev"
|
sh "${ocCmd} process -f ${appManifest} -v ENV=dev,REPLICAS=${replicas} -n rubex-dev | ${ocCmd} apply -f - -n rubex-dev"
|
||||||
sh "${ocCmd} tag rubex-dev/frontend:latest rubex-dev/frontend:dev"
|
sh "${ocCmd} tag rubex-dev/frontend:latest rubex-dev/frontend:dev"
|
||||||
sh "${ocCmd} rollout latest dc/frontend -n rubex-dev"
|
sh "${ocCmd} rollout latest dc/frontend -n rubex-dev"
|
||||||
sh "${ocCmd} rollout status dc/frontend -n rubex-dev"
|
sh "${ocCmd} rollout status dc/frontend -n rubex-dev"
|
||||||
|
@ -35,8 +35,8 @@ node() {
|
||||||
|
|
||||||
if (isPromoteToTest) {
|
if (isPromoteToTest) {
|
||||||
stage('Deploy to TEST') {
|
stage('Deploy to TEST') {
|
||||||
def replicasOpt = getReplicasOpt("frontend", "rubex-test")
|
def replicas = getReplicasOrDefault("frontend", "rubex-test", 2)
|
||||||
sh "${ocCmd} process -f ${appManifest} -v ENV=test ${replicasOpt} -n rubex-test | ${ocCmd} apply -f - -n rubex-test"
|
sh "${ocCmd} process -f ${appManifest} -v ENV=test,REPLICAS=${replicas} -n rubex-test | ${ocCmd} apply -f - -n rubex-test"
|
||||||
sh "${ocCmd} tag rubex-dev/frontend:dev rubex-dev/frontend:test"
|
sh "${ocCmd} tag rubex-dev/frontend:dev rubex-dev/frontend:test"
|
||||||
sh "${ocCmd} rollout latest dc/frontend -n rubex-test"
|
sh "${ocCmd} rollout latest dc/frontend -n rubex-test"
|
||||||
sh "${ocCmd} rollout status dc/frontend -n rubex-test"
|
sh "${ocCmd} rollout status dc/frontend -n rubex-test"
|
||||||
|
|
|
@ -35,8 +35,8 @@ oc tag rubex-dev/frontend:latest rubex-dev/frontend:test
|
||||||
oc login -u admin -p admin
|
oc login -u admin -p admin
|
||||||
|
|
||||||
oc new-project cicd
|
oc new-project cicd
|
||||||
oc policy add-role-to-user edit system:serviceaccount:cicd:default -n rubex-dev
|
oc policy add-role-to-user edit system:serviceaccount:cicd:jenkins -n rubex-dev
|
||||||
oc policy add-role-to-user edit system:serviceaccount:cicd:default -n rubex-test
|
oc policy add-role-to-user edit system:serviceaccount:cicd:jenkins -n rubex-test
|
||||||
|
|
||||||
oc new-app --name=ci omallo/oc-jenkins
|
oc new-app --name=jenkins omallo/oc-jenkins
|
||||||
oc expose svc ci --hostname ci.oc.habitz-app.com
|
oc expose svc ci --hostname ci.oc.habitz-app.com
|
||||||
|
|
Loading…
Reference in a new issue