Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ tag = True
tag_name = {new_version}
message = Bump version: {current_version} -> {new_version}

[bumpversion:file:semver.semver]
search = version = {current_version}
replace = version = {new_version}
[bumpversion:file:VERSION]
search = __version__ = {current_version}
replace = __version__ = {new_version}

[semver]
main_branches = develops, env-test, env-stage, env-prod
major_branches =
minor_branches = feature, RightBrain-Networks/feature
patch_branches = hotfix, bugfix

main_branches = development
major_branches =
minor_branches = feature
patch_branches = bugfix, hotfix
47 changes: 36 additions & 11 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
library('pipeline-library@feature/add-with-ecr')
library('pipeline-library')

pipeline {
options { timestamps() }
agent any
environment {
SERVICE = 'kmstool'
GITHUB_KEY = 'Jenkins'
GITHUB_URL = 'https://github.com/dejonghe/kmstool'
GITHUB_KEY = 'kmstoolDeployKey'
GITHUB_URL = 'git@github.com:dejonghe/kmstool.git'
DOCKER_REGISTRY = '356438515751.dkr.ecr.us-east-1.amazonaws.com'
}
stages {
stage('Version') {
steps {
// runs the automatic semver tool which will version, & tag,
runAutoSemver()
withEcr {
runAutoSemver()
}
}
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')
}
}
}
stage('Build') {
Expand All @@ -23,9 +34,9 @@ pipeline {
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 "docker build ${getDockerBuildFlags()} -t ${env.DOCKER_REGISTRY}/${env.SERVICE}:${env.SEMVER_RESOLVED_VERSION} ."

sh "tar -czvf ${env.SERVICE}-${getVersion('-d')}.tar.gz kmstool"
sh "tar -czvf ${env.SERVICE}-${env.SEMVER_RESOLVED_VERSION}.tar.gz kmstool"
}
post{
// Update Git with status of build stage.
Expand All @@ -37,27 +48,41 @@ pipeline {
}
}
}
stage('Push')
stage('Ship')
{
steps {
withEcr {
sh "docker push ${env.DOCKER_REGISTRY}/${env.SERVICE}:${getVersion('-d')}"
sh "docker push ${env.DOCKER_REGISTRY}/${env.SERVICE}:${env.SEMVER_RESOLVED_VERSION}"
script
{
if("${env.BRANCH_NAME}" == "development")
{
sh "docker tag ${env.DOCKER_REGISTRY}/${env.SERVICE}:${env.SEMVER_RESOLVED_VERSION} ${env.DOCKER_REGISTRY}/${env.SERVICE}:latest"
sh "docker push ${env.DOCKER_REGISTRY}/${env.SERVICE}:latest"
}
}
}

//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"
sh "aws s3 cp ${env.SERVICE}-${env.SEMVER_RESOLVED_VERSION}.tar.gz s3://rbn-ops-pkg-us-east-1/${env.SERVICE}/${env.SERVICE}-${env.SEMVER_RESOLVED_VERSION}.tar.gz"

}
post{
// Update Git with status of push stage.
success {
updateGithubCommitStatus(GITHUB_URL, 'Passed push stage', 'SUCCESS', 'Push')
updateGithubCommitStatus(GITHUB_URL, 'Passed ship stage', 'SUCCESS', 'Ship')
}
failure {
updateGithubCommitStatus(GITHUB_URL, 'Failed push stage', 'FAILURE', 'Push')
updateGithubCommitStatus(GITHUB_URL, 'Failed ship stage', 'FAILURE', 'Ship')
}
}
}
stage('Push Version and Tag') {
steps {
echo "The current branch is ${env.BRANCH_NAME}."
gitPush(env.GITHUB_KEY, env.BRANCH_NAME, true)
}
}
}
post {
always {
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = 1.4.0