jenkins declarative pipeline using docker agent

126 views
Skip to first unread message

Young Lee

unread,
Sep 2, 2017, 6:30:09 PM9/2/17
to Jenkins Developers
Hi,

Our team is using Jenkins declarative pipeline with docker agent as a CI job.

The behavior appears to be that the docker agent setup is always attempts to pull the latest image from the docker registry.

Is it possible to disable this check and always use the cached image from the local docker image repo?

I checked the source code and it appears that the logic is always to pull the image from the docker registry.

Can someone with more insight and experience with the declarative pipeline confirm?  Also if we want to add the feature to disable this check based on jenkins configuration property, can someone provide guidance on what needs to be done?

Thanx in advance.



public class DockerPipelineScript extends AbstractDockerPipelineScript<DockerPipeline> {

public DockerPipelineScript(CpsScript s, DockerPipeline a) {
super(s, a)
}

@Override
public Closure runImage(Closure body) {
return {
if (!Utils.withinAStage()) {
script.stage(SyntheticStageNames.agentSetup()) {
try {
script.getProperty("docker").image(describable.image).pull()
} catch (Exception e) {
script.getProperty("currentBuild").result = Utils.getResultFromException(e)
Utils.markStageFailedAndContinued(SyntheticStageNames.agentSetup())
throw e
}
}
}
try {
if (Utils.withinAStage()) {
script.getProperty("docker").image(describable.image).pull()
}
script.getProperty("docker").image(describable.image).inside(describable.args, {
body.call()
})
} catch (Exception e) {
script.getProperty("currentBuild").result = Utils.getResultFromException(e)
throw e
}
}
}
}

Jesse Glick

unread,
Sep 5, 2017, 5:59:55 PM9/5/17
to Jenkins Dev
Just specify a tag and no network operation should be required once it is cached.

This is a users’ list question I think.
Reply all
Reply to author
Forward
0 new messages