From 1020ed5e40c3bea4e507fcb243dd9b5c0ed9abf3 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 12 Jul 2022 15:52:57 +0800 Subject: [PATCH 01/10] Update Jenkinsfile-online --- Jenkinsfile-online | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 2ca69e7f..cbb0404d 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -11,12 +11,13 @@ pipeline { environment { DOCKER_CREDENTIAL_ID = 'dockerhub-id' - GITHUB_CREDENTIAL_ID = 'github-id' + GITHUB_CREDENTIAL_ID = 'Github-id' KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig' REGISTRY = 'docker.io' - DOCKERHUB_NAMESPACE = 'docker_username' - GITHUB_ACCOUNT = 'kubesphere' + DOCKERHUB_NAMESPACE = 'yeha' + GITHUB_ACCOUNT = 'yeha49' APP_NAME = 'devops-java-sample' + SONAR-CREDENTIAL_ID = 'sonar-qube' } stages { From 5daeece47409ceca4b636fce3b7d5ca7357ff4b9 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 12 Jul 2022 15:53:23 +0800 Subject: [PATCH 02/10] Update Jenkinsfile-online --- Jenkinsfile-online | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index cbb0404d..229183e9 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -17,7 +17,7 @@ pipeline { DOCKERHUB_NAMESPACE = 'yeha' GITHUB_ACCOUNT = 'yeha49' APP_NAME = 'devops-java-sample' - SONAR-CREDENTIAL_ID = 'sonar-qube' + SONAR_CREDENTIAL_ID = 'sonar-qube' } stages { From c0ad475121e50b9db361f60fccbf318e8b5bbb32 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 12 Jul 2022 16:03:37 +0800 Subject: [PATCH 03/10] Update Jenkinsfile-on-prem --- Jenkinsfile-on-prem | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile-on-prem b/Jenkinsfile-on-prem index b76a9ccb..40b1bf4e 100644 --- a/Jenkinsfile-on-prem +++ b/Jenkinsfile-on-prem @@ -17,6 +17,7 @@ pipeline { HARBOR_NAMESPACE = 'library' GITLAB_ACCOUNT = 'admin1' APP_NAME = 'devops-java-sample' + SONAR_CREDENTIAL_ID= 'sonar-qube' } stages { From 1cbdcea476178596cfb4458e1076d970bcb2f067 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 12 Jul 2022 16:04:14 +0800 Subject: [PATCH 04/10] Update Jenkinsfile-on-prem --- Jenkinsfile-on-prem | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Jenkinsfile-on-prem b/Jenkinsfile-on-prem index 40b1bf4e..c4e25c3c 100644 --- a/Jenkinsfile-on-prem +++ b/Jenkinsfile-on-prem @@ -34,6 +34,21 @@ pipeline { } } } + + stage('sonarqube analysis') { + steps { + 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" + } + } + timeout(time: 1, unit: 'HOURS') { + waitForQualityGate abortPipeline: true + } + } + } + } stage ('build & push') { steps { From 8dd1587da390f40e264fe4ac6e3cdb8206fadf84 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 12 Jul 2022 16:05:02 +0800 Subject: [PATCH 05/10] Update Jenkinsfile-online --- Jenkinsfile-online | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 229183e9..32621102 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -34,6 +34,21 @@ pipeline { } } } + + stage('sonarqube analysis') { + steps { + 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" + } + } + timeout(time: 1, unit: 'HOURS') { + waitForQualityGate abortPipeline: true + } + } + } + } stage ('build & push') { steps { From 8bdd9b79efcf24a66418cfdd582454eda6160e40 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 12 Jul 2022 16:05:53 +0800 Subject: [PATCH 06/10] Update Jenkinsfile-online --- Jenkinsfile-online | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 32621102..c6722ada 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 -gs `pwd`/configuration/settings.xml -Dsonar.branch=$BRANCH_NAME -Dsonar.login=$SONAR_TOKEN" } } timeout(time: 1, unit: 'HOURS') { From 895f2882f4e6d88b0bb2cd87d3d23cc9bb31cefe Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 12 Jul 2022 16:06:54 +0800 Subject: [PATCH 07/10] Update Jenkinsfile-on-prem --- Jenkinsfile-on-prem | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile-on-prem b/Jenkinsfile-on-prem index c4e25c3c..06c27ec5 100644 --- a/Jenkinsfile-on-prem +++ b/Jenkinsfile-on-prem @@ -30,7 +30,7 @@ pipeline { stage ('unit test') { steps { container ('maven') { - sh 'mvn clean -o -gs `pwd`/configuration/settings.xml test' + sh 'mvn clean -gs `pwd`/configuration/settings.xml test' } } } @@ -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 -gs `pwd`/configuration/settings.xml -Dsonar.branch=$BRANCH_NAME -Dsonar.login=$SONAR_TOKEN" } } timeout(time: 1, unit: 'HOURS') { @@ -53,7 +53,7 @@ pipeline { stage ('build & push') { steps { container ('maven') { - sh 'mvn -o -Dmaven.test.skip=true -gs `pwd`/configuration/settings.xml clean package' + sh 'mvn -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 .' withCredentials([usernamePassword(passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,credentialsId : "$HARBOR_CREDENTIAL_ID" ,)]) { sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin' From 4d174484fad57516046b69bb8482bf425e45b603 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 12 Jul 2022 16:58:22 +0800 Subject: [PATCH 08/10] Update Jenkinsfile-on-prem --- Jenkinsfile-on-prem | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile-on-prem b/Jenkinsfile-on-prem index 06c27ec5..1b3877f5 100644 --- a/Jenkinsfile-on-prem +++ b/Jenkinsfile-on-prem @@ -10,14 +10,14 @@ pipeline { } environment { - HARBOR_CREDENTIAL_ID = 'harbor-id' - GITLAB_CREDENTIAL_ID = 'gitlab-id' + DOCKER_CREDENTIAL_ID = 'dockerhub-id' + GITHUB_CREDENTIAL_ID = 'Github-id' KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig' - REGISTRY = 'harbor.devops.kubesphere.local:30280' - HARBOR_NAMESPACE = 'library' - GITLAB_ACCOUNT = 'admin1' + REGISTRY = 'docker.io' + DOCKERHUB_NAMESPACE = 'yeha' + GITHUB_ACCOUNT = 'yeha49' APP_NAME = 'devops-java-sample' - SONAR_CREDENTIAL_ID= 'sonar-qube' + SONAR_CREDENTIAL_ID = 'sonar-qube' } stages { From 8bacfb04be9c2f5a44ab2e7a713701d387ff619a Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 12 Jul 2022 17:40:32 +0800 Subject: [PATCH 09/10] Update Jenkinsfile-online --- Jenkinsfile-online | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index c6722ada..5bc707a1 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -17,7 +17,7 @@ pipeline { DOCKERHUB_NAMESPACE = 'yeha' GITHUB_ACCOUNT = 'yeha49' APP_NAME = 'devops-java-sample' - SONAR_CREDENTIAL_ID = 'sonar-qube' + SONAR_CREDENTIAL_ID = 'sonar-aaa' } stages { From 312714eae0ae43d41cb79d2becd36f5a016e4d35 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 12 Jul 2022 17:59:31 +0800 Subject: [PATCH 10/10] Update pom.xml --- pom.xml | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/pom.xml b/pom.xml index 2b912c1c..daba986d 100644 --- a/pom.xml +++ b/pom.xml @@ -25,31 +25,7 @@ spring-boot-starter-parent 2.1.11.RELEASE - - - - spring - https://maven.aliyun.com/repository/spring - - true - - - true - - - - - - spring - https://maven.aliyun.com/repository/spring - - true - - - true - - - +