Closed webbrandon closed 4 years ago
sadly Jenkins API for pipelines is pretty hard.
You can view the json from one of your pipeline build, the REST API
link (on the bottom right) and json api
the interesting part is in action, by default it should look something like
{
"_class" : "org.jenkinsci.plugins.workflow.job.WorkflowRun",
"actions" : [
{
"_class" : "hudson.model.CauseAction",
"causes" : [
{
"_class" : "hudson.model.Cause$UserIdCause",
"shortDescription" : "Started by user user",
"userId" : "user",
"userName" : "user"
}
]
},
{
},
{
},
{
"_class" : "org.jenkinsci.plugins.workflow.support.steps.input.ApproverAction"
},
{
},
{
},
{
},
{
"_class" : "org.jenkinsci.plugins.workflow.job.views.FlowGraphAction"
},
{
},
{
}
],
...
}
you can add a parameter &depth=1
and it will start displaying more info, and &depth=2
will start looking interesting
using this api, you can have something similar with
let jenkins = JenkinsBuilder::new(JENKINS_URL)
.with_depth(2)
.build()
.unwrap();
let build = jenkins.get_build("pipeline job", 1);
println!(
"{:#?}",
build
.unwrap()
.actions
.iter()
.filter_map(|action| action
.as_variant::<jenkins_api::action::FlowGraphAction>()
.ok())
.next()
);
for a simple pipeline with 4 steps
it gives a lot of data : https://gist.github.com/mockersf/e5c011d8140be2100e57bd8918d0d22e
Goal: I want to post the pipeline stages in the status view in Jenkins similar to the stages view plugin.
I see methods that allow you to add a job to an existing view but not one for the additional content such as stage block data. Is there a function that would allow me to update this view with the desired result?
Or simpler text implementation:
Admittedly it has been hard finding details or documents on implementing something like this so far. I feel the solution I need may be hidden in the Jenkins JIRA system in a tickets comments or the DSL codebase for pipelines or jobs.
I have a question for something simliar to this request on stack overflow