From e4e928dd0d96a8754669d4993558f4692d39f622 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Mon, 30 Mar 2015 12:12:20 -0400 Subject: [PATCH] [JENKINS-27474] Noting a few places where fileExists would be useful. --- TUTORIAL.md | 2 +- .../jenkinsci/plugins/workflow/steps/scm/MercurialStepTest.java | 2 +- .../java/org/jenkinsci/plugins/workflow/steps/ReadFileStep.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TUTORIAL.md b/TUTORIAL.md index 151bb1202..2498f467e 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -420,7 +420,7 @@ Here we are using the `def` keyword to define a function (you can also give a Ja The `readFile` step loads a text file from the workspace and returns its content. (Do _not_ try to use `java.io.File` methods, because these will refer to files on the master where Jenkins is running, not in the current workspace.) -There is also a `writeFile` step to save content to a text file in the workspace. +There is also a `writeFile` step to save content to a text file in the workspace, and a `fileExists` step to check whether a file exists without loading it. When you run the flow you should see diff --git a/aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/scm/MercurialStepTest.java b/aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/scm/MercurialStepTest.java index bcb12570c..a1f94f102 100644 --- a/aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/scm/MercurialStepTest.java +++ b/aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/scm/MercurialStepTest.java @@ -90,7 +90,7 @@ private static void hg(File repo, String... cmds) throws Exception { " }\n" + " dir('other') {\n" + " checkout([$class: 'MercurialSCM', source: $/" + otherRepoU + "/$, clean: true])\n" + - " try {\n" + + " try {\n" + // TODO or use fileExists " readFile 'unversioned'\n" + " error 'unversioned did exist'\n" + " } catch (FileNotFoundException x) {\n" + diff --git a/basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/ReadFileStep.java b/basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/ReadFileStep.java index 2cb499648..537af1a44 100644 --- a/basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/ReadFileStep.java +++ b/basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/ReadFileStep.java @@ -43,7 +43,7 @@ public final class ReadFileStep extends AbstractStepImpl { // Could be necessary in case a plugin installs a {@link LauncherDecorator} which keeps commands inside some kind of jail. // In that case we would need some API to determine that such a jail is in effect and this validation must be enforced. // But just checking the path is anyway not sufficient (due to crafted symlinks); would need to check the final resulting path. - // Same for WriteFileStep, PushdStep. + // Same for WriteFileStep, PushdStep, FileExistsStep. this.file = file; }