Skip to content

Commit cde826b

Browse files
committed
add sonar-token
1 parent 689b0b4 commit cde826b

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

‎Jenkinsfile‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pipeline {
1717
NAMESPACE = 'library'
1818
GITLAB_ACCOUNT = 'admin1'
1919
APP_NAME = 'devops-sample-s2i'
20+
SONAR_TOKEN_ID= 'sonar-token'
2021
}
2122

2223
stages {
@@ -37,10 +38,8 @@ pipeline {
3738
stage('sonarqube analysis') {
3839
steps {
3940
container ('maven') {
40-
withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) {
41-
withSonarQubeEnv('sonar') {
42-
sh "mvn sonar:sonar -o -gs `pwd`/configuration/settings.xml -Dsonar.branch=$BRANCH_NAME -Dsonar.login=$SONAR_TOKEN"
43-
}
41+
withSonarQubeEnv('sonar') {
42+
sh "mvn sonar:sonar -o -gs `pwd`/configuration/settings.xml -Dsonar.branch=$BRANCH_NAME -Dsonar.login=$SONAR_TOKEN_ID"
4443
}
4544
timeout(time: 1, unit: 'HOURS') {
4645
waitForQualityGate abortPipeline: true

‎Jenkinsfile-online‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ pipeline {
1111

1212
environment {
1313
DOCKER_CREDENTIAL_ID = 'dockerhub-id'
14-
GITHUB_CREDENTIAL_ID = 'gitlab-id'
14+
GITHUB_CREDENTIAL_ID = 'github-id'
1515
KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig'
1616
REDISTRY = 'docker.io'
1717
NAMESPACE = 'docker_username'
1818
GITHUB_ACCOUNT = 'kubesphere'
1919
APP_NAME = 'devops-sample-s2i'
20+
SONAR_TOKEN_ID= 'sonar-token'
2021
}
2122

2223
stages {
@@ -37,15 +38,13 @@ pipeline {
3738
stage('sonarqube analysis') {
3839
steps {
3940
container ('maven') {
40-
withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) {
41-
withSonarQubeEnv('sonar') {
42-
sh "mvn sonar:sonar -o -gs `pwd`/configuration/settings.xml -Dsonar.branch=$BRANCH_NAME -Dsonar.login=$SONAR_TOKEN"
43-
}
41+
withSonarQubeEnv('sonar') {
42+
sh "mvn sonar:sonar -o -gs `pwd`/configuration/settings.xml -Dsonar.branch=$BRANCH_NAME -Dsonar.login=$SONAR_TOKEN_ID"
4443
}
4544
timeout(time: 1, unit: 'HOURS') {
4645
waitForQualityGate abortPipeline: true
4746
}
48-
}
47+
}
4948
}
5049
}
5150

@@ -96,7 +95,7 @@ pipeline {
9695
sh 'git config --global user.email "kubesphere@yunify.com" '
9796
sh 'git config --global user.name "kubesphere" '
9897
sh 'git tag -a $TAG_NAME -m "$TAG_NAME" '
99-
sh 'git push http://$GIT_USERNAME:$GIT_PASSWORD@gitlab.devops.kubesphere.local:30080/$GITHUB_ACCOUNT/$APP_NAME.git --tags'
98+
sh 'git push http://$GIT_USERNAME:$GIT_PASSWORD@github.com/$GITHUB_ACCOUNT/$APP_NAME.git --tags'
10099
}
101100
sh 'docker tag $REDISTRY/$NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER $REDISTRY/$NAMESPACE/$APP_NAME:$TAG_NAME '
102101
sh 'docker push $REDISTRY/$NAMESPACE/$APP_NAME:$TAG_NAME '

0 commit comments

Comments
 (0)