This repository has been archived by the owner on Mar 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Jenkinsfile.clean_old_issues
53 lines (46 loc) · 2.44 KB
/
Jenkinsfile.clean_old_issues
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
pipeline {
agent any
triggers { cron('H 12 * * *') }
parameters {
string(name: 'ASSISTED_TEST_INFRA_REMOTE', defaultValue: 'https://github.com/openshift/assisted-test-infra', description: 'assisted-test-infra repo URL to use')
string(name: 'ASSISTED_TEST_INFRA_BRANCH', defaultValue: 'master', description: 'Branch on assisted-test-infra repo to use')
string(name: 'ASSISTED_INSTALLER_DEPLOYMENT_REMOTE', defaultValue: 'https://github.com/openshift-assisted/assisted-installer-deployment', description: 'assisted-installer-deployment repo URL to use')
string(name: 'ASSISTED_INSTALLER_DEPLOYMENT_BRANCH', defaultValue: 'master', description: 'Branch on assisted-installer-deployment repo to use')
string(name: 'LOG_LEVEL', defaultValue: 'DEBUG', description: 'Log level')
string(name: 'DAYS', defaultValue: '180', description: 'Age from which tickets are considered old and will be addressed in days')
string(name: 'ISSUES_LIMIT', defaultValue: '50', description: 'Maximum number of issues to update')
}
environment {
JIRA_ACCESS_TOKEN = credentials('assisted-installer-bot-jira-access-token')
SLACK_TOKEN = credentials('slack-token')
}
stages {
stage('Init') {
steps {
sh "rm -rf assisted-test-infra"
sh "git clone ${ASSISTED_TEST_INFRA_REMOTE} --branch ${ASSISTED_TEST_INFRA_BRANCH}"
dir ('assisted-test-infra') {
sh "scripts/install_environment.sh install_skipper"
}
sh "rm -rf assisted-installer-deployment"
sh "git clone ${ASSISTED_INSTALLER_DEPLOYMENT_REMOTE} --branch ${ASSISTED_INSTALLER_DEPLOYMENT_BRANCH}"
}
}
stage('Delete old issues') {
steps {
dir ('assisted-installer-deployment') {
sh "skipper run clean_old_issues --days ${DAYS} --issues-limit ${ISSUES_LIMIT} --log-level ${LOG_LEVEL} --jira-access-token ${JIRA_ACCESS_TOKEN}"
}
}
}
}
post {
failure {
script {
def data = [text: "Attention! ${BUILD_TAG} job failed, see: ${BUILD_URL}"]
writeJSON(file: 'data.txt', json: data, pretty: 4)
}
sh '''curl -X POST -H 'Content-type: application/json' --data-binary "@data.txt" https://hooks.slack.com/services/${SLACK_TOKEN}'''
}
}
}