List all keep-forever builds in Jenkins?

后端 未结 2 361
無奈伤痛
無奈伤痛 2021-01-02 17:50

Is there an easy way in Jenkins to list all all builds marked as keep-forever? And then, ideally, one click to either unmark the build as keep-forever or to immediately del

2条回答
  •  悲哀的现实
    2021-01-02 18:18

    The following XPath query against Jenkins will list the URLs of all builds marked 'Keep Forever':

    http://[jenkins_server]/api/xml?depth=2&xpath=/hudson/job/build[keepLog="true"]/url&wrapper=forever
    

    Enter it in the browser and see what it returns.

    Now, you can embed it into XSLT-based HTML to get a list with links to those builds. To delete the build you can provide a button that invokes Jenkins CLI:

    java -jar jenkins-cli.jar -s http://[jenkins_server]/ delete-builds [job-name] [build-num]
    

    Unfortunately, I do not know how to disable 'keep build forever' with CLI without deleting it.

提交回复
热议问题