Post-build Action: What syntax to use to specify a file to search

Jenkins: 2.401.2
OS: Windows 10 - 10.0
Java: 11.0.19 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)



Whilst Ive been a “user” of Jenkins for sometime, this is the first time Ive tried anything beyond basic launching of jobs through Freestyle projects

I have a new requirement to change the status of a build based on the presence of a string in a log file created by the job.

I found the plugin “text-finder” which is perfect for my needs, but Im running into a problem with the correct syntax to specify the location of the file to search post-build.

If the file is in the workspace directory, or a subfolder within it, then the post-build action is doing exactly what I want. However, the file I need to search is in a folder above the workspace directory, so I need to specify a different path for the search file. Ive tried using …/…/ to move up levels, but the post-build task isnt accepting this syntax (it reports in the console that the specified file isnt present).

The path to the file to search must be specified relative to the workspace root:

This is from the text-finder help " Specify the path to the files to search, relative to the workspace root. This can use wildcards like logs/**/*/*.txt . See the documentation for the @includes attribute of the Ant FileSet type for details."

i.e. this works if the file is in a subfolder: /subfolder1/subfolder2/logs/*.txt

but this doesn’t work: …/…/…/subfolderA/subfolderB/logs/*.txt

Any suggestions are greatly appreciated. Im very close to having this plugin work for me

I would ask myself: if the job creates the log file, why isn’t the log file part of the workspace?
Is there maybe an option in the tool creating the log that you can specify which makes it write the log to a location under the workspace.
Being part of the workspace would mean better separation between concurrent builds in case you have more than one executor on your agent.

Thanks for your feedback @mawinter69 . As I was writing the post, I was starting to ask myself the same question. As a newcomer to configuring jobs in Jenkins, Id set up a Jenkins server of my own, to use as a sandbox, rather than fiddle around with our main CI build server. When I was setting up Jenkins locally, I didnt give too much thought to the workspace location, which, as it turns out, is completely different to the location used for the codebase repo, hence why the log files are not located under the workspace. Setting an appropriate workspace location is the obvious solution to my problem. Thanks