Skip to content

Commit

Permalink
[FIXED JENKINS-14088] add option to disable token parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
bap2000 committed Jun 12, 2012
1 parent c687355 commit d021f9e
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 3 deletions.
Expand Up @@ -51,11 +51,13 @@ public class DescriptionSetterWrapper extends BuildWrapper implements MatrixAggr

final Charset charset;
final String projectDescriptionFilename;
final boolean disableTokens;

@DataBoundConstructor
public DescriptionSetterWrapper(final String charset, final String projectDescriptionFilename) {
public DescriptionSetterWrapper(final String charset, final String projectDescriptionFilename, final boolean disableTokens) {
this.charset = Charset.forName(charset);
this.projectDescriptionFilename = projectDescriptionFilename;
this.disableTokens = disableTokens;
}

public String getCharset() {
Expand All @@ -66,6 +68,10 @@ public String getProjectDescriptionFilename() {
return projectDescriptionFilename;
}

public boolean isDisableTokens() {
return disableTokens;
}

@Override
public Environment setUp(final AbstractBuild build, final Launcher launcher, final BuildListener listener)
throws IOException, InterruptedException {
Expand Down Expand Up @@ -110,6 +116,7 @@ private String getContentsIfAvailable(final AbstractBuild build, final BuildList
}

private String expand(final AbstractBuild build, final BuildListener listener, final String template) {
if (disableTokens) return template;
try {
return TokenMacro.expand(build, listener, template);
} catch (MacroEvaluationException mee) {
Expand Down
Expand Up @@ -39,6 +39,7 @@ public class DescriptionSetterWrapperDescriptor extends BuildWrapperDescriptor {

private String charset;
private String projectDescriptionFilename;
private boolean disableTokens;

public DescriptionSetterWrapperDescriptor() {
super(DescriptionSetterWrapper.class);
Expand All @@ -61,6 +62,14 @@ public void setProjectDescriptionFilename(final String projectDescriptionFilenam
this.projectDescriptionFilename = projectDescriptionFilename;
}

public boolean isDisableTokens() {
return disableTokens;
}

public void setDisableTokens(boolean disableTokens) {
this.disableTokens = disableTokens;
}

public boolean configure(final StaplerRequest request, final JSONObject formData) {
request.bindJSON(this, formData);
save();
Expand Down
Expand Up @@ -29,6 +29,9 @@
<f:textbox default="${descriptor.projectDescriptionFilename}"/>
</f:entry>
<f:advanced>
<f:entry title="${%disableTokens}" field="disableTokens">
<f:checkbox default="${descriptor.disableTokens}"/>
</f:entry>
<f:entry title="${%charset}" field="charset">
<f:select default="${descriptor.charset ?: descriptor.defaultCharset}"/>
</f:entry>
Expand Down
Expand Up @@ -23,4 +23,5 @@
#

projectDescriptionFilename=Filename
disableTokens=Disable tokens
charset=Charset
Expand Up @@ -29,6 +29,9 @@
<f:entry title="${%projectDescriptionFilename}" field="projectDescriptionFilename">
<f:textbox/>
</f:entry>
<f:entry title="${%disableTokens}" field="disableTokens">
<f:checkbox/>
</f:entry>
<f:entry title="${%charset}" field="charset">
<f:select default="${descriptor.defaultCharset}"/>
</f:entry>
Expand Down
Expand Up @@ -24,4 +24,5 @@

section=Project description setter defaults
projectDescriptionFilename=Filename
disableTokens=Disable tokens
charset=Charset
@@ -0,0 +1,29 @@
<!--
~ The MIT License
~
~ Copyright (C) 2010-2011 by Anthony Robinson
~
~ 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.
-->

<div>
Disables token macro parsing in the description file.

<strong>Does not affect token parsing of the filename</strong>
</div>
Expand Up @@ -25,8 +25,8 @@

<j:jelly xmlns:j="jelly:core">
<div>
<p>The name of the file relative to the workspace root</p>
<p>The contents of the file will have any tokens replaced and will then be used to set the description for the project.</p>
<p>The name of the file relative to the workspace root - <strong>Token Macro tokens will always be expanded</strong></p>
<p>The contents of the file will have any tokens replaced (unless Disable tokens is selected) and will then be used to set the description for the project.</p>
<p><br/><br/><strong>Available tokens</strong></p>
<help xmlns="/lib/token-macro"/>
</div>
Expand Down

0 comments on commit d021f9e

Please sign in to comment.