jenkinsci / github-autostatus-plugin

Jenkins plugin to provide automatic status for multibranch jobs
https://plugins.jenkins.io/github-autostatus/
MIT License
52 stars 34 forks source link

Select which stages to notify about #105

Open joxoby opened 3 years ago

joxoby commented 3 years ago

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:

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.

    protected static List<BuildStage> getDeclarativeStages(Run<?, ?> run) {
        ExecutionModelAction executionModelAction = run.getAction(ExecutionModelAction.class);
        if (null == executionModelAction) {
            return null;
        }
        ModelASTStages stages = executionModelAction.getStages();
        if (null == stages) {
            return null;
        }
        List<ModelASTStage> 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.

PhotoTeeborChoka commented 2 years ago

Maybe it would be better to have the correct status reported (skipped in this case) and have a configuration option to "not report skipped jobs".