Skip to content

Commit

Permalink
Merge pull request #7 from Greybird/JENKINS-35316
Browse files Browse the repository at this point in the history
JENKINS-35316 : Nuget plugin publication succeeds when nupkg doesn't exist
  • Loading branch information
Greybird committed Aug 5, 2016
2 parents 0f364f1 + a5d359d commit d4c02c7
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 24 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
@@ -1,15 +1,8 @@
NugetCause.Cause=A package has been updated

NugetTrigger.DiplayName=Build on NuGet updates

NugetGlobalConfiguration.MandatoryProperty=This property is mandatory.

NugetPublisher.DisplayName=Publish NuGet packages

NugetPublisher.DontStartOrEndWithSlash=Cannot start or end with a slash.

NugetPublisher.BackSlash=Cannot contain backslashes.

NugetPromotionPublisher.DisplayName=Publish NuGet packages in a promotion

exception.failedToGetPromotedBuild=Build in a Promotion, but failed to get the original build
@@ -1,10 +1,8 @@
NugetCause.Cause=Un package a été modifié;

NugetTrigger.DiplayName=Construire sur update de package NuGet

NugetGlobalConfiguration.MandatoryProperty=Cette propriété est obligatoire.

NugetPublisher.DisplayName=Publier des packages NuGet

NugetPublisher.DontStartOrEndWithSlash=Ne peut pas commencer ou se terminer par un slash.
NugetPublisher.BackSlash=Ne peut pas contenir de backslashes.
NugetPromotionPublisher.DisplayName=Publier des packages NuGet dans une promotion
exception.failedToGetPromotedBuild=Le build est une promotion, mais impossible d''accéder au build original.
Expand Up @@ -5,7 +5,6 @@
<f:textbox value="${instance.name}"/>
</f:entry>
<j:if test="${empty(nugetPublications)}">
<!-- no SonarQube installation is configured, so warn the user now -->
<f:entry title="${%NugetPublication}">
<div class="error">${%NugetPublication.error(rootURL)}</div>
</f:entry>
Expand Down Expand Up @@ -36,9 +35,12 @@
<f:entry title="${%FileExclusionPattern}" description="${%FileExclusionPatternDescription}" field="packagesExclusionPattern">
<f:textbox value="${instance.packagesExclusionPattern}"/>
</f:entry>
<f:entry title="${%publishPath}" description="${%publishPathDescription}" field="publishPath">
<f:textbox value="${instance.publishPath}"/>
</f:entry>
</j:otherwise>
</j:otherwise>
</j:choose>
<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>
@@ -1,9 +1,10 @@
Name=Name
NugetPublication=Publication
NugetPublication.error=There are no NuGet publication configured.<br/>\
Please configure a NuGet publication in the <a href="{0}/configure">system configuration</a>.
UseWorkspaceInPromotion=Use the workspace
FilePattern=Packages to publish
FilePatternDescription=A path relative to <a href='ws/' target=_new>the workspace root</a>, an Ant fileset pattern, or an environment variable.
FilePatternDescription=A path relative to <a href='ws/' target=_new>the workspace root</a>, an Ant <a href="http://ant.apache.org/manual/dirtasks.html#patterns" target=_new>fileset pattern</a>, or an environment variable.
FilePatternDescriptionPromotion=An Ant <a href="http://ant.apache.org/manual/dirtasks.html#patterns" target=_new>fileset pattern</a> <br />\
The base directory for this fileset is the artifacts directory of the build that is being promoted. Ensure that you \
"Archive the artifacts" in the Post-build Actions to make your artifacts available during a promotion<br/>\
Expand All @@ -12,3 +13,4 @@ FileExclusionPattern=Packages NOT to publish
FileExclusionPatternDescription=A path relative to <a href='ws/' target=_new>the workspace root</a>, an Ant fileset pattern, or an environment variable.
publishPath=Publish Path
publishPathDescription=A path, relative to the publication, where your package will be published.
DoNotFailIfNoPackagesArePublished=Consider no publication as success
@@ -1,9 +1,16 @@
Name=Nom
NugetPublication=Publication
NugetPublication.error=Aucune publication NuGet configurée<br/>\
Merci d'en configurer une dans <a href="{0}/configure" target="_new">la configuration système</a>.
Merci d''en configurer une dans <a href="{0}/configure" target="_new">la configuration système</a>.
UseWorkspaceInPromotion=Utiliser l''<a href='ws/'>espace de travail</a>
FilePattern=Packages à publier
FilePatternDescription=Chemin relatif à la racine du <a href='ws/'>workspace</a>, un patron Ant pour un fileset ou une variable d'environnement.
FilePatternDescription=Chemin relatif à la racine de l''<a href='ws/'>espace de travail</a>, un <a href="http://ant.apache.org/manual/dirtasks.html#patterns" target=_new>patron de fichiers Ant</a> ou une variable d''environnement.
FilePatternDescriptionPromotion=Un <a href="http://ant.apache.org/manual/dirtasks.html#patterns" target=_new>patron de fichiers Ant</a> <br />\
Le répertoire racine pour ce patron est le répertoire des artefacts du build promu. Assurez-vous d''"Archiver les artefacts"\
dans les actions à la suite du build afin de les rendre accessibles durant la promotion. Changez ce répertoire racine au profit du workspace en\
cochant la case à cocher "Utiliser l''<a href='ws/'>espace de travail</a>".
FileExclusionPattern=Packages à ne PAS publier
FileExclusionPatternDescription=Chemin relatif à la racine du <a href='ws/'>workspace</a>, un patron Ant pour un fileset ou une variable d'environnement.
FileExclusionPatternDescription=Chemin relatif à la racine l''<a href='ws/'>espace de travail</a>, un <a href="http://ant.apache.org/manual/dirtasks.html#patterns" target=_new>patron de fichiers Ant</a> ou une variable d''environnement.
publishPath=Chemin de publication
publishPathDescription=Un chemin, relatif à celui de la publication, où le package sera publié.
DoNotFailIfNoPackagesArePublished=Considérer l''absence de publication comme un succès

0 comments on commit d4c02c7

Please sign in to comment.