From 14c306e5ebb026b52ec1cd829babb83bb553e2fd Mon Sep 17 00:00:00 2001 From: zhm5921 <1554966336@qq.com> Date: Sun, 8 May 2022 22:52:19 +0800 Subject: [PATCH 1/2] Update Jenkinsfile-online --- Jenkinsfile-online | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 2ca69e7f1..e44b82870 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -12,11 +12,12 @@ pipeline { environment { DOCKER_CREDENTIAL_ID = 'dockerhub-id' GITHUB_CREDENTIAL_ID = 'github-id' - KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig' + KUBECONFIG_CREDENTIAL_ID = 'kubeconfig-id' REGISTRY = 'docker.io' - DOCKERHUB_NAMESPACE = 'docker_username' - GITHUB_ACCOUNT = 'kubesphere' + DOCKERHUB_NAMESPACE = '1554966336@qq.com' + GITHUB_ACCOUNT = '1554966336@qq.com' APP_NAME = 'devops-java-sample' + SONAR_CREDENTIAL_ID = 'sonar-qube' } stages { From 97f258f78885ee06a1d5aa0a6ec53ab784a550d3 Mon Sep 17 00:00:00 2001 From: zhm5921 <1554966336@qq.com> Date: Sun, 8 May 2022 22:58:38 +0800 Subject: [PATCH 2/2] Update Jenkinsfile-online --- Jenkinsfile-online | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index e44b82870..45a808e4d 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 -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 {