From 7374591cff889fb349bbfb3d343c860217899adc Mon Sep 17 00:00:00 2001 From: jayangyy <361300115@qq.com> Date: Tue, 4 May 2021 15:08:41 +0800 Subject: [PATCH 1/5] Update Jenkinsfile-online 3333 --- Jenkinsfile-online | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 2ca69e7f..067a3b33 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -10,13 +10,14 @@ pipeline { } environment { - DOCKER_CREDENTIAL_ID = 'dockerhub-id' + DOCKER_CREDENTIAL_ID = 'docker-id' GITHUB_CREDENTIAL_ID = 'github-id' - KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig' + KUBECONFIG_CREDENTIAL_ID = 'kubeconfig' REGISTRY = 'docker.io' - DOCKERHUB_NAMESPACE = 'docker_username' - GITHUB_ACCOUNT = 'kubesphere' + DOCKERHUB_NAMESPACE = 'jayang' + GITHUB_ACCOUNT = 'jayangyy' APP_NAME = 'devops-java-sample' + SONAR_CREDENTIAL_ID= '65e9338d4a54359d97d9f9ca6568564f9e6e9ebd' } stages { From 066984d4a9f839f821081220347fe6dd2711bf17 Mon Sep 17 00:00:00 2001 From: jayangyy <361300115@qq.com> Date: Sat, 25 Dec 2021 21:14:28 +0800 Subject: [PATCH 2/5] Update settings.xml eeee --- configuration/settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration/settings.xml b/configuration/settings.xml index 9838b7c9..f3b8cbb5 100644 --- a/configuration/settings.xml +++ b/configuration/settings.xml @@ -11,7 +11,7 @@ jenkins - true + true From 4712c355d81cd777d34480f6ca7df0970a8bfad6 Mon Sep 17 00:00:00 2001 From: jayangyy <361300115@qq.com> Date: Sat, 25 Dec 2021 21:15:12 +0800 Subject: [PATCH 3/5] Update pom.xml --- pom.xml | 114 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 56 insertions(+), 58 deletions(-) diff --git a/pom.xml b/pom.xml index 2b912c1c..776056f4 100644 --- a/pom.xml +++ b/pom.xml @@ -1,53 +1,51 @@ - - 4.0.0 + + 4.0.0 - io.kubesphere.devops - devops-sample - 0.0.1-SNAPSHOT - devops-sample :: HelloWorld Demo + io.kubesphere.devops + devops-sample + 0.0.1-SNAPSHOT + devops-sample :: HelloWorld Demo - - UTF-8 - UTF-8 + + UTF-8 + UTF-8 - - + - ${PWD}/./target/jacoco.exec - target/classes - + ${PWD}/./target/jacoco.exec + target/classes + + + + + org.springframework.boot + spring-boot-starter-parent + 1.4.1.BUILD-SNAPSHOT + - - - org.springframework.boot - spring-boot-starter-parent - 2.1.11.RELEASE - - - spring - https://maven.aliyun.com/repository/spring - - true - - - true - + spring-snapshots + http://repo.spring.io/snapshot + true + + + spring-milestones + http://repo.spring.io/milestone - spring - https://maven.aliyun.com/repository/spring - - true - - - true - + spring-snapshots + http://repo.spring.io/snapshot + + + spring-milestones + http://repo.spring.io/milestone @@ -59,7 +57,7 @@ junit junit - 4.13.1 + 4.12 @@ -70,28 +68,28 @@ jacoco-maven-plugin 0.8.2 - true + true - - agent-for-ut - - prepare-agent - - - - agent-for-it - - prepare-agent-integration - - - - jacoco-site - verify - - report - - + + agent-for-ut + + prepare-agent + + + + agent-for-it + + prepare-agent-integration + + + + jacoco-site + verify + + report + + From a0b8e6a8f522620f3cd54914ad7f6dc358e53275 Mon Sep 17 00:00:00 2001 From: jayangyy <361300115@qq.com> Date: Sat, 25 Dec 2021 21:15:47 +0800 Subject: [PATCH 4/5] Create pom.xml From 54b1fa1a0c62593d0e0d185db1c1fc8785954d9f Mon Sep 17 00:00:00 2001 From: jayangyy <361300115@qq.com> Date: Sat, 25 Dec 2021 21:20:13 +0800 Subject: [PATCH 5/5] Update Jenkinsfile-online --- Jenkinsfile-online | 68 ++++++++++------------------------------------ 1 file changed, 14 insertions(+), 54 deletions(-) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 067a3b33..bc909e1f 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -10,14 +10,14 @@ pipeline { } environment { - DOCKER_CREDENTIAL_ID = 'docker-id' - GITHUB_CREDENTIAL_ID = 'github-id' + DOCKER_CREDENTIAL_ID = 'dockerhub-id' + GITHUB_CREDENTIAL_ID = 'git-hub' KUBECONFIG_CREDENTIAL_ID = 'kubeconfig' REGISTRY = 'docker.io' DOCKERHUB_NAMESPACE = 'jayang' GITHUB_ACCOUNT = 'jayangyy' APP_NAME = 'devops-java-sample' - SONAR_CREDENTIAL_ID= '65e9338d4a54359d97d9f9ca6568564f9e6e9ebd' + SONAR_CREDENTIAL_ID= 'sonar-token' } stages { @@ -34,61 +34,21 @@ pipeline { } } } - - stage ('build & push') { - steps { - container ('maven') { - sh 'mvn -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 .' - 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' - } - } - } - } - - stage('push latest'){ - when{ - branch 'master' - } - steps{ - container ('maven') { - sh 'docker tag $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:latest ' - sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:latest ' - } - } - } - - stage('deploy to dev') { - when{ - branch 'master' - } + stage('sonarqube analysis') { steps { - input(id: 'deploy-to-dev', message: 'deploy to dev?') - kubernetesDeploy(configs: 'deploy/dev-ol/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID") - } - } - stage('push with tag'){ - when{ - expression{ - return params.TAG_NAME =~ /v.*/ + container ('maven') { + withCredentials([string(credentialsId: "$SONAR_CREDENTIAL_ID", variable: 'SONAR_TOKEN')]) { + withSonarQubeEnv('sonar') { + sh "mvn sonar:sonar -o -gs `pwd`/configuration/settings.xml -Dsonar.login=$SONAR_TOKEN" + } + } + timeout(time: 1, unit: 'HOURS') { + waitForQualityGate abortPipeline: true + } } } - steps { - container ('maven') { - input(id: 'release-image-with-tag', message: 'release image with tag?') - withCredentials([usernamePassword(credentialsId: "$GITHUB_CREDENTIAL_ID", passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) { - sh 'git config --global user.email "kubesphere@yunify.com" ' - sh 'git config --global user.name "kubesphere" ' - sh 'git tag -a $TAG_NAME -m "$TAG_NAME" ' - sh 'git push http://$GIT_USERNAME:$GIT_PASSWORD@github.com/$GITHUB_ACCOUNT/devops-java-sample.git --tags --ipv4' - } - sh 'docker tag $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$TAG_NAME ' - sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$TAG_NAME ' - } - } } + stage('deploy to production') { when{ expression{