-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6fd398
commit 0266b16
Showing
1 changed file
with
3 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |