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

Test and fix for missing ArgumentsAction string inside a stage #195

Merged
merged 1 commit into from
Dec 20, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.18</version>
<version>2.24</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand Down Expand Up @@ -272,6 +272,12 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>pipeline-stage-step</artifactId>
<version>2.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public static boolean isStringSafe(@CheckForNull String input, @CheckForNull Env
"JOB_URL",
"NODE_LABELS",
"NODE_NAME",
"STAGE_NAME",
"WORKSPACE",

// Normal system variables for posix environments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import hudson.XmlFile;
import hudson.model.Action;
import hudson.tasks.ArtifactArchiver;
import jenkins.model.Jenkins;
import org.apache.commons.lang.RandomStringUtils;
import org.jenkinsci.plugins.credentialsbinding.impl.BindingStep;
import org.jenkinsci.plugins.workflow.actions.ArgumentsAction;
import org.jenkinsci.plugins.workflow.actions.StageAction;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.cps.CpsFlowExecution;
import org.jenkinsci.plugins.workflow.cps.CpsThread;
Expand All @@ -38,13 +40,17 @@
import org.jenkinsci.plugins.workflow.testMetaStep.Oregon;
import org.jenkinsci.plugins.workflow.testMetaStep.StateMetaStep;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import static org.hamcrest.Matchers.*;
import org.jvnet.hudson.test.BuildWatcher;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;

import java.lang.annotation.Target;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
Expand Down Expand Up @@ -208,6 +214,31 @@ public void testRecursiveSanitizationOfContent() {
Assert.assertEquals(unsanitizedList, impl.sanitizeListAndRecordMutation(unsanitizedList, new EnvVars()));
}

@Test
@Issue("JENKINS-48644")
public void testMissingDescriptionInsideStage() throws Exception {
Assume.assumeTrue(r.jenkins.getComputer("").isUnix()); // No need for windows-specific testing
WorkflowJob j = r.jenkins.createProject(WorkflowJob.class, "HiddenStep");
j.setDefinition(new CpsFlowDefinition("node{\n" +
" stage ('Build') {\n" +
" sh \"echo 'Building'\"\n" +
" }\n" +
" stage ('Test') {\n" +
" sh \"echo 'testing'\"\n" +
" }\n" +
" stage ('Deploy') {\n" +
" sh \"echo 'deploy'\"\n" +
" }\n" +
"}\n", true));
WorkflowRun run = r.buildAndAssertSuccess(j);
List<FlowNode> nodes = new LinearScanner().filteredNodes(run.getExecution(), new NodeStepTypePredicate("sh"));
for (FlowNode f : nodes) {
if (ArgumentsAction.getStepArgumentsAsString(f) == null) {
Assert.fail("No arguments action for node: "+f.toString());
}
}
}

@Test
public void testBasicCreateAndMask() throws Exception {
HashMap<String,String> passwordBinding = new HashMap<String,String>();
Expand Down