Switched to node builder

This commit is contained in:
Jonathan Ervine 2020-07-20 22:16:51 +08:00
parent 21d71a566d
commit 6e096946fe

55
Jenkinsfile vendored
View File

@ -1,27 +1,34 @@
node("docker-node") { podTemplate(yaml: """
docker.withRegistry('https://harbor.ervine.dev', 'jenkins-to-harbor') { kind: Pod
spec:
git branch: "master", url: "ssh://git@git.ervine.org/jonny/x86_64-alpine-mariadb", credentialsId: 'jenkins-to-git' containers:
- name: kaniko
sh "git rev-parse HEAD > .git/commit-id" image: gcr.io/kaniko-project/executor:debug-539ddefcae3fd6b411a95982a830d987f4214251
def commit_id = readFile('.git/commit-id').trim() imagePullPolicy: Always
println commit_id 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
"""
) {
try { node(POD_LABEL) {
stage "build" stage('Build with Kaniko') {
def app = docker.build "library/x86_64/alpine/mariadb" git url: 'ssh://git@git.ervine.org/jonny/x86_64-alpine-mariadb.git', credentialsId: 'jenkins-to-git'
container('kaniko') {
stage "publish" sh '/kaniko/executor -f `pwd`/Dockerfile -c `pwd` --cache=true --destination=harbor.ervine.dev/library/x86_64/alpine/mariadb:3.12.0 --destination=harbor.ervine.dev/library/x86_64/alpine/mariadb:3.12'
app.push("${env.BUILD_NUMBER}") }
app.push("3.12.0")
app.push("latest")
stage('Deploy on K8s'){
sh "/usr/local/bin/kubectl -n db delete po mariadb-0"
}
}
catch (err) {
currentBuild.result = 'FAILURE'
}
} }
}
} }