Last active
September 13, 2019 11:57
-
-
Save norberttech/5ed327b402e32f8e3d96c9b0ea356509 to your computer and use it in GitHub Desktop.
This file contains 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
node('rundeck-cli') { | |
withCredentials([string(credentialsId: 'rundeck-token', variable: 'RD_TOKEN')]) { | |
stage('Get list of rundeck projects') { | |
try { | |
def projects = sh(returnStdout: true, script: 'rd projects list --outformat "%name"').toString().trim() | |
projects.split().each { | |
sh script: 'rd executions deletebulk -y -m ${RD_OPTION_BATCH:-20} --older ${RD_OPTION_OLDER_THAN:-7d} -p ' + it | |
} | |
} catch (rundeckException) { | |
withCredentials([string(credentialsId: 'google-chat-webhook-jenkins-key', variable: 'KEY'), string(credentialsId: 'google-chat-webhook-jenkins-token', variable: 'TOKEN')]) { | |
try { | |
sh label: '', script: 'curl -s -d \'{"text": "❌ <users/all> can not clean rundeck old job executions"}\' -H "Content-Type: application/json" -X POST https://chat.googleapis.com/v1/spaces/AAAAy16y1KE/messages\\?key\\=${KEY}\\&token\\=${TOKEN} > /dev/null' | |
} catch (notificationException) { | |
echo "Failed to send notification"; | |
} | |
} | |
throw rundeckException | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment