2019-04-11 19:42:18 +02:00
|
|
|
library('pipeline-library@feature/add-with-ecr')
|
|
|
|
|
|
|
|
pipeline {
|
|
|
|
options { timestamps() }
|
|
|
|
agent any
|
|
|
|
environment {
|
|
|
|
SERVICE = 'auto-semver'
|
|
|
|
GITHUB_KEY = 'autosemverDeployKey'
|
|
|
|
GITHUB_URL = 'https://github.com/RightBrain-Networks/auto-semver'
|
|
|
|
DOCKER_REGISTRY = '356438515751.dkr.ecr.us-east-1.amazonaws.com'
|
|
|
|
}
|
|
|
|
stages {
|
|
|
|
stage('Version') {
|
|
|
|
steps {
|
|
|
|
// runs the automatic semver tool which will version, & tag,
|
|
|
|
runAutoSemver()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Build') {
|
|
|
|
steps {
|
|
|
|
|
|
|
|
|
|
|
|
echo "Building ${env.SERVICE} docker image"
|
|
|
|
|
|
|
|
// Docker build flags are set via the getDockerBuildFlags() shared library.
|
|
|
|
sh "docker build ${getDockerBuildFlags()} -t ${env.DOCKER_REGISTRY}/${env.SERVICE}:${getVersion('-d')} ."
|
|
|
|
|
|
|
|
//sh "tar -czvf ${env.SERVICE}-${getVersion('-d')}.tar.gz deployer"
|
|
|
|
}
|
|
|
|
post{
|
|
|
|
// Update Git with status of build stage.
|
|
|
|
success {
|
|
|
|
updateGithubCommitStatus(GITHUB_URL, 'Passed build stage', 'SUCCESS', 'Build')
|
|
|
|
}
|
|
|
|
failure {
|
|
|
|
updateGithubCommitStatus(GITHUB_URL, 'Failed build stage', 'FAILURE', 'Build')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Push')
|
|
|
|
{
|
|
|
|
steps {
|
|
|
|
withEcr {
|
|
|
|
sh "docker push ${env.DOCKER_REGISTRY}/${env.SERVICE}:${getVersion('-d')}"
|
|
|
|
}
|
|
|
|
|
|
|
|
//Copy tar.gz file to s3 bucket
|
|
|
|
//sh "aws s3 cp ${env.SERVICE}-${getVersion('-d')}.tar.gz s3://rbn-ops-pkg-us-east-1/${env.SERVICE}/${env.SERVICE}-${getVersion('-d')}.tar.gz"
|
|
|
|
|
|
|
|
}
|
2019-04-11 19:45:34 +02:00
|
|
|
post
|
|
|
|
{
|
2019-04-11 19:42:18 +02:00
|
|
|
// Update Git with status of push stage.
|
|
|
|
success {
|
2019-04-11 19:45:34 +02:00
|
|
|
updateGithubCommitStatus(GITHUB_URL, 'Passed push stage', 'SUCCESS', 'Push')
|
2019-04-11 19:42:18 +02:00
|
|
|
}
|
|
|
|
failure {
|
2019-04-11 19:45:34 +02:00
|
|
|
updateGithubCommitStatus(GITHUB_URL, 'Failed push stage', 'FAILURE', 'Push')
|
2019-04-11 19:42:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-11 19:45:34 +02:00
|
|
|
post {
|
|
|
|
always {
|
|
|
|
removeDockerImages()
|
|
|
|
cleanWs()
|
|
|
|
}
|
|
|
|
}
|
2019-04-11 19:47:15 +02:00
|
|
|
}
|
2019-04-11 19:42:18 +02:00
|
|
|
}
|