Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIXED JENKINS-41060] Add new fixed/regression post conditions
- Loading branch information
Showing
6 changed files
with
150 additions
and
1 deletion.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
.../main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/Fixed.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2018, CloudBees, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package org.jenkinsci.plugins.pipeline.modeldefinition.model.conditions | ||
|
||
import hudson.Extension | ||
import hudson.model.Result | ||
import org.jenkinsci.Symbol | ||
import org.jenkinsci.plugins.pipeline.modeldefinition.model.BuildCondition | ||
import org.jenkinsci.plugins.workflow.job.WorkflowRun | ||
|
||
/** | ||
* A {@link BuildCondition} for matching builds where the previous build was not SUCCESS but the current build is. | ||
* | ||
* @author Andrew Bayer | ||
*/ | ||
@Extension(ordinal=900d) @Symbol("fixed") | ||
class Fixed extends BuildCondition { | ||
@Override | ||
boolean meetsCondition(WorkflowRun r) { | ||
Result execResult = getExecutionResult(r) | ||
// Only look at the previous completed build. | ||
WorkflowRun prev = r.getPreviousCompletedBuild() | ||
|
||
// Get the *worst* result of either the execution or the run. If the run's result is null, that's effectively | ||
// SUCCESS. | ||
Result runResult = execResult.combine(r.getResult() ?: Result.SUCCESS) | ||
|
||
// If there's no previous build, we can't exactly be fixed, can we? | ||
if (prev == null) { | ||
return false | ||
} else { | ||
return runResult == Result.SUCCESS && prev.getResult() != Result.SUCCESS | ||
} | ||
} | ||
|
||
@Override | ||
String getDescription() { | ||
return Messages.Fixed_Description() | ||
} | ||
|
||
|
||
static final long serialVersionUID = 1L | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
.../groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/conditions/Regression.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2018, CloudBees, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package org.jenkinsci.plugins.pipeline.modeldefinition.model.conditions | ||
|
||
import hudson.Extension | ||
import hudson.model.Result | ||
import org.jenkinsci.Symbol | ||
import org.jenkinsci.plugins.pipeline.modeldefinition.model.BuildCondition | ||
import org.jenkinsci.plugins.workflow.job.WorkflowRun | ||
|
||
/** | ||
* A {@link BuildCondition} for matching builds where the previous build was better than the current build. | ||
* | ||
* @author Andrew Bayer | ||
*/ | ||
@Extension(ordinal=900d) @Symbol("regression") | ||
class Regression extends BuildCondition { | ||
@Override | ||
boolean meetsCondition(WorkflowRun r) { | ||
Result execResult = getExecutionResult(r) | ||
// Only look at the previous completed build. | ||
WorkflowRun prev = r.getPreviousCompletedBuild() | ||
|
||
// Get the *worst* result of either the execution or the run. If the run's result is null, that's effectively | ||
// SUCCESS. | ||
Result runResult = execResult.combine(r.getResult() ?: Result.SUCCESS) | ||
|
||
// If there's no previous build, we can't exactly be regressing, can we? | ||
if (prev == null) { | ||
return false | ||
} else { | ||
return runResult.isWorseThan(prev.getResult()) | ||
} | ||
} | ||
|
||
@Override | ||
String getDescription() { | ||
return Messages.Regression_Description() | ||
} | ||
|
||
|
||
static final long serialVersionUID = 1L | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,9 @@ pipeline { | |
changed { | ||
echo "I CHANGED" | ||
} | ||
fixed { | ||
echo "I AM FIXED" | ||
} | ||
failure { | ||
echo "I FAILED" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters