jenkinsci / jenkinsci/github-autostatus-plugin

Select which stages to notify about

Open
#105 1 comment 4 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
58
Forks
38
PR merge metrics
No merged PRs in 30d

Description

One of the issues that I encountered is that there's no way to select (or deselect) which stages you want to notify about. Consider the following case:

```jenkins
pipeline {
agent any
stages {
stage('Stage 1') {
...
}
stage('Stage 2') {
when { branch 'master' }
...
}
}
}
```
If a user opens a PR (not `master` branch), `Stage 2` will not run, and thus they will get a constant `PENDING` notification for that stage.

I am considering adding functionality to prevent similar cases and would be nice to get some ideas on how to attack the problem.

What I thought about is adding some filtering in the function `getDeclarativeStages`.
```java
protected static List getDeclarativeStages(Run run) {
ExecutionModelAction executionModelAction = run.getAction(ExecutionModelAction.class);
if (null == executionModelAction) {
return null;
}
ModelASTStages stages = executionModelAction.getStages();
if (null == stages) {
return null;
}
List stageList = stages.getStages();
if (null == stageList) {
return null;
}

// do filtering ...

return convertList(filteredStageList);
}
```
The problem is that I'm not sure how would we could add a property (`notify: (true/false)`) to each stage of the pipeline and retrieve it here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.