forked from nemerosa/ontrack-jenkins-cli-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathontrackCliValidateCHML.groovy
73 lines (63 loc) · 2.15 KB
/
ontrackCliValidateCHML.groovy
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
import net.nemerosa.ontrack.jenkins.pipeline.utils.ParamUtils
import net.nemerosa.ontrack.jenkins.pipeline.validate.Validation
import net.nemerosa.ontrack.jenkins.pipeline.graphql.GraphQL
def call(Map<String, ?> params = [:]) {
boolean logging = ParamUtils.getLogging(params, env.ONTRACK_LOGGING)
int critical = ParamUtils.getIntParam(params, "critical", 0)
int high = ParamUtils.getIntParam(params, "high", 0)
int medium = ParamUtils.getIntParam(params, "medium", 0)
int low = ParamUtils.getIntParam(params, "low", 0)
// GraphQL query
String query = '''
mutation ValidateBuildWithCHML(
$project: String!,
$branch: String!,
$build: String!,
$validation: String!,
$description: String!,
$runInfo: RunInfoInput,
$critical: Int!,
$high: Int!,
$medium: Int!,
$low: Int!
) {
validateBuildWithCHML(input: {
project: $project,
branch: $branch,
build: $build,
validation: $validation,
description: $description,
runInfo: $runInfo,
critical: $critical,
high: $high,
medium: $medium,
low: $low
}) {
validationRun {
id
}
errors {
message
}
}
}
'''
// Validation parameters
Validation validation = new Validation("ontrack-cli-validate-chml")
Map<String,?> variables = validation.variables(this, params, false)
// CHML values
variables.critical = critical
variables.high = high
variables.medium = medium
variables.low = low
// GraphQL call
def response = ontrackCliGraphQL(
logging: logging,
query: query,
variables: variables,
)
// Checks for errors
GraphQL.checkForMutationErrors(response, 'validateBuildWithCHML')
// Validation run properties
Validation.setValidationRunProperties(this, params, response, 'validateBuildWithCHML')
}