Gist to support https://www.youtube.com/watch?v=vMlUVDcriww
- https://github.com/GoogleContainerTools/kaniko
- https://docs.cloudbees.com/docs/cloudbees-ci/latest/cloud-admin-guide/using-kaniko
kubectl create secret docker-registry docker-credentials --docker-username=[userid] --docker-password=[Docker Hub access token] --docker-email=[user email address] --namespace jenkins
pipeline {
agent {
kubernetes {
yaml """
kind: Pod
spec:
containers:
- name: kaniko
image: gcr.io/kaniko-project/executor:debug
imagePullPolicy: Always
command:
- sleep
args:
- 9999999
volumeMounts:
- name: jenkins-docker-cfg
mountPath: /kaniko/.docker
volumes:
- name: jenkins-docker-cfg
projected:
sources:
- secret:
name: docker-credentials
items:
- key: .dockerconfigjson
path: config.json
"""
}
}
stages {
stage('Build with Kaniko') {
steps {
container(name: 'kaniko', shell: '/busybox/sh') {
sh '''#!/busybox/sh
echo "FROM jenkins/inbound-agent:latest" > Dockerfile
/kaniko/executor --context `pwd` --destination darinpope/hello-kaniko:latest
'''
}
}
}
}
}