Skip to content

Commit

Permalink
Decorate build in Notifier if Wrapper is skipped
Browse files Browse the repository at this point in the history
Fixes #54
  • Loading branch information
ascandella committed Aug 9, 2015
1 parent 0e30f25 commit 7e2f5be
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Expand Up @@ -65,7 +65,6 @@ public Environment setUp(AbstractBuild build,
final String arcPath = this.getArcPath();

final Map<String, String> envAdditions = new HashMap<String, String>();
envAdditions.put(PhabricatorPlugin.WRAP_KEY, "true");
envAdditions.put(PhabricatorPlugin.ARCANIST_PATH, arcPath);

final String conduitToken = this.getConduitToken(build.getParent(), logger);
Expand Down
Expand Up @@ -84,7 +84,7 @@ public final boolean perform(final AbstractBuild<?, ?> build, final Launcher lau
final String branch = environment.get("GIT_BRANCH");
final UberallsClient uberalls = new UberallsClient(getDescriptor().getUberallsURL(), logger,
environment.get("GIT_URL"), branch);
final boolean needsDecoration = environment.get(PhabricatorPlugin.WRAP_KEY, null) == null;
final boolean needsDecoration = build.getActions(PhabricatorPostbuildAction.class).size() == 0;

final String conduitToken = getConduitToken(build.getParent(), logger);

Expand Down Expand Up @@ -118,6 +118,10 @@ public final boolean perform(final AbstractBuild<?, ?> build, final Launcher lau
return true;
}

if (needsDecoration) {
diff.decorate(build, this.getPhabricatorURL(build.getParent()));
}

String revisionID = diff.getRevisionID(true);
if (CommonUtils.isBlank(revisionID)) {
return this.ignoreBuild(logger.getStream(), "Unable to load revisionID from conduit for diff ID " + diffID);
Expand Down Expand Up @@ -236,14 +240,22 @@ public String getCommentFile() {
}

public String getConduitToken(Job owner, Logger logger) {
ConduitCredentials credentials = this.getDescriptor().getCredentials(owner);
ConduitCredentials credentials = getDescriptor().getCredentials(owner);
if (credentials != null) {
return credentials.getToken().getPlainText();
}
logger.warn("credentials", "No credentials configured.");
return null;
}

public String getPhabricatorURL(Job owner) {
ConduitCredentials credentials = getDescriptor().getCredentials(owner);
if (credentials != null) {
return credentials.getUrl();
}
return null;
}

// Overridden for better type safety.
@Override
public PhabricatorNotifierDescriptor getDescriptor() {
Expand Down
Expand Up @@ -34,8 +34,6 @@ public class PhabricatorPlugin extends Plugin {
// Phabricator object ID (for Harbormaster)
static final String PHID_FIELD = "PHID";

static final String WRAP_KEY = "PHABRICATOR_JENKINS";

public static String getIconPath(String icon) {
if (icon == null) {
return null;
Expand Down

0 comments on commit 7e2f5be

Please sign in to comment.