From fbe1d22dd018df9a4c74caee9776f763bf6ffc86 Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Wed, 3 Aug 2016 12:26:46 -0700 Subject: [PATCH] Give Pipeline the proper credentials to publish to Dockerhub --- Jenkinsfile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1e9c13f..e8ef6c4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,9 +2,19 @@ node('docker') { + checkout scm + stage 'Build Containers' sh './build-rubies.sh' stage 'Publish Containers' - sh './push-rubies.sh' + /* Using credentials with the ID 'dockerhub' from the Jenkins installation */ + withCredentials([[$class: 'UsernamePasswordMultiBinding', + credentialsId: 'dockerhub', + passwordVariable: 'DOCKERHUB_TOKEN', + usernameVariable: 'DOCKERHUB_EMAIL']]) { + /* Our variables be exposed in the environment and we must log in before trying to publish to Dockerhub */ + sh 'docker login --username ${DOCKERHUB_EMAIL} --password ${DOCKERHUB_TOKEN}' + sh './push-rubies.sh' + } }