Skip to content

Commit

Permalink
Merge pull request #100 from SHildebrandt/master
Browse files Browse the repository at this point in the history
Fixed Wercker environment variables
  • Loading branch information
trautonen authored Sep 5, 2016
2 parents 0c780b0 + e764098 commit a07d85b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
public class Wercker extends AbstractServiceSetup {

public static final String WERCKER_NAME = "wercker";
public static final String WERCKER_BUILD_URL = "WERCKER_RUN_URL";
public static final String WERCKER = "WERCKER";
public static final String WERCKER_BUILD_ID = "WERCKER_BUILD_ID";
public static final String WERCKER_BUILD_URL = "WERCKER_BUILD_URL";
public static final String WERCKER_BRANCH = "WERCKER_GIT_BRANCH";

public Wercker(final Map<String, String> env) {
Expand All @@ -45,7 +47,7 @@ public Wercker(final Map<String, String> env) {

@Override
public boolean isSelected() {
return getProperty(WERCKER_BRANCH) != null;
return "true".equalsIgnoreCase(getProperty(WERCKER));
}

@Override
Expand All @@ -55,8 +57,7 @@ public String getName() {

@Override
public String getJobId() {
final String buildUrl = getBuildUrl();
return buildUrl.substring(buildUrl.lastIndexOf("/") + 1);
return getProperty(WERCKER_BUILD_ID);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public class WerckerTest {

private Map<String, String> env() {
Map<String, String> env = new HashMap<String, String>();
env.put("WERCKER_RUN_URL", "https://app.wercker.com/build/123456789");
env.put("WERCKER", "true");
env.put("WERCKER_BUILD_URL", "https://app.wercker.com/build/123456789");
env.put("WERCKER_BUILD_ID", "123456789");
env.put("WERCKER_GIT_BRANCH", "master");
return env;
}
Expand All @@ -50,7 +52,7 @@ public void testIsSelectedForNothing() {
}

@Test
public void testIsSelectedForTravis() {
public void testIsSelectedForWercker() {
assertTrue(new Wercker(env()).isSelected());
}

Expand All @@ -64,6 +66,11 @@ public void testGetJobId() {
assertEquals("123456789", new Wercker(env()).getJobId());
}

@Test
public void testGetBuildUrl() {
assertEquals("https://app.wercker.com/build/123456789", new Wercker(env()).getBuildUrl());
}

@Test
public void testGetBranch() {
assertEquals("master", new Wercker(env()).getBranch());
Expand Down

0 comments on commit a07d85b

Please sign in to comment.