Skip to content

Commit

Permalink
Example building a docker image with Kaniko (jenkinsci#312)
Browse files Browse the repository at this point in the history
The docker-registry secret type crates a .dockercfg file that needs to be put in root

It does not create the new .docker/config.json format
  • Loading branch information
carlossg authored and MattLud committed May 25, 2018
1 parent 7328a7d commit d4ae089
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions examples/kaniko.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* This pipeline will build and deploy a Docker image with Kaniko
* https://github.com/GoogleContainerTools/kaniko
* without needing a Docker host
*
* You need to create a jenkins-docker-cfg secret with your docker config
* as described in
* https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-in-the-cluster-that-holds-your-authorization-token
*/

def label = "kaniko-${UUID.randomUUID().toString()}"

podTemplate(name: 'kaniko', label: label, yaml: """
kind: Pod
metadata:
name: kaniko
spec:
containers:
- name: kaniko
image: csanchez/kaniko:jenkins # we need a patched version of kaniko for now
imagePullPolicy: Always
command:
- cat
tty: true
volumeMounts:
- name: jenkins-docker-cfg
mountPath: /root
volumes:
- name: jenkins-docker-cfg
secret:
secretName: regcred
"""
) {

node(label) {
stage('Build with Kaniko') {
git 'https://github.com/jenkinsci/docker-jnlp-slave.git'
container('kaniko') {
sh '/kaniko/executor -c . --insecure-skip-tls-verify --destination=mydockerregistry:5000/myorg/myimage'
}
}
}
}

0 comments on commit d4ae089

Please sign in to comment.