Created
August 2, 2024 08:34
-
-
Save Storager/eebd6a16202f76ce5eb3c535871feb7a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pipeline { | |
| agent any | |
| parameters { | |
| string(name:'commitHash', defaultValue: '5a24fd961fcb1027981d38a6ed2aa5e654ea6ea2', description: 'Commit to delete' ) | |
| } | |
| stages { | |
| stage ('eraser - Build') { | |
| steps { | |
| // Shell build step | |
| withCredentials([string(credentialsId: 'bb-request-token', variable: 'TOKEN')]) { | |
| sh ''' | |
| echo $commitHash | |
| #5a24fd961fcb1027981d38a6ed2aa5e654ea6ea2 | |
| sleep 10 | |
| for i in `curl -s --header "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -X GET http://<change_url>/rest/build-status/1.0/commits/$commitHash | jq -r '.values[].key'` | |
| do | |
| curl -s --header "Authorization: Bearer $TOKEN" \ | |
| -X DELETE --url http://<change_url>/rest/api/latest/projects/TEST/repos/test01/commits/$commitHash/builds?key=\$i \ | |
| -v --header 'Accept: application/json' | |
| done | |
| ''' | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment