Reading file from Workspace in Jenkins with Groovy script

前端 未结 7 1572
广开言路
广开言路 2020-11-30 04:12

I want to add a Build step with the Groovy plugin to read a file and trigger a build fail depending on the content of the file.

How can I inject the workspace file p

7条回答
  •  不知归路
    2020-11-30 04:27

    Based on your comments, you would be better off with Text-finder plugin.

    It allows to search file(s), as well as console, for a regular expression and then set the build either unstable or failed if found.

    As for the Groovy, you can use the following to access ${WORKSPACE} environment variable:
    def workspace = manager.build.getEnvVars()["WORKSPACE"]

提交回复
热议问题