Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[JENKINS-19843] Provides an extension point for other plugins to supp…
…ort rebuild plugin.
- Loading branch information
Showing
6 changed files
with
280 additions
and
2 deletions.
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
58 changes: 58 additions & 0 deletions
58
src/main/java/com/sonyericsson/rebuild/RebuildParameterPage.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,58 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2013 IKEDA Yasuyuki | ||
* | ||
* 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 com.sonyericsson.rebuild; | ||
|
||
/** | ||
* A bean contains information of the view to show parameters in rebuild page. | ||
*/ | ||
public class RebuildParameterPage { | ||
private Class<?> clazz = null; | ||
/** | ||
* @return the class for the view. | ||
*/ | ||
public Class<?> getClazz() { | ||
return clazz; | ||
} | ||
/** | ||
* @param clazz the class for the view. | ||
*/ | ||
public void setClazz(Class<?> clazz) { | ||
this.clazz = clazz; | ||
} | ||
|
||
private String page = null; | ||
/** | ||
* @return the path of jelly(or groovy) file. | ||
*/ | ||
public String getPage() { | ||
return page; | ||
} | ||
/** | ||
* @param page the path of jelly(or groovy) file. | ||
*/ | ||
public void setPage(String page) { | ||
this.page = page; | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
src/main/java/com/sonyericsson/rebuild/RebuildParameterProvider.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,89 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2013 IKEDA Yasuyuki | ||
* | ||
* 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 com.sonyericsson.rebuild; | ||
|
||
import jenkins.model.Jenkins; | ||
import hudson.Extension; | ||
import hudson.ExtensionList; | ||
import hudson.ExtensionPoint; | ||
import hudson.model.ParameterValue; | ||
|
||
/** | ||
* Extension point to provide views to show parameters in rebuild page. | ||
* | ||
* If you want your custom {@link ParameterValue} to work with rebuild plugin, | ||
* do as followings: | ||
* <ol> | ||
* <li>Define a class implementing {@link RebuildParameterProvider}.</li> | ||
* <li>Annotate the class with {@link Extension}. | ||
* You should specify option=true in {@link Extension} annotation | ||
* to have your plugin work without rebuild plugin.</li> | ||
* <li>Override {@link RebuildParameterProvider#getRebuildPage(ParameterValue)}. | ||
* Don't forget to return <code>null</code> for parameter values | ||
* other than your custom {@link ParameterValue}. | ||
* There are two recommended ways to set values to {@link RebuildParameterPage}: | ||
* <table> | ||
* <tr> | ||
* <th> </th> | ||
* <th>Recommended 1</th> | ||
* <th>Recommended 2</th> | ||
* </tr> | ||
* <tr> | ||
* <th>clazz</th> | ||
* <td>your custom {@link ParameterValue}</td> | ||
* <td>the class implementing {@link RebuildParameterProvider}</td> | ||
* </tr> | ||
* <tr> | ||
* <th>page</th> | ||
* <td>a file in the resource directory of your custom {@link ParameterValue}</td> | ||
* <td>a file in the resource directory of the class implementing {@link RebuildParameterProvider}</td> | ||
* </tr> | ||
* </table> | ||
* </li> | ||
* </ol> | ||
*/ | ||
public abstract class RebuildParameterProvider implements ExtensionPoint { | ||
// This is defined not as an interface but as an abstract class. | ||
// If defined as an interface, developers might carelessly apply this | ||
// to mandatory class in their plugin and their plugins get not to work | ||
// without rebuild plugin. | ||
|
||
/** | ||
* Provide a view for specified {@link ParameterValue}. | ||
* | ||
* Return null if cannot handle specified {@link ParameterValue}. | ||
* | ||
* @param value a value to be shown in a rebuild page. | ||
* @return page for the parameter value. null for parameter values cannot be handled. | ||
*/ | ||
public abstract RebuildParameterPage getRebuildPage(ParameterValue value); | ||
|
||
/** | ||
* @return all {@link RebuildParameterProvider} registered to Jenkins. | ||
*/ | ||
public static ExtensionList<RebuildParameterProvider> all() { | ||
return Jenkins.getInstance().getExtensionList(RebuildParameterProvider.class); | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
...m/sonyericsson/rebuild/RebuildValidatorTest/SupportedUnknownParameterValue/rebuild.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,16 @@ | ||
package com.sonyericsson.rebuild.RebuildValidatorTest.SupportedUnknownParameterValue; | ||
|
||
f = namespace("lib/form") | ||
|
||
// "it" will be overridden inside nexted tags. | ||
String itName = it.name | ||
String itValue = it.value | ||
|
||
f.entry(title: it.name, description: it.description) { | ||
div(name: "parameter") { | ||
input(type: "hidden", name: "name", value: itName) | ||
input(type: "text", name: "value", value: itValue) | ||
text("This is a mark for test") | ||
} | ||
} | ||
|