credentials environment variable

This commit is contained in:
2019-12-19 16:57:03 -05:00
parent 57411e6a46
commit 6b4568a2be

21
Jenkinsfile vendored
View File

@ -6,7 +6,7 @@ pipeline {
environment { environment {
SERVICE = 'auto-semver' SERVICE = 'auto-semver'
GITHUB_URL = 'git@github.com:RightBrain-Networks/auto-semver.git' GITHUB_URL = 'git@github.com:RightBrain-Networks/auto-semver.git'
env.DOCKER_REGISTRY = credentials('RbnDockerRegistry')
//Image tag to use for self-versioning //Image tag to use for self-versioning
SELF_SEMVER_TAG = "develop" SELF_SEMVER_TAG = "develop"
@ -15,9 +15,7 @@ pipeline {
//Runs versioning in docker container //Runs versioning in docker container
stage('Self Version') { stage('Self Version') {
steps { steps {
withCredentials([string(credentialsId: 'RbnDockerRegistry', variable: 'DOCKER_REGISTRY')]) { runAutoSemver("${env.DOCKER_REGISTRY}/auto-semver:${SELF_SEMVER_TAG}")
runAutoSemver("${DOCKER_REGISTRY}/auto-semver:${SELF_SEMVER_TAG}")
}
} }
post{ post{
// Update Git with status of version stage. // Update Git with status of version stage.
@ -34,10 +32,9 @@ pipeline {
echo "Building ${env.SERVICE} docker image" echo "Building ${env.SERVICE} docker image"
withCredentials([string(credentialsId: 'RbnDockerRegistry', variable: 'DOCKER_REGISTRY')]) { // Docker build flags are set via the getDockerBuildFlags() shared library.
// Docker build flags are set via the getDockerBuildFlags() shared library. sh "docker build ${getDockerBuildFlags()} -t ${env.DOCKER_REGISTRY}/${env.SERVICE}:${env.VERSION} ."
sh "docker build ${getDockerBuildFlags()} -t ${DOCKER_REGISTRY}/${env.SERVICE}:${env.VERSION} ."
}
sh "python setup.py sdist" sh "python setup.py sdist"
} }
@ -55,17 +52,15 @@ pipeline {
{ {
steps { steps {
withEcr { withEcr {
withCredentials([string(credentialsId: 'RbnDockerRegistry', variable: 'DOCKER_REGISTRY')]) { sh "docker push ${env.DOCKER_REGISTRY}/${env.SERVICE}:${env.VERSION}"
sh "docker push ${DOCKER_REGISTRY}/${env.SERVICE}:${env.VERSION}"
script script
{ {
if("${env.BRANCH_NAME}" == "develop") if("${env.BRANCH_NAME}" == "develop")
{ {
sh "docker tag ${DOCKER_REGISTRY}/${env.SERVICE}:${env.VERSION} ${DOCKER_REGISTRY}/${env.SERVICE}:latest" sh "docker tag ${env.DOCKER_REGISTRY}/${env.SERVICE}:${env.VERSION} ${env.DOCKER_REGISTRY}/${env.SERVICE}:latest"
sh "docker push ${DOCKER_REGISTRY}/${env.SERVICE}:latest" sh "docker push ${env.DOCKER_REGISTRY}/${env.SERVICE}:latest"
} }
} }
}
} }
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" 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"