You can take a look at Job and Stage monitoring plugin 
(https://github.com/jenkinsci/github-autostatus-plugin). I think it does 
the thing you're looking for.
On Tuesday, January 12, 2021 at 4:50:23 AM UTC+3 Mark Waite wrote:

> On Mon, Jan 11, 2021 at 6:24 PM 'Cyrille Le Clerc' via Jenkins Developers <
> jenkin...@googlegroups.com> wrote:
>
>> Dear community,
>>
>> *Context: *
>> I'm trying to implement an OpenTelemetry instrumentation of Jenkins, 
>> starting injecting distributed traces in job executions. See 
>> https://github.com/cyrille-leclerc/opentelemetry-plugin
>>
>> *Question: *
>> *What is the recommended way to listen to the end of the execution of a 
>> step and to collect its result?*
>> I would like to listen the end of execution of `stage`and `git` steps to 
>> end a trace span reporting the result of the step.
>>
>> I found the `GraphListener#onNewHead(FlowNode)` API and I identify the 
>> end of stage steps with `StepEndNode` containing a   whose descriptor is a 
>> `StageStep.DescriptorImpl` but
>>
>>    - I am not clear on if I should track the `StepEndNode` containing a 
>>    `LabelAction` or an `ArgumentsAction`
>>    - On none of the StepEndNode give me access to the error thrown 
>>    during the execution to indicate a failure,  `StepEndNode#getError()` and 
>>    `StepEndNode.getExecution.getCauseOfFailure()` return null 
>>    during  `GraphListener#onNewHead(FlowNode)`
>>
>> I'm wondering if I have to add a `BodyExecutionCallback` to the `
>> CpsBodyInvoker` but I didn't find an API to do this implementing a 
>> listener of the pipeline executions.
>>
>> I have a similar request for `git` steps that don't even have a  
>> `StepEndNode`, how can I intercept the end of execution and the 
>> result/error of the execution of a `git` step.
>>
>>
>
> I don't know the answer to your listener question.  This is probably not 
> what you want to hear, but I think that you should focus on the checkout 
> step rather than the git step.  Per the git step documentation:
>
> More advanced checkout operations require the checkout step rather than 
> the git step.  
>
> The git step is a simplified shorthand for a subset of the more powerful 
> checkout step:
>
> checkout([$class: 'GitSCM', branches: [[name: '*/master']],
>     userRemoteConfigs: [[url: 'http://git-server/user/repository.git']]])
>
>
>  
>
>> I hope my question is detailed enough.
>>
>> Cyrille
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Jenkins Developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to jenkinsci-de...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-dev/db5376b1-3888-46f0-9429-9b34e3940ed9n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-dev/db5376b1-3888-46f0-9429-9b34e3940ed9n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/a1012b64-1979-47a5-9646-832e21376146n%40googlegroups.com.

Reply via email to