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.download_logs
79 lines (69 loc) · 3.45 KB
/
Jenkinsfile.download_logs
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
pipeline {
agent { label 'download_logs' }
parameters {
string(name: 'REMOTE_SERVICE_URL', defaultValue: 'https://api.openshift.com', description: 'Service URL')
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: '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')
choice(name: 'SIGNATURES_SOURCE', choices: ['logs_server', 'jira'], description: 'Signatures will get created from the specified data source')
booleanParam(name: 'DRY_RUN', defaultValue: false, description: 'Flag to determine whether to run in dry run mode')
}
triggers { cron('H/30 * * * *') }
environment {
SKIPPER_PARAMS = " "
SIGNATURES_SOURCE = "${params.SIGNATURES_SOURCE}"
LOGS_DEST = "/var/ai-logs/triage_logs"
// Credentials
OFFLINE_TOKEN = credentials('admin_offline_token')
JIRA_ACCESS_TOKEN = credentials('assisted-installer-bot-jira-access-token')
SLACK_TOKEN = credentials('slack-token')
PULL_SECRET_CONTENTS = credentials('prod-pull-secret-text')
}
options {
timeout(time: 90, unit: 'MINUTES')
}
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 "make image_build"
}
sh "rm -rf assisted-installer-deployment"
sh "git clone ${ASSISTED_INSTALLER_DEPLOYMENT_REMOTE} --branch ${ASSISTED_INSTALLER_DEPLOYMENT_BRANCH}"
}
}
stage('Cluster-logs') {
steps {
dir ('assisted-test-infra') {
sh "make download_cluster_logs"
}
dir ('assisted-installer-deployment') {
sh "skipper run ./tools/triage/attach_logs_in_jira.py --source-dir ${LOGS_DEST} --jira-access-token ${JIRA_ACCESS_TOKEN} --verbose"
}
}
}
stage('Create tickets') {
steps {
dir ('assisted-installer-deployment') {
script {
def dryRunFlag = params.DRY_RUN ? '--dry-run' : ''
sh "skipper run -e PULL_SECRET_CONTENTS -e SIGNATURES_SOURCE ./tools/triage/create_triage_tickets.py --jira-access-token ${JIRA_ACCESS_TOKEN} -v ${dryRunFlag}"
}
}
}
}
}
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}'''
}
}
}