hudson.model.Build Java Examples

The following examples show how to use hudson.model.Build. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VaultBuildWrapperTest.java    From hashicorp-vault-plugin with MIT License 6 votes vote down vote up
@Test
public void testWithNonExistingPath() throws IOException, InterruptedException {
    String path = "not/existing";
    TestWrapper wrapper = new TestWrapper(standardSecrets(path));
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream logger = new PrintStream(baos);
    SimpleBuildWrapper.Context context = null;
    Run<?, ?> build = mock(Build.class);
    when(build.getParent()).thenReturn(null);
    EnvVars envVars = mock(EnvVars.class);
    when(envVars.expand(path)).thenReturn(path);

    wrapper.run(context, build, envVars, logger);

    try { // now we expect the exception to raise
        wrapper.vaultConfig.setFailIfNotFound(true);
        wrapper.run(context, build, envVars, logger);
    } catch (VaultPluginException e) {
        assertThat(e.getMessage(), is("Vault credentials not found for 'not/existing'"));
    }

    wrapper.verifyCalls();
    assertThat(new String(baos.toByteArray(), StandardCharsets.UTF_8),
        containsString("Vault credentials not found for 'not/existing'"));
}
 
Example #2
Source File: DynamicBuild.java    From DotCi with MIT License 6 votes vote down vote up
@Override
public Object getDynamic(final String token, final StaplerRequest req, final StaplerResponse rsp) {
    try {
        final Build item = getRun(Combination.fromString(token));
        if (item != null) {
            if (item.getNumber() == this.getNumber()) {
                return item;
            } else {
                // redirect the user to the correct URL
                String url = Functions.joinPath(item.getUrl(), req.getRestOfPath());
                final String qs = req.getQueryString();
                if (qs != null) {
                    url += '?' + qs;
                }
                throw HttpResponses.redirectViaContextPath(url);
            }
        }
    } catch (final IllegalArgumentException e) {
        // failed to parse the token as Combination. Must be something else
    }
    return super.getDynamic(token, req, rsp);
}
 
Example #3
Source File: DynamicBuild.java    From DotCi with MIT License 5 votes vote down vote up
public Build getRun(final Combination combination) {
    for (final DynamicSubProject subProject : getAllSubProjects()) {
        if (subProject.getCombination().equals(combination)) {
            return getRunForConfiguration(subProject);
        }

    }
    return null;
}
 
Example #4
Source File: DynamicRunPtr.java    From DotCi with MIT License 5 votes vote down vote up
public String getNearestRunUrl() {
    final
    Build r = getRun();
    if (r == null) {
        return null;
    }
    if (this.dynamicBuild.getNumber() == r.getNumber()) {
        return getShortUrl() + "/console";
    }
    return Stapler.getCurrentRequest().getContextPath() + '/' + r.getUrl();
}
 
Example #5
Source File: DynamicRunPtr.java    From DotCi with MIT License 5 votes vote down vote up
public String getTooltip() {
    final Build r = getRun();
    if (r != null) {
        return r.getIconColor().getDescription();
    }
    final Queue.Item item = Jenkins.getInstance().getQueue().getItem(this.dynamicBuild.getParent().getItem(this.combination));
    if (item != null) {
        return item.getWhy();
    }
    return null; // fall back
}
 
Example #6
Source File: DynamicRunPtr.java    From DotCi with MIT License 4 votes vote down vote up
public Build getRun() {
    return this.dynamicBuild.getRun(this.combination);
}