Skip to content

Commit

Permalink
[JENKINS-27474] Noting a few places where fileExists would be useful.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Mar 30, 2015
1 parent 205f27b commit e4e928d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit e4e928d

Please sign in to comment.