Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[FIXED JENKINS-48138] Log a warning when fileExists called with empty…
… string
- Loading branch information
Showing
with
43 additions
and 3 deletions.
- +2 −1 pom.xml
- +5 −0 src/main/java/org/jenkinsci/plugins/workflow/steps/FileExistsStep.java
- +2 −1 src/main/resources/org/jenkinsci/plugins/workflow/steps/Messages.properties
- +2 −1 src/test/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStepTest.java
- +32 −0 src/test/java/org/jenkinsci/plugins/workflow/steps/FileExistsStepTest.java
@@ -1,3 +1,4 @@ | ||
ArtifactArchiverStepExecution.Deprecated=The 'archive' step is deprecated, please use 'archiveArtifacts' instead." | ||
ArtifactArchiverStepExecution.NoFiles=No files found to archive for pattern "{0}", continuing. | ||
ArtifactArchiverStepExecution.NoFilesWithExcludes=No files found to archive for pattern "{0}", excluding "{1}", continuing. | ||
ArtifactArchiverStepExecution.NoFilesWithExcludes=No files found to archive for pattern "{0}", excluding "{1}", continuing. | ||
FileExistsStep.EmptyString=The 'fileExists' step was called with '', the empty string, so the current directory will be checked instead. |
@@ -0,0 +1,32 @@ | ||
package org.jenkinsci.plugins.workflow.steps; | ||
|
||
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowJob; | ||
import org.junit.ClassRule; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runners.model.Statement; | ||
import org.jvnet.hudson.test.BuildWatcher; | ||
import org.jvnet.hudson.test.Issue; | ||
import org.jvnet.hudson.test.RestartableJenkinsRule; | ||
|
||
public class FileExistsStepTest { | ||
|
||
@ClassRule | ||
public static BuildWatcher buildWatcher = new BuildWatcher(); | ||
@Rule | ||
public RestartableJenkinsRule story = new RestartableJenkinsRule(); | ||
|
||
@Issue("JENKINS-48138") | ||
@Test | ||
public void emptyStringWarning() { | ||
story.addStep(new Statement() { | ||
@Override | ||
public void evaluate() throws Throwable { | ||
WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "p"); | ||
p.setDefinition(new CpsFlowDefinition("node { fileExists('') }", true)); | ||
story.j.assertLogContains(Messages.FileExistsStep_EmptyString(), story.j.buildAndAssertSuccess(p)); | ||
} | ||
}); | ||
} | ||
} |