Skip to content

Commit

Permalink
[FIXED JENKINS-47814] Don't run post validator contirbutors twice
Browse files Browse the repository at this point in the history
  • Loading branch information
abayer committed Nov 3, 2017
1 parent bbe2c22 commit f3d3486
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
Expand Up @@ -108,7 +108,7 @@ class ModelValidatorImpl implements ModelValidator {
valid = false
}

return validateFromContributors(post, valid)
return valid
}

public boolean validateElement(@Nonnull ModelASTBuildCondition buildCondition) {
Expand Down
Expand Up @@ -28,7 +28,7 @@
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTOption;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTStep;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPostBuild;
import org.jenkinsci.plugins.pipeline.modeldefinition.model.BuildCondition;
import org.jenkinsci.plugins.pipeline.modeldefinition.model.Options;
import org.jenkinsci.plugins.pipeline.modeldefinition.model.Parameters;
Expand Down Expand Up @@ -686,6 +686,27 @@ public void validatorContributor() throws Exception {
.go();
}

@Issue("JENKINS-47814")
@Test
public void postValidatorContributor() throws Exception {
TestDupeContributor.count = 0;
expectError("postValidatorContributor")
.logContains("validate 1")
.logNotContains("validate 2")
.go();
}

@TestExtension
public static class TestDupeContributor extends DeclarativeValidatorContributor {
public static int count = 0;

@Override
public String validateElement(@Nonnull ModelASTPostBuild postBuild, @CheckForNull FlowExecution execution) {
count++;
return "validate " + count;
}
}

@TestExtension
public static class RejectTestProperty extends DeclarativeValidatorContributor {
@Override
Expand Down
@@ -0,0 +1,42 @@
/*
* The MIT License
*
* Copyright (c) 2017, 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.
*/

pipeline {
agent none
stages {
stage("foo") {
steps {
echo "hello"
}
}
}
post {
always {
echo "hi"
}
}
}



0 comments on commit f3d3486

Please sign in to comment.