Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #4 from imod/master
Browse files Browse the repository at this point in the history
[FIXED JENKINS-18135] inline attributes instead of deprecated newInstanc...
  • Loading branch information
gboissinot committed Nov 14, 2013
2 parents f4a98b3 + b82141c commit 20268aa
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
17 changes: 16 additions & 1 deletion pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.424</version>
<version>1.480</version>
</parent>

<artifactId>artifactdeployer</artifactId>
Expand Down Expand Up @@ -70,6 +70,15 @@
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jvnet.localizer</groupId>
<artifactId>maven-localizer-plugin</artifactId>
<version>1.14</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -94,6 +103,12 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<version>1.100</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>

Expand Down
Expand Up @@ -5,21 +5,19 @@
import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.Util;
import hudson.model.*;
import hudson.model.listeners.RunListener;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Builder;
import hudson.util.DescribableList;
import hudson.util.FormValidation;
import net.sf.json.JSONObject;
import org.jenkinsci.plugins.artifactdeployer.exception.ArtifactDeployerException;
import org.jenkinsci.plugins.artifactdeployer.service.ArtifactDeployerCopy;
import org.jenkinsci.plugins.artifactdeployer.service.ArtifactDeployerManager;
import org.jenkinsci.plugins.artifactdeployer.service.DeployedArtifactsActionManager;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;

import java.io.IOException;
import java.io.Serializable;
Expand All @@ -33,6 +31,14 @@
public class ArtifactDeployerBuilder extends Builder implements Serializable {

ArtifactDeployerEntry entry;

@DataBoundConstructor
public ArtifactDeployerBuilder(String includes, String basedir, String excludes, String remote, boolean flatten, boolean deleteRemote, boolean deleteRemoteArtifacts, DeleteRemoteArtifactsByScriptModel deleteRemoteArtifactsByScript, boolean failNoFilesDeploy) {
this.entry = new ArtifactDeployerEntry(includes, basedir, excludes, remote, flatten, deleteRemote, deleteRemoteArtifacts, deleteRemoteArtifactsByScript, failNoFilesDeploy);
}

public ArtifactDeployerBuilder() {
}

@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
Expand Down Expand Up @@ -207,28 +213,6 @@ public String getDisplayName() {
return DISPLAY_NAME;
}

@Override
public Builder newInstance(StaplerRequest req, JSONObject formData) throws FormException {
ArtifactDeployerBuilder builder = new ArtifactDeployerBuilder();
ArtifactDeployerEntry entry = new ArtifactDeployerEntry();
entry.setIncludes(Util.fixEmpty(formData.getString("includes")));
entry.setBasedir(Util.fixEmpty(formData.getString("basedir")));
entry.setExcludes(Util.fixEmpty(formData.getString("excludes")));
entry.setRemote(Util.fixEmpty(formData.getString("remote")));
entry.setDeleteRemote(formData.getBoolean("deleteRemote"));
entry.setFlatten(formData.getBoolean("flatten"));
entry.setDeleteRemoteArtifacts(formData.getBoolean("deleteRemoteArtifacts"));
Object deleteRemoteArtifactsObject = formData.get("deleteRemoteArtifactsByScript");
if (deleteRemoteArtifactsObject == null) {
entry.setDeleteRemoteArtifactsByScript(false);
} else {
entry.setDeleteRemoteArtifactsByScript(true);
entry.setGroovyExpression(Util.fixEmpty(formData.getJSONObject("deleteRemoteArtifactsByScript").getString("groovyExpression")));
}
builder.setEntry(entry);
return builder;
}

public FormValidation doCheckIncludes(@AncestorInPath AbstractProject project, @QueryParameter String value) throws IOException {
return FilePath.validateFileMask(project.getSomeWorkspace(), value);
}
Expand Down
@@ -1,5 +1,6 @@
package org.jenkinsci.plugins.artifactdeployer;

import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;

import java.io.Serializable;
Expand Down Expand Up @@ -93,7 +94,7 @@ public boolean isDeleteRemoteArtifacts() {

@SuppressWarnings("unused")
public boolean isDeleteRemoteArtifactsByScript() {
return deleteRemoteArtifactsByScript;
return StringUtils.isNotBlank(groovyExpression);
}

@SuppressWarnings("unused")
Expand Down
Expand Up @@ -41,7 +41,7 @@
<f:optionalBlock
field="deleteRemoteArtifactsByScript"
name="artifactdeployer.entry.deleteRemoteArtifactsByScript"
checked="${instance.entry.deletedRemoteArtifactsByScript}"
checked="${instance.entry.deleteRemoteArtifactsByScript}"
title="${%Execute a groovy script when the job is deleted}">

<f:entry field="groovyExpression" title="${%Groovy Expression}">
Expand Down

0 comments on commit 20268aa

Please sign in to comment.