更新 'Jenkinsfile'

main
newrain001 9 months ago
parent b237c68d03
commit 6490394c24
  1. 108
      Jenkinsfile

108
Jenkinsfile vendored

@ -17,52 +17,52 @@ apiVersion: v1
kind: Pod kind: Pod
spec: spec:
containers: containers:
- name: jnlp - name: jnlp
image: jenkins/inbound-agent:3107.v665000b_51092-15 image: jenkins/inbound-agent:3107.v665000b_51092-15
args: ['\$(JENKINS_SECRET)', '\$(JENKINS_NAME)'] args: ['\$(JENKINS_SECRET)', '\$(JENKINS_NAME)']
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
volumeMounts: volumeMounts:
- mountPath: "/etc/localtime" - mountPath: "/etc/localtime"
name: "volume-2" name: "volume-2"
readOnly: false readOnly: false
- name: kubectl - name: kubectl
image: kubesphere/kubectl:v1.22.0 image: kubesphere/kubectl:v1.22.0
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
tty: true tty: true
command: ["cat"] command: ["cat"]
volumeMounts: volumeMounts:
- mountPath: "/etc/localtime" - mountPath: "/etc/localtime"
name: "volume-2" name: "volume-2"
readOnly: false readOnly: false
- mountPath: "/var/run/docker.sock" - mountPath: "/var/run/docker.sock"
name: "volume-docker" name: "volume-docker"
readOnly: false readOnly: false
- mountPath: "/root/.kube/config" - mountPath: "/root/.kube/config"
subPath: config subPath: config
name: "kubeconfig" name: "kubeconfig"
readOnly: false readOnly: false
- name: docker - name: docker
image: docker:19.03.15-git image: docker:19.03.15-git
command: ['cat'] command: ['cat']
tty: true tty: true
volumeMounts: volumeMounts:
- mountPath: "/var/run/docker.sock" - mountPath: "/var/run/docker.sock"
name: "volume-docker" name: "volume-docker"
readOnly: false readOnly: false
volumes: volumes:
- name: volume-2 - name: volume-2
hostPath: hostPath:
path: "/usr/share/zoneinfo/Asia/Shanghai" path: "/usr/share/zoneinfo/Asia/Shanghai"
- name: volume-docker - name: volume-docker
hostPath: hostPath:
path: "/var/run/docker.sock" path: "/var/run/docker.sock"
- name: kubeconfig - name: kubeconfig
secret: secret:
secretName: kubeconfig secretName: kubeconfig
items: items:
- key: config - key: config
path: config path: config
""" """
} }
} }
stages { stages {
@ -77,7 +77,8 @@ spec:
""" """
} }
} }
post { }
post {
failure { failure {
dingtalk ( dingtalk (
robot: '4eabbd09-a21a-40a9-84db-6440c0daebec', robot: '4eabbd09-a21a-40a9-84db-6440c0daebec',
@ -98,14 +99,14 @@ spec:
} }
} }
} }
}
stage('部署到kubernetes') { stage('部署到kubernetes') {
steps { steps {
container('kubectl') { container('kubectl') {
sh """ sh """
sed -i "s/REPLICAS/${env.REPLICAS}/;s/HARBOR_HOST/${env.HARBOR_HOST}/;s/NAMESPACE_NAME/${env.NAMESPACE_NAME}/;s/REPOSITORY_NAME/${env.REPOSITORY_NAME}/;s/TAG/${env.TAG}/" ${env.YAML_PATH}${env.DEPLOYMENT_NAME} sed -i "s/REPLICAS/${env.REPLICAS}/;s/HARBOR_HOST/${env.HARBOR_HOST}/;s/NAMESPACE_NAME/${env.NAMESPACE_NAME}/;s/REPOSITORY_NAME/${env.REPOSITORY_NAME}/;s/TAG/${env.TAG}/" ${env.YAML_PATH}${env.DEPLOYMENT_NAME}
kubectl apply -f ${env.YAML_PATH} kubectl apply -f ${env.YAML_PATH}
""" """
}
} }
post { post {
failure { failure {
@ -127,7 +128,6 @@ spec:
) )
} }
} }
}
} }
} }
} }

Loading…
Cancel
Save