-
Notifications
You must be signed in to change notification settings - Fork 4
/
Jenkinsfile
139 lines (124 loc) · 5.35 KB
/
Jenkinsfile
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!groovy
retry (10) {
// load pipeline configuration into the environment
httpRequest("${FEDORA_CI_PIPELINES_CONFIG_URL}/environment").content.split('\n').each { l ->
l = l.trim(); if (l && !l.startsWith('#')) { env["${l.split('=')[0].trim()}"] = "${l.split('=')[1].trim()}" }
}
}
def pipelineMetadata = [
pipelineName: 'rpmdeplint',
pipelineDescription: 'Finding errors in RPM packages in the context of their dependency graph',
testCategory: 'functional',
testType: 'rpmdeplint',
maintainer: 'Fedora CI',
docs: 'https://docs.fedoraproject.org/en-US/ci/generic_tests/#_rpmdeplint',
contact: [
irc: '#fedora-ci',
email: '[email protected]'
],
]
def artifactId
def additionalArtifactIds
def testingFarmRequestId
def testingFarmResult
def pipelineRepoUrlAndRef
def hook
def runUrl
pipeline {
agent none
libraries {
lib("fedora-pipeline-library@${env.PIPELINE_LIBRARY_VERSION}")
}
options {
buildDiscarder(logRotator(daysToKeepStr: env.DEFAULT_DAYS_TO_KEEP_LOGS, artifactNumToKeepStr: env.DEFAULT_ARTIFACTS_TO_KEEP))
timeout(time: env.DEFAULT_PIPELINE_TIMEOUT_MINUTES, unit: 'MINUTES')
skipDefaultCheckout(true)
}
parameters {
string(name: 'ARTIFACT_ID', defaultValue: '', trim: true, description: '"koji-build:<taskId>" for Koji builds; Example: koji-build:46436038')
string(name: 'ADDITIONAL_ARTIFACT_IDS', defaultValue: '', trim: true, description: 'A comma-separated list of additional ARTIFACT_IDs')
}
environment {
TESTING_FARM_API_KEY = credentials('testing-farm-api-key')
}
stages {
stage('Prepare') {
agent {
label pipelineMetadata.pipelineName
}
steps {
script {
artifactId = params.ARTIFACT_ID
additionalArtifactIds = params.ADDITIONAL_ARTIFACT_IDS
setBuildNameFromArtifactId(artifactId: artifactId)
if (!artifactId) {
abort('ARTIFACT_ID is missing')
}
checkout scm
pipelineRepoUrlAndRef = [url: "${getGitUrl()}", ref: "${getGitRef()}"]
}
sendMessage(type: 'queued', artifactId: artifactId, additionalArtifactIds: additionalArtifactIds, pipelineMetadata: pipelineMetadata, dryRun: isPullRequest())
}
}
stage('Schedule Test') {
agent {
label pipelineMetadata.pipelineName
}
steps {
script {
def requestPayload = [
api_key: "${env.TESTING_FARM_API_KEY}",
test: [
fmf: pipelineRepoUrlAndRef
],
environments: [
[
arch: "x86_64",
variables: [
RELEASE_ID: "${getReleaseIdFromBranch()}",
TASK_ID: "${getIdFromArtifactId(artifactId: artifactId, additionalArtifactIds: additionalArtifactIds)}"
]
]
]
]
hook = registerWebhook()
requestPayload['notification'] = ['webhook': [url: hook.getURL()]]
def response = submitTestingFarmRequest(payloadMap: requestPayload)
testingFarmRequestId = response['id']
}
sendMessage(type: 'running', artifactId: artifactId, additionalArtifactIds: additionalArtifactIds, pipelineMetadata: pipelineMetadata, dryRun: isPullRequest())
}
}
stage('Wait for Test Results') {
agent none
steps {
script {
def response = waitForTestingFarm(requestId: testingFarmRequestId, hook: hook)
testingFarmResult = response.apiResponse
runUrl = "${FEDORA_CI_TESTING_FARM_ARTIFACTS_URL}/${testingFarmRequestId}"
}
}
}
}
post {
always {
evaluateTestingFarmResults(testingFarmResult)
}
aborted {
script {
if (isTimeoutAborted(timeout: env.DEFAULT_PIPELINE_TIMEOUT_MINUTES, unit: 'MINUTES')) {
sendMessage(type: 'error', artifactId: artifactId, additionalArtifactIds: additionalArtifactIds, errorReason: 'Timeout has been exceeded, pipeline aborted.', pipelineMetadata: pipelineMetadata, runUrl: runUrl, dryRun: isPullRequest())
}
}
}
success {
sendMessage(type: 'complete', artifactId: artifactId, additionalArtifactIds: additionalArtifactIds, pipelineMetadata: pipelineMetadata, runUrl: runUrl, dryRun: isPullRequest())
}
failure {
sendMessage(type: 'error', artifactId: artifactId, additionalArtifactIds: additionalArtifactIds, pipelineMetadata: pipelineMetadata, runUrl: runUrl, dryRun: isPullRequest())
}
unstable {
sendMessage(type: 'complete', artifactId: artifactId, additionalArtifactIds: additionalArtifactIds, pipelineMetadata: pipelineMetadata, runUrl: runUrl, dryRun: isPullRequest())
}
}
}