更新 'Jenkinsfile'

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

108
Jenkinsfile vendored

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

Loading…
Cancel
Save