Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
118 lines (115 sloc) 4.3 KB
apiVersion: v1
kind: Template
metadata:
name: openshift-django-pipeline
objects:
- apiVersion: v1
kind: BuildConfig
metadata:
name: djangopipeline
labels:
name: djangopipeline
annotations:
pipeline.alpha.openshift.io/uses: '[{"name": "openshift-django", "namespace": "", "kind": "DeploymentConfig"}]'
spec:
runPolicy: Serial
source:
type: None
strategy:
type: JenkinsPipeline
env:
jenkinsPipelineStrategy:
jenkinsfile: |-
def openshiftDjangoRepo="https://raw.githubusercontent.com/ruddra/openshift-django/master/.openshift/templates/openshift-django.yaml"
def stageTag="promoteToQA"
def DEV_PROJECT="dev"
def STAGE_PROJECT="stage"
pipeline{
agent { label ""}
stages{
stage('Create in DEV') {
when {
expression {
openshift.withCluster() {
openshift.withProject(DEV_PROJECT) {
echo "checking openshift django exists in DEV"
return !openshift.selector("bc", "openshift-django").exists();
}
}
}
}
steps {
script {
openshift.withCluster() {
openshift.withProject(DEV_PROJECT) {
openshift.newApp(openshiftDjangoRepo).narrow("svc").expose();
def dc = openshift.selector("dc", "openshift-django")
while (dc.object().spec.replicas != dc.object().status.availableReplicas) {
sleep 10
}
}
}
}
}
}
stage('Build and Test in DEV'){
steps {
script {
openshiftBuild(namespace: "${DEV_PROJECT}", buildConfig: "openshift-django", showBuildLogs: 'true', waitTime: "600000")
}
}
}
stage('Rollout to DEV') {
steps {
script {
openshiftDeploy(namespace: "${DEV_PROJECT}", deploymentConfig: "openshift-django", waitTime: "600000")
}
}
}
stage('Scale in DEV') {
steps {
script {
openshiftScale(namespace: "${DEV_PROJECT}", deploymentConfig: "openshift-django", replicaCount: '2')
}
}
}
stage('Promote to STAGE?') {
steps {
timeout(time:15, unit:'MINUTES') {
input message: "Promote to STAGE?", ok: "Promote"
}
script {
openshift.withCluster() {
openshift.tag("${DEV_PROJECT}/openshift-django:latest", "${STAGE_PROJECT}/openshift-django:${stageTag}")
}
}
}
}
stage('Rollout to STAGE') {
steps {
script {
openshift.withCluster() {
openshift.withProject(STAGE_PROJECT) {
if (openshift.selector('dc', 'openshift-django').exists()) {
openshift.selector('dc', 'openshift-django').delete()
openshift.selector('svc', 'openshift-django').delete()
openshift.selector('route', 'openshift-django').delete()
}
openshift.newApp("openshift-django:${stageTag}").narrow("svc").expose()
}
}
}
}
}
stage('Scale in STAGE') {
steps {
script {
openshiftScale(namespace: "${STAGE_PROJECT}", deploymentConfig: "openshift-django", replicaCount: '3')
}
}
}
}
}
output:
resources:
postCommit:
You can’t perform that action at this time.