diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 2ca69e7f1..45a808e4d 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 { @@ -33,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 {