-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.Jenkinsfile
More file actions
40 lines (34 loc) · 1.43 KB
/
example.Jenkinsfile
File metadata and controls
40 lines (34 loc) · 1.43 KB
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
import groovy.json.JsonOutput
pipeline {
agent any
parameters {
string(name: 'JOB_ID', defaultValue: '', description: 'Ctrlplane Job ID passed by the plugin')
}
stages {
stage('Fetch Ctrlplane Job Details') {
steps {
script {
if (!params.JOB_ID) {
error 'JOB_ID parameter is required'
}
echo "Fetching details for Job ID: ${params.JOB_ID}"
def jobDetails = ctrlplaneGetJob jobId: params.JOB_ID
echo "-----------------------------------------"
echo "Successfully fetched job details:"
echo JsonOutput.prettyPrint(JsonOutput.toJson(jobDetails))
echo "-----------------------------------------"
// Example: Access specific fields from the returned map
// if(jobDetails.variables) {
// echo "Specific Variable: ${jobDetails.variables.your_variable_name}"
// }
// if(jobDetails.metadata) {
// echo "Metadata Value: ${jobDetails.metadata.your_metadata_key}"
// }
// if(jobDetails.job_config) {
// echo "Job Config: ${jobDetails.job_config.jobUrl}"
// }
}
}
}
}
}