From 98ac9be118ca4f3bbb29a0707e26d9825ab8191a Mon Sep 17 00:00:00 2001 From: mafei Date: Wed, 8 Dec 2021 16:36:16 +0800 Subject: [PATCH 1/7] modify --- Jenkinsfile-online | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 2ca69e7f1..90d2ef43e 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -14,8 +14,8 @@ pipeline { GITHUB_CREDENTIAL_ID = 'github-id' KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig' REGISTRY = 'docker.io' - DOCKERHUB_NAMESPACE = 'docker_username' - GITHUB_ACCOUNT = 'kubesphere' + DOCKERHUB_NAMESPACE = 'jsntmf' + GITHUB_ACCOUNT = 'jsntmf' APP_NAME = 'devops-java-sample' } @@ -78,8 +78,8 @@ pipeline { 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 config --global user.email "jsntmf@qq.com" ' + sh 'git config --global user.name "jsntmf" ' 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' } From a9460a43034c15d731348b51a6ebaefe087e43e8 Mon Sep 17 00:00:00 2001 From: mafei Date: Thu, 9 Dec 2021 10:30:15 +0800 Subject: [PATCH 2/7] modify --- Jenkinsfile-online | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 90d2ef43e..0ec384c10 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -38,10 +38,10 @@ pipeline { 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 .' + sh 'docker build -f Dockerfile-online -t $REGISTRY/jsntmf/$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' + sh 'docker push $REGISTRY/jsntmf/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER' } } } @@ -53,8 +53,8 @@ pipeline { } 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 ' + sh 'docker tag $REGISTRY/jsntmf/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:latest ' + sh 'docker push $REGISTRY/jsntmf/$APP_NAME:latest ' } } } From 10c1ca39ead656ded08a0e8d51567db890e3c05d Mon Sep 17 00:00:00 2001 From: mafei Date: Thu, 9 Dec 2021 11:28:52 +0800 Subject: [PATCH 3/7] modify --- Jenkinsfile-online | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 0ec384c10..90d2ef43e 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -38,10 +38,10 @@ pipeline { steps { container ('maven') { sh 'mvn -Dmaven.test.skip=true -gs `pwd`/configuration/settings.xml clean package' - sh 'docker build -f Dockerfile-online -t $REGISTRY/jsntmf/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER .' + 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/jsntmf/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER' + sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER' } } } @@ -53,8 +53,8 @@ pipeline { } steps{ container ('maven') { - sh 'docker tag $REGISTRY/jsntmf/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:latest ' - sh 'docker push $REGISTRY/jsntmf/$APP_NAME:latest ' + 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 ' } } } From 1b542be54ffded1ba28df4c7d20ab4cad24405d8 Mon Sep 17 00:00:00 2001 From: mafei Date: Thu, 9 Dec 2021 12:01:23 +0800 Subject: [PATCH 4/7] modify --- Jenkinsfile-online | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 90d2ef43e..4ae7d31be 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -67,6 +67,20 @@ pipeline { input(id: 'deploy-to-dev', message: 'deploy to dev?') kubernetesDeploy(configs: 'deploy/dev-ol/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID") } + + steps { + + input(id: 'deploy-to-dev', message: 'deploy to dev?') + container ('maven') { + withCredentials([ + kubeconfigFile( + credentialsId: $KUBECONFIG_CREDENTIAL_ID, + variable: 'KUBECONFIG') + ]) { + sh 'envsubst < deploy/dev-ol/** | kubectl apply -f -' + } + } + } } stage('push with tag'){ when{ From cdd202d733cb5b37eb44d033a2f18a5bfa34f964 Mon Sep 17 00:00:00 2001 From: mafei Date: Fri, 10 Dec 2021 10:06:50 +0800 Subject: [PATCH 5/7] modify --- Jenkinsfile-online | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 4ae7d31be..996663f3f 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -63,24 +63,19 @@ pipeline { when{ branch 'master' } - steps { - input(id: 'deploy-to-dev', message: 'deploy to dev?') - kubernetesDeploy(configs: 'deploy/dev-ol/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID") - } steps { - input(id: 'deploy-to-dev', message: 'deploy to dev?') - container ('maven') { - withCredentials([ - kubeconfigFile( - credentialsId: $KUBECONFIG_CREDENTIAL_ID, - variable: 'KUBECONFIG') - ]) { - sh 'envsubst < deploy/dev-ol/** | kubectl apply -f -' - } - } - } + container ('maven') { + withCredentials([ + kubeconfigFile( + credentialsId: $KUBECONFIG_CREDENTIAL_ID, + variable: 'KUBECONFIG') + ]) { + sh 'envsubst < deploy/dev-ol/** | kubectl apply -f -' + } + } + } } stage('push with tag'){ when{ From a0cfe761681cc5c204db1b10f244a714d3d36fe3 Mon Sep 17 00:00:00 2001 From: mafei Date: Fri, 10 Dec 2021 11:25:43 +0800 Subject: [PATCH 6/7] modify --- Jenkinsfile-online | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 996663f3f..086b64ff3 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -69,9 +69,10 @@ pipeline { container ('maven') { withCredentials([ kubeconfigFile( - credentialsId: $KUBECONFIG_CREDENTIAL_ID, + credentialsId: env.KUBECONFIG_CREDENTIAL_ID, variable: 'KUBECONFIG') ]) { + sh 'echo "mafei -----$KUBECONFIG_CREDENTIAL_ID"' sh 'envsubst < deploy/dev-ol/** | kubectl apply -f -' } } From d219d2e3445bcf9adc9cdf49528a848e2cd988d0 Mon Sep 17 00:00:00 2001 From: mafei Date: Fri, 10 Dec 2021 14:51:27 +0800 Subject: [PATCH 7/7] modify --- Jenkinsfile-online | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 086b64ff3..512cea64d 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -73,7 +73,8 @@ pipeline { variable: 'KUBECONFIG') ]) { sh 'echo "mafei -----$KUBECONFIG_CREDENTIAL_ID"' - sh 'envsubst < deploy/dev-ol/** | kubectl apply -f -' + sh 'envsubst < deploy/dev-ol/devops-sample.yaml | kubectl apply -f -' + sh 'envsubst < deploy/dev-ol/devops-sample-svc.yaml | kubectl apply -f -' } } }