1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| def label = "slave-${UUID.randomUUID().toString()}"
podTemplate(label: label, containers: [
containerTemplate(name: 'maven', image: 'maven:3.6-alpine', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'docker', image: 'docker', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'kubectl',image: 'hex/kubectl', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'helm', image: 'hex/helm', command: 'cat', ttyEnabled: true),
], volumes: [
hostPathVolume(mountPath: '/root/.m2', hostPath: '/var/run/m2'),
hostPathVolume(mountPath: '/home/jenkins/.kube', hostPath: '/root/.kube'),
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
]) {
node(label) {
def myRepo = checkout scm
stage('单元测试') { container('maven') { echo "单元测试" } }
stage('编译打包') { container('maven') { echo "编译打包" } }
stage('Docker 镜像'){ container('docker') { echo "构建镜像" } }
stage('Helm 部署') { container('helm') { sh "helm list" } }
}
}
|