I see that there is some documentation on using Docker through Jenkins Pipelines here: https://www.jenkins.io/doc/book/pipeline/docker/
They have an example for building a Docker image:
node {
checkout scm
def customImage = docker.build("my-image:${env.BUILD_ID}")
customImage.inside {
sh 'make test'
}
}
But I was unable to find the complete list (with examples) of Docker commands supported. Here's some places I've looked:
- https://plugins.jenkins.io/docker-workflow/
- https://github.com/jenkinsci/docker-workflow-plugin/
- https://docs.cloudbees.com/docs/admin-resources/latest/plugins/docker-workflow
What I was looking to do is docker save
. Does anyone know if something like this is supported, or where it might be documented:
// Tar ball or filename path
def imageTar = docker.save("${ImageFileName}.tar", "${ProjectImage}:${ProjectRelease}")
CodePudding user response:
The commands under the docker
keyword are made available by the Docker Pipeline Plugin which is usually installed by default with Jenkins. The full documentation of the plugin is available Here.
In addition because this plugin adds methods as global variables (which are available in Pipeline directly, not as steps) you can see the available options, which are based on the version of the plugin you have installed, in the Global Variable Reference documentation within your Jenkins instance. There are two ways to reach it:
- Navigate to: [JENKINS_URL]/pipeline-syntax/globals
- Go to one of your pipeline jobs, on the left menu click on the Pipeline Syntax link, then on the left menu select Global Variable Reference
Search for the docker section and you will see all available options.
Back to your original question - it seems that this plugin currently does not support the save command. it only supports tag, push, pull and run (of all kinds).
If you find it useful you can open a feature request in the plugin's Report an issue (Jira) page asking that they add this new capability.