diff --git a/content/en/docs/devops-user-guide/examples/a-maven-project.md b/content/en/docs/devops-user-guide/examples/a-maven-project.md index 57262123f..ca13e5092 100644 --- a/content/en/docs/devops-user-guide/examples/a-maven-project.md +++ b/content/en/docs/devops-user-guide/examples/a-maven-project.md @@ -132,15 +132,17 @@ In this example, all workloads are deployed in `kubesphere-sample-dev`. You must } stage('deploy to dev') { - steps { - withCredentials([ - kubeconfigFile( - credentialsId: env.KUBECONFIG_CREDENTIAL_ID, - variable: 'KUBECONFIG') - ]) { - sh 'envsubst < deploy/all-in-one/devops-sample.yaml | kubectl apply -f -' + steps { + container ('maven') { + withCredentials([ + kubeconfigFile( + credentialsId: env.KUBECONFIG_CREDENTIAL_ID, + variable: 'KUBECONFIG') + ]) { + sh 'envsubst < deploy/all-in-one/devops-sample.yaml | kubectl apply -f -' + } + } } - } } } } diff --git a/content/en/docs/devops-user-guide/examples/create-multi-cluster-pipeline.md b/content/en/docs/devops-user-guide/examples/create-multi-cluster-pipeline.md index 80106666d..f36e07dd7 100644 --- a/content/en/docs/devops-user-guide/examples/create-multi-cluster-pipeline.md +++ b/content/en/docs/devops-user-guide/examples/create-multi-cluster-pipeline.md @@ -183,36 +183,42 @@ You must create the projects as shown in the table below in advance. Make sure y } stage('deploy to dev') { steps { - withCredentials([ - kubeconfigFile( - credentialsId: env.DEV_KUBECONFIG_CREDENTIAL_ID, - variable: 'KUBECONFIG') - ]) { - sh 'envsubst < deploy/dev-all-in-one/devops-sample.yaml | kubectl apply -f -' + container('maven') { + withCredentials([ + kubeconfigFile( + credentialsId: env.DEV_KUBECONFIG_CREDENTIAL_ID, + variable: 'KUBECONFIG') + ]) { + sh 'envsubst < deploy/dev-all-in-one/devops-sample.yaml | kubectl apply -f -' + } } } } stage('deploy to staging') { steps { - input(id: 'deploy-to-staging', message: 'deploy to staging?') - withCredentials([ - kubeconfigFile( - credentialsId: env.TEST_KUBECONFIG_CREDENTIAL_ID, - variable: 'KUBECONFIG') - ]) { - sh 'envsubst < deploy/prod-all-in-one/devops-sample.yaml | kubectl apply -f -' + container('maven') { + input(id: 'deploy-to-staging', message: 'deploy to staging?') + withCredentials([ + kubeconfigFile( + credentialsId: env.TEST_KUBECONFIG_CREDENTIAL_ID, + variable: 'KUBECONFIG') + ]) { + sh 'envsubst < deploy/prod-all-in-one/devops-sample.yaml | kubectl apply -f -' + } } } } stage('deploy to production') { steps { - input(id: 'deploy-to-production', message: 'deploy to production?') - withCredentials([ - kubeconfigFile( - credentialsId: env.PROD_KUBECONFIG_CREDENTIAL_ID, - variable: 'KUBECONFIG') - ]) { - sh 'envsubst < deploy/prod-all-in-one/devops-sample.yaml | kubectl apply -f -' + container('maven') { + input(id: 'deploy-to-production', message: 'deploy to production?') + withCredentials([ + kubeconfigFile( + credentialsId: env.PROD_KUBECONFIG_CREDENTIAL_ID, + variable: 'KUBECONFIG') + ]) { + sh 'envsubst < deploy/prod-all-in-one/devops-sample.yaml | kubectl apply -f -' + } } } } diff --git a/content/en/docs/devops-user-guide/examples/go-project-pipeline.md b/content/en/docs/devops-user-guide/examples/go-project-pipeline.md index aa4786bfd..59ab66dbc 100644 --- a/content/en/docs/devops-user-guide/examples/go-project-pipeline.md +++ b/content/en/docs/devops-user-guide/examples/go-project-pipeline.md @@ -95,12 +95,14 @@ With the above credentials ready, you can create a pipeline using an example Jen } stage ('deploy app') { steps { - withCredentials([ - kubeconfigFile( - credentialsId: env.KUBECONFIG_CREDENTIAL_ID, - variable: 'KUBECONFIG') - ]) { - sh 'envsubst < devops-go-sample/manifest/deploy.yaml | kubectl apply -f -' + container ('go') { + withCredentials([ + kubeconfigFile( + credentialsId: env.KUBECONFIG_CREDENTIAL_ID, + variable: 'KUBECONFIG') + ]) { + sh 'envsubst < devops-go-sample/manifest/deploy.yaml | kubectl apply -f -' + } } } } diff --git a/content/en/docs/devops-user-guide/examples/multi-cluster-project-example.md b/content/en/docs/devops-user-guide/examples/multi-cluster-project-example.md index 825871289..9bc5a1dce 100644 --- a/content/en/docs/devops-user-guide/examples/multi-cluster-project-example.md +++ b/content/en/docs/devops-user-guide/examples/multi-cluster-project-example.md @@ -106,12 +106,14 @@ With the above credentials ready, you can use the user `project-regular` to crea stage('deploy app to multi cluster') { steps { - withCredentials([ - kubeconfigFile( - credentialsId: env.KUBECONFIG_CREDENTIAL_ID, - variable: 'KUBECONFIG') - ]) { - sh 'envsubst < devops-go-sample/manifest/multi-cluster-deploy.yaml | kubectl apply -f -' + container('go') { + withCredentials([ + kubeconfigFile( + credentialsId: env.KUBECONFIG_CREDENTIAL_ID, + variable: 'KUBECONFIG') + ]) { + sh 'envsubst < devops-go-sample/manifest/multi-cluster-deploy.yaml | kubectl apply -f -' + } } } } diff --git a/content/zh/docs/devops-user-guide/examples/a-maven-project.md b/content/zh/docs/devops-user-guide/examples/a-maven-project.md index 72d7b0120..2c411513b 100644 --- a/content/zh/docs/devops-user-guide/examples/a-maven-project.md +++ b/content/zh/docs/devops-user-guide/examples/a-maven-project.md @@ -132,15 +132,17 @@ kubectl get cm -n kubesphere-devops-system ks-devops-agent -o yaml } stage('deploy to dev') { - steps { - withCredentials([ - kubeconfigFile( - credentialsId: env.KUBECONFIG_CREDENTIAL_ID, - variable: 'KUBECONFIG') - ]) { - sh 'envsubst < deploy/all-in-one/devops-sample.yaml | kubectl apply -f -' + steps { + container ('maven') { + withCredentials([ + kubeconfigFile( + credentialsId: env.KUBECONFIG_CREDENTIAL_ID, + variable: 'KUBECONFIG') + ]) { + sh 'envsubst < deploy/all-in-one/devops-sample.yaml | kubectl apply -f -' + } + } } - } } } } diff --git a/content/zh/docs/devops-user-guide/examples/create-multi-cluster-pipeline.md b/content/zh/docs/devops-user-guide/examples/create-multi-cluster-pipeline.md index fdc5fa774..94e8361cd 100644 --- a/content/zh/docs/devops-user-guide/examples/create-multi-cluster-pipeline.md +++ b/content/zh/docs/devops-user-guide/examples/create-multi-cluster-pipeline.md @@ -181,36 +181,42 @@ weight: 11440 } stage('deploy to dev') { steps { - withCredentials([ - kubeconfigFile( - credentialsId: env.DEV_KUBECONFIG_CREDENTIAL_ID, - variable: 'KUBECONFIG') - ]) { - sh 'envsubst < deploy/dev-all-in-one/devops-sample.yaml | kubectl apply -f -' + container('maven') { + withCredentials([ + kubeconfigFile( + credentialsId: env.DEV_KUBECONFIG_CREDENTIAL_ID, + variable: 'KUBECONFIG') + ]) { + sh 'envsubst < deploy/dev-all-in-one/devops-sample.yaml | kubectl apply -f -' + } } } } stage('deploy to staging') { steps { - input(id: 'deploy-to-staging', message: 'deploy to staging?') - withCredentials([ - kubeconfigFile( - credentialsId: env.TEST_KUBECONFIG_CREDENTIAL_ID, - variable: 'KUBECONFIG') - ]) { - sh 'envsubst < deploy/prod-all-in-one/devops-sample.yaml | kubectl apply -f -' + container('maven') { + input(id: 'deploy-to-staging', message: 'deploy to staging?') + withCredentials([ + kubeconfigFile( + credentialsId: env.TEST_KUBECONFIG_CREDENTIAL_ID, + variable: 'KUBECONFIG') + ]) { + sh 'envsubst < deploy/prod-all-in-one/devops-sample.yaml | kubectl apply -f -' + } } } } stage('deploy to production') { steps { - input(id: 'deploy-to-production', message: 'deploy to production?') - withCredentials([ - kubeconfigFile( - credentialsId: env.PROD_KUBECONFIG_CREDENTIAL_ID, - variable: 'KUBECONFIG') - ]) { - sh 'envsubst < deploy/prod-all-in-one/devops-sample.yaml | kubectl apply -f -' + container('maven') { + input(id: 'deploy-to-production', message: 'deploy to production?') + withCredentials([ + kubeconfigFile( + credentialsId: env.PROD_KUBECONFIG_CREDENTIAL_ID, + variable: 'KUBECONFIG') + ]) { + sh 'envsubst < deploy/prod-all-in-one/devops-sample.yaml | kubectl apply -f -' + } } } } diff --git a/content/zh/docs/devops-user-guide/examples/go-project-pipeline.md b/content/zh/docs/devops-user-guide/examples/go-project-pipeline.md index 9d8b13b87..40e6ebba1 100644 --- a/content/zh/docs/devops-user-guide/examples/go-project-pipeline.md +++ b/content/zh/docs/devops-user-guide/examples/go-project-pipeline.md @@ -96,12 +96,14 @@ weight: 11410 stage ('deploy app') { steps { - withCredentials([ - kubeconfigFile( - credentialsId: env.KUBECONFIG_CREDENTIAL_ID, - variable: 'KUBECONFIG') - ]) { - sh 'envsubst < devops-go-sample/manifest/deploy.yaml | kubectl apply -f -' + container ('go') { + withCredentials([ + kubeconfigFile( + credentialsId: env.KUBECONFIG_CREDENTIAL_ID, + variable: 'KUBECONFIG') + ]) { + sh 'envsubst < devops-go-sample/manifest/deploy.yaml | kubectl apply -f -' + } } } } diff --git a/content/zh/docs/devops-user-guide/examples/multi-cluster-project-example.md b/content/zh/docs/devops-user-guide/examples/multi-cluster-project-example.md index d234181d4..79e0e7ba9 100644 --- a/content/zh/docs/devops-user-guide/examples/multi-cluster-project-example.md +++ b/content/zh/docs/devops-user-guide/examples/multi-cluster-project-example.md @@ -106,12 +106,14 @@ weight: 11420 stage('deploy app to multi cluster') { steps { - withCredentials([ - kubeconfigFile( - credentialsId: env.KUBECONFIG_CREDENTIAL_ID, - variable: 'KUBECONFIG') - ]) { - sh 'envsubst < devops-go-sample/manifest/multi-cluster-deploy.yaml | kubectl apply -f -' + container('go') { + withCredentials([ + kubeconfigFile( + credentialsId: env.KUBECONFIG_CREDENTIAL_ID, + variable: 'KUBECONFIG') + ]) { + sh 'envsubst < devops-go-sample/manifest/multi-cluster-deploy.yaml | kubectl apply -f -' + } } } }