Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-57827] Fix databinding of ContainerTemplate so DescribableModel.uninstantiate2 works #486

Merged
merged 1 commit into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public ContainerTemplate(ContainerTemplate from) {
this.setLivenessProbe(from.getLivenessProbe());
}

@DataBoundSetter
public void setName(String name) {
this.name = name;
}
Expand All @@ -110,7 +109,6 @@ public String getName() {
return name;
}

@DataBoundSetter
public void setImage(String image) {
this.image = image;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,33 @@

package org.csanchez.jenkins.plugins.kubernetes.pipeline;

import com.google.common.base.Predicates;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.*;

import jenkins.plugins.git.GitSampleRepoRule;
import jenkins.plugins.git.GitStep;
import org.jenkinsci.plugins.structs.describable.UninstantiatedDescribable;
import org.jenkinsci.plugins.workflow.actions.ArgumentsAction;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.graphanalysis.DepthFirstScanner;
import org.jenkinsci.plugins.workflow.graphanalysis.FlowScanningUtils;
import org.jenkinsci.plugins.workflow.graphanalysis.NodeStepTypePredicate;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.jvnet.hudson.test.Issue;

public class KubernetesDeclarativeAgentTest extends AbstractKubernetesPipelineTest {

@Rule
public GitSampleRepoRule repoRule = new GitSampleRepoRule();

@Issue("JENKINS-41758")
@Issue({"JENKINS-41758", "JENKINS-57827"})
@Test
public void declarative() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "job with dir");
Expand All @@ -53,6 +61,15 @@ public void declarative() throws Exception {
r.assertLogContains("Apache Maven 3.3.9", b);
r.assertLogContains("INSIDE_CONTAINER_ENV_VAR = " + CONTAINER_ENV_VAR_VALUE + "\n", b);
r.assertLogContains("OUTSIDE_CONTAINER_ENV_VAR = " + CONTAINER_ENV_VAR_VALUE + "\n", b);
FlowNode podTemplateNode = new DepthFirstScanner().findFirstMatch(b.getExecution(), Predicates.and(new NodeStepTypePredicate("podTemplate"), FlowScanningUtils.hasActionPredicate(ArgumentsAction.class)));
assertNotNull("recorded arguments for podTemplate", podTemplateNode);
Map<String, Object> arguments = podTemplateNode.getAction(ArgumentsAction.class).getArguments();
@SuppressWarnings("unchecked")
List<UninstantiatedDescribable> containers = (List<UninstantiatedDescribable>) arguments.get("containers");
assertNotNull(containers);
assertFalse("no junk in arguments: " + arguments, containers.get(0).getArguments().containsKey("alwaysPullImage"));
FlowNode containerNode = new DepthFirstScanner().findFirstMatch(b.getExecution(), Predicates.and(new NodeStepTypePredicate("container"), FlowScanningUtils.hasActionPredicate(ArgumentsAction.class)));
assertNotNull("recorded arguments for container", containerNode);
}

@Issue("JENKINS-48135")
Expand Down