Skip to content

Commit

Permalink
[FIXED JENKINS-35316] Nuget plugin publication succeeds when nupkg do…
Browse files Browse the repository at this point in the history
…esn't exist
  • Loading branch information
Greybird committed Aug 5, 2016
1 parent c07c204 commit a5d359d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
Expand Up @@ -51,8 +51,8 @@ public class NugetPromotionPublisher extends NugetPublisher {
private static final String PROMOTION_CLASS_NAME = "hudson.plugins.promoted_builds.Promotion";

@DataBoundConstructor
public NugetPromotionPublisher(String name, String packagesPattern, String publishPath, String nugetPublicationName, String packagesExclusionPattern, boolean useWorkspaceInPromotion) {
super(name, packagesPattern, publishPath, nugetPublicationName, packagesExclusionPattern);
public NugetPromotionPublisher(String name, String packagesPattern, String publishPath, String nugetPublicationName, String packagesExclusionPattern, boolean useWorkspaceInPromotion, boolean doNotFailIfNoPackagesArePublished) {
super(name, packagesPattern, publishPath, nugetPublicationName, packagesExclusionPattern, doNotFailIfNoPackagesArePublished);
this.useWorkspaceInPromotion = useWorkspaceInPromotion;
}

Expand Down
Expand Up @@ -35,14 +35,16 @@ public class NugetPublisher extends Recorder {
protected String publishPath;
protected String nugetPublicationName;
protected String packagesExclusionPattern;
protected boolean doNotFailIfNoPackagesArePublished;

@DataBoundConstructor
public NugetPublisher(String name, String packagesPattern, String publishPath, String nugetPublicationName, String packagesExclusionPattern) {
public NugetPublisher(String name, String packagesPattern, String publishPath, String nugetPublicationName, String packagesExclusionPattern, boolean doNotFailIfNoPackagesArePublished) {
this.name = name;
this.packagesPattern = packagesPattern;
this.publishPath = StringUtils.trim(publishPath);
this.nugetPublicationName = nugetPublicationName;
this.packagesExclusionPattern = packagesExclusionPattern;
this.doNotFailIfNoPackagesArePublished = doNotFailIfNoPackagesArePublished;
}

@Override
Expand Down Expand Up @@ -80,6 +82,9 @@ protected FilePath getFilesRoot(AbstractBuild<?, ?> build) {
}

private void checkErrors(List<PublicationResult> results) throws AbortException {
if (results.isEmpty() && !doNotFailIfNoPackagesArePublished) {
throw new AbortException("No packages were published.");
}
for(PublicationResult result : results) {
if (!result.isSuccess()) {
throw new AbortException("There were errors while publishing packages to NuGet.");
Expand Down Expand Up @@ -112,6 +117,10 @@ public String getNugetPublicationName() {
return nugetPublicationName;
}

public boolean isDoNotFailIfNoPackagesArePublished() {
return doNotFailIfNoPackagesArePublished;
}

@Extension
public static final class NugetPublisherDescriptor extends BuildStepDescriptor<Publisher> {

Expand Down
Expand Up @@ -15,7 +15,6 @@
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
Expand Down
Expand Up @@ -40,4 +40,7 @@
<f:entry title="${%publishPath}" description="${%publishPathDescription}" field="publishPath">
<f:textbox value="${instance.publishPath}"/>
</f:entry>
<f:entry title="${%DoNotFailIfNoPackagesArePublished}" field="doNotFailIfNoPackagesArePublished">
<f:checkbox value="${instance.doNotFailIfNoPackagesArePublished}"/>
</f:entry>
</j:jelly>

0 comments on commit a5d359d

Please sign in to comment.