Skip to content

Commit

Permalink
JENKINS-15882 - rebuild plugin should not store non-stored password p…
Browse files Browse the repository at this point in the history
…arameter

-Replaced if jelly tag by choose
-fixed global jelly to show documentation
-imrpoved documentation
-added license
-added javadoc
  • Loading branch information
rinokadijk committed Mar 25, 2013
1 parent 17cfac7 commit 0eb0c00
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 9 deletions.
13 changes: 13 additions & 0 deletions src/main/java/com/sonyericsson/rebuild/RebuildAction.java
Expand Up @@ -391,6 +391,9 @@ public BuildStepDescriptor getDescriptor() {
public static final class DescriptorImpl extends BuildStepDescriptor<Publisher> {
private final RebuildConfiguration rebuildConfiguration = new RebuildConfiguration(Boolean.TRUE);

/**
* Constructs a new Descriptor implementation.
*/
public DescriptorImpl() {
super(RebuildAction.class);
load();
Expand Down Expand Up @@ -418,10 +421,20 @@ public Publisher newInstance(StaplerRequest req, JSONObject formData) throws For
return new RebuildAction();
}

/**
* Gets the configuration object.
*
* @return the configuration object.
*/
public RebuildConfiguration getRebuildConfiguration() {
return rebuildConfiguration;
}

/**
* Gets the remember password option from the configuration object.
*
* @return true if the password field should be pre-filled.
*/
public boolean getRememberPassword() {
return rebuildConfiguration.getRememberPassword();
}
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/com/sonyericsson/rebuild/RebuildConfiguration.java
@@ -1,14 +1,46 @@
/*
* The MIT License
*
* Copyright 2013 Rino Kadijk.
*
* 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 hudson.model.Describable;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* This class holds the configuration values for the rebuild action.
*/
public class RebuildConfiguration implements Describable {

public boolean rememberPassword;

/**
* Constructs a new configuration object.
*
* @param rememberPassword indicates whether the password field should be pre-filled or empty when rebuilding
* a job with a password parameter.
*/
@DataBoundConstructor
public RebuildConfiguration(boolean rememberPassword) {
this.rememberPassword = rememberPassword;
Expand All @@ -19,6 +51,11 @@ public Descriptor getDescriptor() {
return Hudson.getInstance().getDescriptorOrDie(RebuildConfiguration.class);
}

/**
* True if the password field should be pre-filled.
*
* @return true if the password field should be pre-filled.
*/
public boolean getRememberPassword() {
return rememberPassword;
}
Expand Down
Expand Up @@ -30,12 +30,10 @@ xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:entry title="${it.name}" description="${it.description}">
<div name="parameter" description="${it.description}">
<input type="hidden" name="name" value="${it.name}" />
<j:if test="${rememberPassword}">
<f:password name="value" value="${it.value}" />
</j:if>
<j:if test="${!rememberPassword}">
<f:password name="value" value="" />
</j:if>
<j:choose>
<j:when test="${rememberPassword}"><f:password name="value" value="${it.value}"/></j:when>
<j:otherwise><f:password name="value" value="" /></j:otherwise>
</j:choose>
</div>
</f:entry>
</j:jelly>
Expand Up @@ -4,8 +4,8 @@
<f:section title="Rebuild">
<f:entry title="Rebuild Configuration">
<table width="100%">
<f:entry title="Remember Password">
<f:checkbox field="rememberPassword"/>
<f:entry title="Remember Password" field="rememberPassword">
<f:checkbox/>
</f:entry>
</table>
</f:entry>
Expand Down
@@ -1,5 +1,6 @@
<div>
If the remember password option is checked, the rebuild plugin will use the stored password parameter when a
rebuild is triggered. If the remember password option is unchecked, the user will be prompted to enter the
password every time a rebuild is triggered. This only applies for parameters of type password.
password every time a rebuild is triggered. This only applies for a parameterized build with parameters of
type password.
</div>

0 comments on commit 0eb0c00

Please sign in to comment.