From 11d9d5ef638475e49c382a3844016a13d364f923 Mon Sep 17 00:00:00 2001 From: shaowenchen Date: Thu, 29 Oct 2020 10:00:15 +0800 Subject: [PATCH 1/4] fix: remove unsupported parameters --- Jenkinsfile-on-prem | 2 +- Jenkinsfile-online | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile-on-prem b/Jenkinsfile-on-prem index 1a47ed52..09084338 100644 --- a/Jenkinsfile-on-prem +++ b/Jenkinsfile-on-prem @@ -40,7 +40,7 @@ pipeline { container ('maven') { withCredentials([string(credentialsId: "$SONAR_CREDENTIAL_ID", variable: 'SONAR_TOKEN')]) { withSonarQubeEnv('sonar') { - sh "mvn sonar:sonar -o -gs `pwd`/configuration/settings.xml -Dsonar.branch=$BRANCH_NAME -Dsonar.login=$SONAR_TOKEN" + sh "mvn sonar:sonar -o -gs `pwd`/configuration/settings.xml -Dsonar.login=$SONAR_TOKEN" } } timeout(time: 1, unit: 'HOURS') { diff --git a/Jenkinsfile-online b/Jenkinsfile-online index dec0cebf..f677c057 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -40,7 +40,7 @@ pipeline { container ('maven') { withCredentials([string(credentialsId: "$SONAR_CREDENTIAL_ID", variable: 'SONAR_TOKEN')]) { withSonarQubeEnv('sonar') { - sh "mvn sonar:sonar -o -gs `pwd`/configuration/settings.xml -Dsonar.branch=$BRANCH_NAME -Dsonar.login=$SONAR_TOKEN" + sh "mvn sonar:sonar -o -gs `pwd`/configuration/settings.xml -Dsonar.login=$SONAR_TOKEN" } } timeout(time: 1, unit: 'HOURS') { From 108e2fe63fc653e2b54e43d345aa7aa3e8cdfee7 Mon Sep 17 00:00:00 2001 From: shaowenchen Date: Thu, 29 Oct 2020 10:44:40 +0800 Subject: [PATCH 2/4] fix: sonarqube branch error --- Jenkinsfile-on-prem | 4 ++-- Jenkinsfile-online | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile-on-prem b/Jenkinsfile-on-prem index 09084338..1f693ce9 100644 --- a/Jenkinsfile-on-prem +++ b/Jenkinsfile-on-prem @@ -65,7 +65,7 @@ pipeline { stage('push latest'){ when{ - branch 'master' + branch 'sonarqube' } steps{ container ('maven') { @@ -77,7 +77,7 @@ pipeline { stage('deploy to dev') { when{ - branch 'master' + branch 'sonarqube' } steps { input(id: 'deploy-to-dev', message: 'deploy to dev?') diff --git a/Jenkinsfile-online b/Jenkinsfile-online index f677c057..24affdda 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -65,7 +65,7 @@ pipeline { stage('push latest'){ when{ - branch 'master' + branch 'sonarqube' } steps{ container ('maven') { @@ -77,7 +77,7 @@ pipeline { stage('deploy to dev') { when{ - branch 'master' + branch 'sonarqube' } steps { input(id: 'deploy-to-dev', message: 'deploy to dev?') From 05204423a7ecc294f185b5f341e602435d431d59 Mon Sep 17 00:00:00 2001 From: shaowenchen Date: Mon, 2 Nov 2020 16:41:43 +0800 Subject: [PATCH 3/4] improvement: don't use cache to build Signed-off-by: shaowenchen --- Jenkinsfile-on-prem | 2 +- Jenkinsfile-online | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile-on-prem b/Jenkinsfile-on-prem index 1f693ce9..ed07df2f 100644 --- a/Jenkinsfile-on-prem +++ b/Jenkinsfile-on-prem @@ -54,7 +54,7 @@ pipeline { steps { container ('maven') { sh 'mvn -o -Dmaven.test.skip=true -gs `pwd`/configuration/settings.xml clean package' - sh 'docker build -f Dockerfile-on-prem -t $REGISTRY/$HARBOR_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER .' + sh 'docker build --no-cache -f Dockerfile-on-prem -t $REGISTRY/$HARBOR_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER .' withCredentials([usernamePassword(passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,credentialsId : "$HARBOR_CREDENTIAL_ID" ,)]) { sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin' sh 'docker push $REGISTRY/$HARBOR_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER' diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 24affdda..dec3bf2e 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -54,7 +54,7 @@ pipeline { steps { container ('maven') { sh 'mvn -o -Dmaven.test.skip=true -gs `pwd`/configuration/settings.xml clean package' - sh 'docker build -f Dockerfile-online -t $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER .' + sh 'docker build --no-cache -f Dockerfile-online -t $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER .' withCredentials([usernamePassword(passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,credentialsId : "$DOCKER_CREDENTIAL_ID" ,)]) { sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin' sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER' From 306cc50319bfbc7f379b7ecfbe5e65ed8e5e32bd Mon Sep 17 00:00:00 2001 From: MaxLanGod <1114773280@qq.com> Date: Thu, 28 Oct 2021 17:24:16 +0800 Subject: [PATCH 4/4] Update Jenkinsfile-online --- Jenkinsfile-online | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index dec3bf2e..a8a264d2 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -14,10 +14,10 @@ pipeline { GITHUB_CREDENTIAL_ID = 'github-id' KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig' REGISTRY = 'docker.io' - DOCKERHUB_NAMESPACE = 'docker_username' - GITHUB_ACCOUNT = 'kubesphere' + DOCKERHUB_NAMESPACE = 'zhangyalan' + GITHUB_ACCOUNT = 'MaxLanGod' APP_NAME = 'devops-java-sample' - SONAR_CREDENTIAL_ID = 'sonar-token' + SONAR_CREDENTIAL_ID = 'sonar-qube' } stages {