Skip to content
Permalink
Browse files

Changed my mind - makes more sense as an agent option

  • Loading branch information...
abayer committed Sep 28, 2017
1 parent 1c275cd commit a367db7c2a727e5ea87381777b72b4c84b52f1a2
@@ -29,11 +29,13 @@
import org.jenkinsci.plugins.pipeline.modeldefinition.agent.AbstractDockerAgent;
import org.jenkinsci.plugins.pipeline.modeldefinition.agent.DeclarativeAgentDescriptor;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

import javax.annotation.Nonnull;

public class DockerPipeline extends AbstractDockerAgent<DockerPipeline> {
private String image;
private boolean alwaysDoPull;

@DataBoundConstructor
public DockerPipeline(@Nonnull String image) {
@@ -44,6 +46,15 @@ public DockerPipeline(@Nonnull String image) {
return image;
}

@DataBoundSetter
public void setAlwaysDoPull(boolean alwaysDoPull) {
this.alwaysDoPull = alwaysDoPull;
}

public boolean isAlwaysDoPull() {
return alwaysDoPull;
}

@Extension(ordinal = 1000) @Symbol("docker")
public static class DescriptorImpl extends DeclarativeAgentDescriptor<DockerPipeline> {
}

This file was deleted.

@@ -27,7 +27,7 @@ package org.jenkinsci.plugins.pipeline.modeldefinition.agent.impl

import org.jenkinsci.plugins.pipeline.modeldefinition.SyntheticStageNames
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
import org.jenkinsci.plugins.pipeline.modeldefinition.options.impl.AlwaysDoDockerPull

import org.jenkinsci.plugins.workflow.cps.CpsScript

public class DockerPipelineScript extends AbstractDockerPipelineScript<DockerPipeline> {
@@ -38,9 +38,8 @@ public class DockerPipelineScript extends AbstractDockerPipelineScript<DockerPip

@Override
public Closure runImage(Closure body) {
boolean alwaysDoDockerPull = describable.getOption(AlwaysDoDockerPull)?.alwaysDoDockerPull
return {
if (!Utils.withinAStage() && alwaysDoDockerPull) {
if (!Utils.withinAStage()) {
script.stage(SyntheticStageNames.agentSetup()) {
try {
script.getProperty("docker").image(describable.image).pull()
@@ -52,7 +51,7 @@ public class DockerPipelineScript extends AbstractDockerPipelineScript<DockerPip
}
}
try {
if (Utils.withinAStage() && alwaysDoDockerPull) {
if (Utils.withinAStage() && describable.alwaysDoPull) {
script.getProperty("docker").image(describable.image).pull()
}
script.getProperty("docker").image(describable.image).inside(describable.args, {

This file was deleted.

0 comments on commit a367db7

Please sign in to comment.
You can’t perform that action at this time.