Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checkbox for Builder to fail deployment when there are no artifacts. #11

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,39 @@ private Map<Integer, List<ArtifactDeployerVO>> processDeployment(final AbstractB
ArtifactDeployerManager deployerManager = new ArtifactDeployerManager();
FilePath basedirFilePath = deployerManager.getBasedirFilePath(workspace, basedir);
List<ArtifactDeployerVO> results = basedirFilePath.act(deployerCopy);

if (isFailNoFilesDeploy(results, entry)) {
throw new ArtifactDeployerException("Can't find any artifacts to deploy with the following configuration :"
+ printConfiguration(includes, excludes, basedirFilePath.getRemote(), outputPath));
}

deployedArtifacts.put(entry.getUniqueId(), results);
return deployedArtifacts;
}

private boolean isFailNoFilesDeploy(List<ArtifactDeployerVO> results, ArtifactDeployerEntry entry) {
return ((results == null || results.size() == 0) && entry.isFailNoFilesDeploy());
}

private String printConfiguration(String includes, String excludes, String basedir, String outputPath) {
StringBuffer sb = new StringBuffer();

if (includes != null) {
sb.append(",includes:").append(includes);
}
if (excludes != null) {
sb.append(",excludes:").append(excludes);
}

sb.append(",basedir:").append(basedir);
sb.append(",outPath:").append(outputPath);
sb.append("]");

sb = sb.replace(0, 1, "[");

return sb.toString();
}

@SuppressWarnings("unused")
public ArtifactDeployerEntry getEntry() {
return entry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ THE SOFTWARE.
<f:checkbox name="artifactdeployer.entry.flatten" checked="${instance.entry.flatten}" title="Flatten"/>
</f:entry>

<f:entry field="failNoFilesDeploy">
<f:checkbox name="artifactdeployer.entry.failNoFilesDeploy"
checked="${instance.entry.failNoFilesDeploy}"/>
<label class="attach-previous">Fail build if there are no files to deploy</label>
</f:entry>

<f:entry field="deleteRemote">
<f:checkbox name="artifactdeployer.entry.deleteRemote" checked="${instance.entry.deleteRemote}"/>
<label class="attach-previous">Clean-up remote directory before deployment</label>
Expand Down