forked from jenkinsci/kubernetes-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example building a docker image with Kaniko (jenkinsci#312)
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
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} | ||
} | ||
} | ||
} |