diff --git a/Jenkinsfile-on-prem b/Jenkinsfile-on-prem index 1a47ed52..ed07df2f 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') { @@ -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' @@ -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 dec0cebf..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 { @@ -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') { @@ -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' @@ -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?')