diff --git a/Jenkinsfile b/Jenkinsfile index 5f34bf9..4ccfaf3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,13 +9,6 @@ pipeline { agent { kubernetes { cloud "${KUBERNETES_NAME}" - // 增加超时时间为60分钟 - containerTemplate { - name 'docker' - image 'docker:19.03.15-git' - tty true - command 'cat' - } yaml """ apiVersion: v1 kind: Pod @@ -29,33 +22,18 @@ spec: - mountPath: "/etc/localtime" name: "volume-2" readOnly: false - - name: kubectl - image: kubersphere/kubectl:v1.22.0 - imagePullPolicy: IfNotPresent + - name: docker + image: docker:19.03.15-git + command: ['cat'] tty: true volumeMounts: - - mountPath: "/etc/localtime" - name: "volume-2" - readOnly: false - mountPath: "/var/run/docker.sock" name: "volume-docker" readOnly: false - - mountPath: "/.kube/config" - subPath: config - name: "kubeconfig" - readOnly: false volumes: - - name: volume-maven-repo - emptyDir: {} - name: volume-2 hostPath: path: "/usr/share/zoneinfo/Asia/Shanghai" - - name: kubeconfig - secret: - secretName: kubeconfig - items: - - key: config - path: config - name: volume-docker hostPath: path: "/var/run/docker.sock" @@ -63,32 +41,18 @@ spec: } } stages { - stage('Check Kubernetes ENV') { - steps { - container(name: 'kubectl', shell: 'echo') { - sh 'kubectl get pod -A' - } - - } - } - stage('构建镜像及检查kubernetes环境') { - parallel { - stage('构建镜像') { - steps { - withCredentials([usernamePassword(credentialsId: '${DOCKER_REPOSITORY_CREDENTIAL_ID}', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) { - container(name: 'docker', shell: 'echo') { - sh """ - docker build -t ${HARBOR_HOST}/${NAMESPACE_NAME}/${REPOSITORY_NAME}:${TAG} . - docker login ${HARBOR_HOST} --username=${USERNAME} --password=${PASSWORD} - docker push ${HARBOR_HOST}/${NAMESPACE_NAME}/${REPOSITORY_NAME}:${TAG} - """ - } - } + stage('构建镜像') { + steps { + withCredentials([usernamePassword(credentialsId: '${DOCKER_REPOSITORY_CREDENTIAL_ID}', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) { + container('docker') { + sh """ + docker build -t ${HARBOR_HOST}/${NAMESPACE_NAME}/${REPOSITORY_NAME}:${TAG} . + docker login ${HARBOR_HOST} --username ${USERNAME} --password ${PASSWORD} + docker push ${HARBOR_HOST}/${NAMESPACE_NAME}/${REPOSITORY_NAME}:${TAG} + """ } } } } - - } }