Using node builder

This commit is contained in:
Jonathan Ervine 2020-07-20 15:23:51 +08:00
parent 5e81cc8df5
commit 866ea167bc

57
Jenkinsfile vendored
View File

@ -1,27 +1,36 @@
node("docker-node") { podTemplate(yaml: """
docker.withRegistry('https://harbor.ervine.dev', 'jenkins-to-harbor') { kind: Pod
spec:
containers:
- name: kaniko
image: gcr.io/kaniko-project/executor:debug-539ddefcae3fd6b411a95982a830d987f4214251
imagePullPolicy: Always
command:
- /busybox/cat
tty: true
volumeMounts:
- name: jenkins-docker-cfg
mountPath: /kaniko/.docker
volumes:
- name: jenkins-docker-cfg
projected:
sources:
- secret:
name: regcred
items:
- key: .dockerconfigjson
path: config.json
"""
) {
git branch: "master", url: "ssh://git@git.ervine.org/jonny/x86_64-debian-bedrock", credentialsId: 'jenkins-to-git' node(POD_LABEL) {
stage('Build with Kaniko') {
sh "git rev-parse HEAD > .git/commit-id" git url: 'ssh://git@git.ervine.org/jonny/x86_64-debian-bedrock.git', credentialsId: 'jenkins-to-git'
def commit_id = readFile('.git/commit-id').trim() container('kaniko') {
println commit_id sh '/kaniko/executor -f `pwd`/Dockerfile -c `pwd` --cache=true --destination=harbor.ervine.dev/library/x86_64/debian/bedrock:latest --destination=harbor.ervine.dev/library/x86_64/debian/bedrock:1.16.1.02'
}
try {
stage "build"
def app = docker.build "library/x86_64/debian/bedrock"
stage "publish"
app.push("${env.BUILD_NUMBER}")
app.push("1.16.02")
app.push("latest")
stage('Deploy on K8s'){
sh "/usr/local/bin/kubectl -n games delete po bedrock-0"
}
}
catch (err) {
currentBuild.result = 'FAILURE'
}
} }
}
} }