Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-39284] Set build description to failure cause #72

Open
wants to merge 40 commits into
base: master
Choose a base branch
from

Conversation

TreverW
Copy link

@TreverW TreverW commented Aug 2, 2017

JENKINS-39284
Add an option to the BFA configuration that, when enabled, sets the build description to the failure cause.

JENKINS-39284
Add an option to the BFA configuration that, when enabled, sets the build description to the failure cause.
Copy link
Member

@TWestling TWestling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!
One small inline comment + please tests for this.
Should be easy to add some tests for this to BuildFailureScannerHudsonTest

…ot as complete as I'd like because I'm not sure how to manipulate the build description before BFA scans the build. I'd like to test functionality with a build description already set such as might happen from another plugin.
@TreverW
Copy link
Author

TreverW commented Aug 11, 2017

Thanks for the suggestions (this is my first OSS pull request so I'm learning how this works).

I've appended to the build description instead of overwriting it. I've also added some tests. The tests are not as complete as I'd like because I'm not sure how to manipulate the build description before BFA scans the build. I'd like to test functionality with a build description already set such as might happen from another plugin. If you have some suggestion on how I might do that in the tests, I'd be happy to improve the tests.

@rsandell
Copy link
Member

You can either add a custom TestBuilder to a FreestyleProject or in a pipeline just do currentBuild.description = "Hello World"

You do something like the following to add the test builder:

project.getBuildersList().add(new TestBuilder() {
    @Override
    boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
        build.setDescription("Hello World")
        return true;
    }
});

@rsennewald
Copy link

Hello, is there any chance this can be re-reviewed and integrated with the project? I'm looking for the exact same functionality to solve my use case and would love it if the plugin supported it out of the box and I didn't have to do a post build script in groovy to achieve this.

Copy link
Member

@rsandell rsandell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the review delay, I thought someone else was actively reviewing it.

@ssbarnea
Copy link
Contributor

I like the idea but I would prefer to append-to-description option instead of overriding current value.

@guidograzioli
Copy link
Member

Also, this functionality should only be offered after enabling a global config checkbox. Changing the default behaviour without action is never a good idea.

TreverW and others added 10 commits March 22, 2018 11:58
JENKINS-39284
Add an option to the BFA configuration that, when enabled, sets the build description to the failure cause.
…ot as complete as I'd like because I'm not sure how to manipulate the build description before BFA scans the build. I'd like to test functionality with a build description already set such as might happen from another plugin.
…ion_to_failure_cause' into JENKINS-39284_Set_build_description_to_failure_cause
@rsandell rsandell changed the title JENKINS-39284_Set_build_description_to_failure_cause [JENKINS-39284] Set build description to failure cause Jan 13, 2020
TreverW and others added 15 commits September 4, 2020 18:55
# Conflicts:
#	src/main/java/com/sonyericsson/jenkins/plugins/bfa/BuildFailureScanner.java
…lure_cause

# Conflicts:
#	src/main/java/com/sonyericsson/jenkins/plugins/bfa/BuildFailureScanner.java
…ion_to_failure_cause' into JENKINS-39284_Set_build_description_to_failure_cause

# Conflicts:
#	src/main/java/com/sonyericsson/jenkins/plugins/bfa/PluginImpl.java
… line numbers as they may change frequently.
…rder to have an unstable build with failure causes identified in order to make sure the Build Description is not applied if the setting is disabled.
@TreverW
Copy link
Author

TreverW commented Sep 9, 2020

Thank you for your time reviewing this PR. I've tried to address the suggestions given. Thank you. I am still learning how to do plugin development for Jenkins so I appreciate the feedback.

# Conflicts:
#	src/main/java/com/sonyericsson/jenkins/plugins/bfa/BuildFailureScanner.java
@stronk7
Copy link

stronk7 commented Jul 24, 2022

Was looking to release notes and other random stuff when I arrived here.

Just in case it helps to anybody... we are using here since some good months ago this script, launched every X minutes via job... that exactly addresses this (set build description to the BFA causes found).

https://git.in.moodle.com/integration/nightlyjobs/-/blob/master/src/org/moodle/ci/maintenance/SetBuildDescriptionToIndications.groovy

We launch it via library, although I imagine that it can be embed without problem in a pipeline script. This s how we launch it:

@Library('ci') _

import org.moodle.ci.maintenance.SetBuildDescriptionToIndications

node("jenkins-maintenance") {
    stage("Run") {
        task = new SetBuildDescriptionToIndications(
            view: "${params.VIEW}",
        )
        if (task.run(this) != 0) {
            currentBuild.result = 'FAILURE'
        }
    }
}

You can see it in action @ https://ci.moodle.org/job/W.03.05%20-%20Behat%20-%20Chrome%20+%20Oracle/ (for example, because with Oracle, heh, is where we get more random/failures detected by BFA).

Hope it helps, ciao :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants