Java 类hudson.model.EnvironmentContributor 实例源码

项目:p4-jenkins    文件:ApproveNotifier.java   
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
        throws InterruptedException, IOException {

    AbstractProject<?, ?> job = build.getParent();
    Node node = build.getBuiltOn();
    EnvVars env = job.getEnvironment(node, listener);

    for (EnvironmentContributor ec : EnvironmentContributor.all().reverseView()) {
        ec.buildEnvironmentFor(build, env, listener);
    }

    ConnectionHelper p4 = new ConnectionHelper(job, getCredential(), listener);

    try {
        return approveReview(p4, env);
    } catch (Exception e) {
        throw new InterruptedException("Unable to update Review.");
    }
}
项目:p4-jenkins    文件:ApproveNotifierStep.java   
@Override
public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath buildWorkspace,
                    @Nonnull Launcher launcher, @Nonnull TaskListener listener)
        throws InterruptedException, IOException {

    EnvVars env = run.getEnvironment(listener);

    for (EnvironmentContributor ec : EnvironmentContributor.all().reverseView()) {
        ec.buildEnvironmentFor(run, env, listener);
    }

    ConnectionHelper p4 = new ConnectionHelper(run, getCredential(), listener);

    try {
        approveReview(p4, env);
    } catch (Exception e) {
        throw new IOException("Unable to update Review.", e);
    }
}
项目:yet-another-docker-plugin    文件:DockerShellStep.java   
/**
 * Return all job related vars without executor vars.
 * I.e. slave is running in osx, but docker image for shell is linux.
 */
protected static EnvVars getEnvVars(Run run, TaskListener listener) throws IOException, InterruptedException {
    final EnvVars envVars = run.getCharacteristicEnvVars();

    // from run.getEnvironment(listener) but without computer vars
    for (EnvironmentContributor ec : EnvironmentContributor.all().reverseView()) {
        // job vars
        ec.buildEnvironmentFor(run.getParent(), envVars, listener);

        // build vars
        if (ec instanceof CoreEnvironmentContributor) {
            // exclude executor computer related vars
            envVars.put("BUILD_DISPLAY_NAME", run.getDisplayName());

            String rootUrl = Jenkins.getInstance().getRootUrl();
            if (rootUrl != null) {
                envVars.put("BUILD_URL", rootUrl + run.getUrl());
            }

            // and remove useless job var from CoreEnvironmentContributor
            envVars.remove("JENKINS_HOME");
            envVars.remove("HUDSON_HOME");
        } else {
            ec.buildEnvironmentFor(run, envVars, listener); // build vars
        }
    }


    return envVars;
}