Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Changed my mind - makes more sense as an agent option
  • Loading branch information
abayer committed Sep 28, 2017
1 parent 1c275cd commit a367db7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 87 deletions.
Expand Up @@ -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) {
Expand All @@ -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> {
}
Expand Down

This file was deleted.

Expand Up @@ -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> {
Expand All @@ -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()
Expand All @@ -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, {
Expand Down

This file was deleted.

0 comments on commit a367db7

Please sign in to comment.