Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-54250] Disable restarting stages in jenkinsfile optionally (#…
…560) * Introduce DisableRestartFromStage declarative option. Change logic of restart declarative pipeline action to not return the icon if restart is disabled. Parse new option in Utils.groovy * Handle disableRestartFromStage option in Utils.groovy when it is not set
- Loading branch information
1 parent
31fd5b9
commit 821aabd
Showing
9 changed files
with
153 additions
and
1 deletion.
There are no files selected for viewing
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
8 changes: 8 additions & 0 deletions
8
...org/jenkinsci/plugins/pipeline/modeldefinition/actions/DisableRestartFromStageAction.java
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,8 @@ | ||
package org.jenkinsci.plugins.pipeline.modeldefinition.actions; | ||
|
||
import hudson.model.InvisibleAction; | ||
|
||
public class DisableRestartFromStageAction extends InvisibleAction { | ||
|
||
public DisableRestartFromStageAction(){} | ||
} |
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
28 changes: 28 additions & 0 deletions
28
.../org/jenkinsci/plugins/pipeline/modeldefinition/options/impl/DisableRestartFromStage.java
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,28 @@ | ||
package org.jenkinsci.plugins.pipeline.modeldefinition.options.impl; | ||
|
||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import hudson.Extension; | ||
import org.jenkinsci.Symbol; | ||
import org.jenkinsci.plugins.pipeline.modeldefinition.options.DeclarativeOption; | ||
import org.jenkinsci.plugins.pipeline.modeldefinition.options.DeclarativeOptionDescriptor; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
public class DisableRestartFromStage extends DeclarativeOption { | ||
|
||
@DataBoundConstructor | ||
public DisableRestartFromStage() {} | ||
|
||
@Extension @Symbol("disableRestartFromStage") | ||
public static class DescriptorImpl extends DeclarativeOptionDescriptor { | ||
@Override | ||
@NonNull | ||
public String getDisplayName() { | ||
return "Disable the ability to restart this Pipeline from a specific stage"; | ||
} | ||
|
||
@Override | ||
public boolean canUseInStage() { | ||
return false; | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...kinsci/plugins/pipeline/modeldefinition/options/impl/DisableRestartFromStage/config.jelly
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,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ 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. | ||
--> | ||
|
||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form"> | ||
</j:jelly> |
27 changes: 27 additions & 0 deletions
27
...jenkinsci/plugins/pipeline/modeldefinition/options/impl/DisableRestartFromStage/help.html
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,27 @@ | ||
<!-- | ||
~ 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. | ||
--> | ||
|
||
<p> | ||
If specified, Restart From Stage button will not be displayed. | ||
</p> |
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
13 changes: 13 additions & 0 deletions
13
pipeline-model-definition/src/test/resources/options/restartableFromStageDisabled.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,13 @@ | ||
pipeline { | ||
agent none | ||
options { | ||
disableRestartFromStage() | ||
} | ||
stages { | ||
stage("foo") { | ||
steps { | ||
echo "hello" | ||
} | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
pipeline-model-definition/src/test/resources/options/restartableFromStageEnabled.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,10 @@ | ||
pipeline { | ||
agent none | ||
stages { | ||
stage("foo") { | ||
steps { | ||
echo "hello" | ||
} | ||
} | ||
} | ||
} |