From 6deb02b11d5d7ed96cca33f30e14acf9c5c36813 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Tue, 18 Jan 2022 22:52:11 -0600 Subject: [PATCH 1/2] single quotes to fix insecure string interpolation --- Jenkinsfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9c1a20a..2d622a5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -34,18 +34,18 @@ node('worker'){ ]) } def tag = '' - stage("Build Container"){ + stage('Build Container'){ if (params.BRANCH.contains('main')){ tag = 'latest' } else { tag = params.BRANCH.replace('\\', '-') } - sh "docker build -t aronwk/nexus-dashboard:${tag} ." + sh 'docker build -t aronwk/nexus-dashboard:${tag} .' } - stage("Push Container"){ + stage('Push Container'){ withCredentials([usernamePassword(credentialsId: 'docker-hub-token', passwordVariable: 'password', usernameVariable: 'username')]) { - sh "docker login -u ${username} -p ${password}" - sh "docker push aronwk/nexus-dashboard:${tag}" + sh 'docker login -u ${username} -p ${password}' + sh 'docker push aronwk/nexus-dashboard:${tag}' sh 'docker logout' } } From 4bda98670bfbafbfcfda8f6cb8e599b461819d7f Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Tue, 18 Jan 2022 23:04:32 -0600 Subject: [PATCH 2/2] Didn't work use GIT_BRANCH as branch var --- Jenkinsfile | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2d622a5..260948c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,8 +5,8 @@ properties([ branchFilter: 'origin/(.*)', defaultValue: 'origin/main', description: '', - name: 'BRANCH', - quickFilterEnabled: false, + name: 'GIT_BRANCH', + quickFilterEnabled: true, selectedValue: 'DEFAULT', sortMode: 'NONE', tagFilter: '*', @@ -17,13 +17,12 @@ properties([ ]) node('worker'){ - - currentBuild.setDescription(params.BRANCH) + currentBuild.setDescription(params.GIT_BRANCH) stage('Clone Code'){ checkout([ $class: 'GitSCM', - branches: [[name: params.BRANCH]], + branches: [[name: params.GIT_BRANCH]], extensions: [], userRemoteConfigs: [ [ @@ -40,13 +39,13 @@ node('worker'){ } else { tag = params.BRANCH.replace('\\', '-') } - sh 'docker build -t aronwk/nexus-dashboard:${tag} .' + sh "docker build -t aronwk/nexus-dashboard:$tag ." } stage('Push Container'){ withCredentials([usernamePassword(credentialsId: 'docker-hub-token', passwordVariable: 'password', usernameVariable: 'username')]) { - sh 'docker login -u ${username} -p ${password}' - sh 'docker push aronwk/nexus-dashboard:${tag}' - sh 'docker logout' + sh "docker login -u $username -p $password" + sh "docker push aronwk/nexus-dashboard:$tag" + sh "docker logout" } } }