Skip to content

Commit

Permalink
👷 Added new jenkinsfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Lubneuski authored and dankolbman committed Jun 22, 2018
1 parent c6fd398 commit 0266b16
Showing 1 changed file with 3 additions and 199 deletions.
202 changes: 3 additions & 199 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,200 +1,4 @@
#!groovy
properties([
pipelineTriggers([[$class:"GitHubPushTrigger"]])
])
pipeline {
agent { label 'docker-slave' }
stages{
stage('Get Code') {
steps {
deleteDir()
checkout ([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
extensions: [[$class: 'CloneOption', noTags: false, shallow: false, depth: 0, reference: '']],
userRemoteConfigs: scm.userRemoteConfigs,
])
script {
tag=sh(returnStdout: true, script: "git tag -l --points-at HEAD").trim()
env.tag = tag
}
}
}
stage('GetOpsScripts') {
steps {
slackSend (color: '#ddaa00', message: ":construction_worker: GETTING SCRIPTS:")
sh '''
git clone [email protected]:kids-first/kf-api-dataservice-config.git
'''
}
}
stage('Test') {
steps {
slackSend (color: '#ddaa00', message: ":construction_worker: TESTING STARTED: (${env.BUILD_URL})")
sh '''
kf-api-dataservice-config/ci-scripts/test_stage/test.sh
'''
slackSend (color: '#41aa58', message: ":white_check_mark: TESTING COMPLETED: (${env.BUILD_URL})")
}
post {
failure {
slackSend (color: '#ff0000', message: ":frowning: Test Failed: Branch '${env.BRANCH_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
}
}
stage('Build') {
steps {
sh '''
kf-api-dataservice-config/ci-scripts/build_stage/build.sh
'''
}
}
stage('Publish') {
steps {
sh '''
kf-api-dataservice-config/ci-scripts/publish_stage/publish.sh
'''
slackSend (color: '#41aa58', message: ":arrow_up: PUSHED IMAGE: (${env.BUILD_URL})")
}
post {
failure {
slackSend (color: '#ff0000', message: ":frowning: Publish Failed: Branch '${env.BRANCH_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
}
}
stage('Deploy Dev') {
steps {
slackSend (color: '#005e99', message: ":deploying_dev: DEPLOYING TO DEVELOPMENT: (${env.BUILD_URL})")
sh '''
kf-api-dataservice-config/ci-scripts/deploy_stage/deploy.sh dev
'''
slackSend (color: '#41aa58', message: ":white_check_mark: DEPLOYED TO DEVELOPMENT: (${env.BUILD_URL})")
}
post {
failure {
slackSend (color: '#ff0000', message: ":frowning: Test Failed: Branch '${env.BRANCH_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
}
}
stage('Retag with pre-release'){
when {
expression {
return env.BRANCH_NAME == 'master';
}
expression {
return tag != '';
}
}
steps {
slackSend (color: '#005e99', message: ":deploying_qa: Retagging image with 'pre-release'")
sh '''
MANIFEST=$(aws ecr batch-get-image --region us-east-1 --repository-name kf-api-dataservice --image-ids imageTag=latest --query images[].imageManifest --output text)
aws ecr put-image --region us-east-1 --repository-name kf-api-dataservice --image-tag "prerelease-$tag" --image-manifest "$MANIFEST"
'''
}
}
stage('Deploy QA') {
when {
expression {
return env.BRANCH_NAME == 'master';
}
}
steps {
slackSend (color: '#005e99', message: ":deploying_qa: DEPLOYING TO QA: (${env.BUILD_URL})")
sh '''
kf-api-dataservice-config/ci-scripts/deploy_stage/deploy.sh qa
'''
slackSend (color: '#41aa58', message: ":white_check_mark: DEPLOYED TO QA: (${env.BUILD_URL})")
}
}
stage("Promotion dataservice-api to PRD") {
when {
expression {
return env.BRANCH_NAME == 'master';
}
expression {
return tag != '';
}
}
steps {
script {
env.DEPLOY_TO_PRD = input message: 'User input required',
submitter: 'lubneuskia,heatha',
parameters: [choice(name: 'dataservice-api: Deploy to PRD Environment', choices: 'no\nyes', description: 'Choose "yes" if you want to deploy the PRD server')]
}
}
}
stage('Retag with release'){
when {
environment name: 'DEPLOY_TO_PRD', value: 'yes'
expression {
return env.BRANCH_NAME == 'master';
}
expression {
return tag != '';
}
}
steps {
slackSend (color: '#005e99', message: ":deploying_qa: Retagging image with 'release'")
sh '''
MANIFEST=$(aws ecr batch-get-image --region us-east-1 --repository-name kf-api-dataservice --image-ids imageTag="prerelease-$tag" --query images[].imageManifest --output text)
aws ecr put-image --region us-east-1 --repository-name kf-api-dataservice --image-tag "$tag" --image-manifest "$MANIFEST"
'''
}
}
stage('Deploy PRD') {
when {
environment name: 'DEPLOY_TO_PRD', value: 'yes'
expression {
return env.BRANCH_NAME == 'master';
}
expression {
return tag != '';
}
}
steps {
slackSend (color: '#005e99', message: ":deploying_prd: DEPLOYING TO PRD: (${env.BUILD_URL})")
sh '''
kf-api-dataservice-config/ci-scripts/deploy_stage/deploy.sh prd
'''
slackSend (color: '#41aa58', message: ":white_check_mark: DEPLOYED TO PRD: (${env.BUILD_URL})")
}
}
stage("Rollback dataservice-api ?") {
when {
expression {
return env.BRANCH_NAME == 'master';
}
expression {
return tag != '';
}
}
steps {
script {
env.ROLL_BACK = input message: 'User input required',
submitter: 'lubneuskia,heatha',
parameters: [choice(name: 'dataservice-api: Deploy to PRD Environment', choices: 'no\nyes', description: 'Choose "yes" if you want to deploy the PRD server')]
}
}
}
stage('Rollback PRD') {
when {
environment name: 'ROLL_BACK', value: 'yes'
expression {
return env.BRANCH_NAME == 'master';
}
expression {
return tag != '';
}
}
steps {
slackSend (color: '#005e99', message: ":deploying_prd: DEPLOYING TO PRD: (${env.BUILD_URL})")
sh '''
kf-api-dataservice-config/ci-scripts/rollback/rollback.sh prd
'''
slackSend (color: '#41aa58', message: ":white_check_mark: DEPLOYED TO PRD: (${env.BUILD_URL})")
}
}
}
@Library(value='kids-first/aws-infra-jenkins-shared-libraries', changelog=false) _
ecs_service_type_1 {
projectName = "kf-api-dataservice"
}

0 comments on commit 0266b16

Please sign in to comment.