auto-semver/Jenkinsfile

94 lines
2.8 KiB
Plaintext
Raw Normal View History

2019-07-16 20:38:46 +02:00
library('pipeline-library')
2019-04-11 19:42:18 +02:00
pipeline {
options { timestamps() }
agent any
environment {
SERVICE = 'auto-semver'
2019-11-25 20:34:30 +01:00
GITHUB_KEY = 'rbn-ops github'
GITHUB_URL = 'git@github.com:RightBrain-Networks/auto-semver.git'
2019-04-11 19:42:18 +02:00
DOCKER_REGISTRY = '356438515751.dkr.ecr.us-east-1.amazonaws.com'
2019-04-11 20:59:37 +02:00
//Image tag to use for self-versioning
2019-11-25 17:59:01 +01:00
SELF_SEMVER_TAG = "develop"
2019-04-11 20:59:37 +02:00
2019-04-11 19:42:18 +02:00
}
stages {
2019-04-11 20:59:37 +02:00
//Runs versioning in docker container
2019-11-22 21:37:53 +01:00
stage('Self Version') {
2019-04-11 19:42:18 +02:00
steps {
2019-11-22 22:58:18 +01:00
runAutoSemver("${DOCKER_REGISTRY}/auto-semver:${SELF_SEMVER_TAG}")
2019-04-11 19:42:18 +02:00
}
2019-04-11 20:59:37 +02:00
post{
// Update Git with status of version stage.
success {
updateGithubCommitStatus(GITHUB_URL, 'Passed version stage', 'SUCCESS', 'Version')
}
failure {
updateGithubCommitStatus(GITHUB_URL, 'Failed version stage', 'FAILURE', 'Version')
}
}
2019-04-11 19:42:18 +02:00
}
stage('Build') {
steps {
echo "Building ${env.SERVICE} docker image"
// Docker build flags are set via the getDockerBuildFlags() shared library.
2019-04-11 20:44:16 +02:00
sh "docker build ${getDockerBuildFlags()} -t ${env.DOCKER_REGISTRY}/${env.SERVICE}:${env.VERSION} ."
2019-04-11 19:42:18 +02:00
2019-08-05 19:15:52 +02:00
sh "python setup.py sdist"
2019-04-11 19:42:18 +02:00
}
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 {
2019-04-11 20:59:37 +02:00
sh "docker push ${env.DOCKER_REGISTRY}/${env.SERVICE}:${env.VERSION}"
2019-07-18 22:30:03 +02:00
script
{
if("${env.BRANCH_NAME}" == "develop")
2019-07-18 22:30:03 +02:00
{
2019-07-18 22:41:23 +02:00
sh "docker tag ${env.DOCKER_REGISTRY}/${env.SERVICE}:${env.VERSION} ${env.DOCKER_REGISTRY}/${env.SERVICE}:latest"
2019-07-18 22:30:03 +02:00
sh "docker push ${env.DOCKER_REGISTRY}/${env.SERVICE}:latest"
}
}
2019-04-11 19:42:18 +02:00
}
2019-11-26 20:04:03 +01:00
sh "aws s3 cp `ls -t ./dist/semver-* | head -1` s3://rbn-ops-pkg-us-east-1/${env.SERVICE}/${env.SERVICE}-${env.VERSION}.tar.gz"
2019-04-11 19:42:18 +02:00
}
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-05-30 22:00:25 +02:00
stage('Push Version and Tag') {
steps {
echo "The current branch is ${env.BRANCH_NAME}."
2019-11-25 20:34:30 +01:00
gitPushTags(env.GITHUB_KEY)
2019-05-30 22:00:25 +02:00
}
}
2019-04-11 19:47:15 +02:00
}
2019-11-26 18:19:06 +01:00
post {
success { updateGithubCommitStatus(GITHUB_URL, 'Passed build and test', 'SUCCESS') }
failure { updateGithubCommitStatus(GITHUB_URL, 'Failed build and test', 'FAILURE') }
2019-04-11 19:48:29 +02:00
}
2019-04-11 19:42:18 +02:00
}