Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How to groovy list files on a jenkins workspace?


Asked by Louise Booker on Dec 04, 2021 Groovy



I'm tagging it @NonCPS because it's required for groovy closures on Pipeline, which I'd really prefer to use over full java <1.8 syntax. For pwd you can use pwd step. As for list of files in main workspace dir you could use findFiles:
Just so,
As for the Groovy, you can use the following to access ${WORKSPACE}environment variable: def workspace = manager.build.getEnvVars()["WORKSPACE\
In respect to this, This plugin deletes the build workspace. There is a single step to be used whenever a workspace is allocated. The cleanWs step is available for use with Declarative Pipeline. When you want to clean the workspace after the build, you can add this step under a suitable condition in the post section of your Pipeline job.
Next,
If you are trying to read a file from the workspace during a pipeline build step, there's a method for that: readFile('name-of-file.groovy') For reference, see https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#readfile-read-file-from-workspace. Share Improve this answer Follow edited Dec 3 '18 at 21:12 jxramos
Also,
Specify what is deleted from projects that include a P4Groovy cleanup step or a P4Groovy delete job. From the Jenkins home page browse to Manage Jenkins > Configure System > Perforce: OnDelete Workspace Options: Delete Perforce client: only applicable when deleting a Jenkins job.