本文整理了Java中hudson.model.Environment
类的一些代码示例,展示了Environment
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment
类的具体详情如下:
包路径:hudson.model.Environment
类名称:Environment
[英]Represents some resources that are set up for the duration of a build to be torn down when the build is over.
This is often used to run a parallel server necessary during a build, such as an application server, a database reserved for the build, X server for performing UI tests, etc.
By having a plugin that does this, instead of asking each build script to do this, we can simplify the build script. Environment abstraction also gives you guaranteed "tear down" phase, so that such resource won't keep running forever.
[中]表示在生成期间设置的一些资源,这些资源将在生成结束时被拆除。
这通常用于运行构建期间所需的并行服务器,例如应用程序服务器、为构建保留的数据库、用于执行UI测试的X服务器等。
通过有一个插件来实现这一点,我们可以简化构建脚本,而不是要求每个构建脚本都这样做。环境抽象还为您提供了有保证的“拆卸”阶段,这样这些资源就不会永远运行。
代码示例来源:origin: jenkinsci/jenkins
@Override
public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException {
EnvVars env = super.getEnvironment(log);
FilePath ws = getWorkspace();
if (ws!=null) // if this is done very early on in the build, workspace may not be decided yet. see HUDSON-3997
env.put("WORKSPACE", ws.getRemote());
project.getScm().buildEnvVars(this,env);
if (buildEnvironments!=null)
for (Environment e : buildEnvironments)
e.buildEnvVars(env);
for (EnvironmentContributingAction a : getActions(EnvironmentContributingAction.class))
a.buildEnvVars(this,env);
EnvVars.resolve(env);
return env;
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public Environment setUp(AbstractBuild build, Launcher launcher,
BuildListener listener) throws IOException, InterruptedException {
return Environment.create(envVars);
}
代码示例来源:origin: org.jvnet.hudson.plugins/ivy
return Result.FAILURE;
buildEnvironments.add(e);
e.buildEnvVars(envVars); // #3502: too late for
if (!buildEnvironments.get(i).tearDown(IvyModuleSetBuild.this, listener)) {
failed = true;
代码示例来源:origin: groupon/DotCi
public boolean tearDownBuildEnvironments(final BuildListener listener) throws IOException, InterruptedException {
boolean failed = false;
final List<Environment> buildEnvironments = getBuildEnvironments();
for (int i = buildEnvironments.size() - 1; i >= 0; i--) {
if (!buildEnvironments.get(i).tearDown(this.build, listener)) {
failed = true;
}
}
return failed;
}
代码示例来源:origin: org.hudsonci.plugins/ivy
return Result.FAILURE;
buildEnvironments.add(e);
e.buildEnvVars(envVars); // #3502: too late for
if (!buildEnvironments.get(i).tearDown(IvyModuleSetBuild.this, listener)) {
failed = true;
代码示例来源:origin: com.cloudbees.plugins/build-flow-plugin
protected Result doRun(BuildListener listener) throws Exception {
if(!preBuild(listener, project.getPublishersList()))
return FAILURE;
try {
setResult(SUCCESS);
if (dslFile != null) {
listener.getLogger().printf("[build-flow] reading DSL from file '%s'\n", dslFile);
String fileContent = getWorkspace().child(dslFile).readToString();
new FlowDSL().executeFlowScript(FlowRun.this, fileContent, listener);
} else {
new FlowDSL().executeFlowScript(FlowRun.this, dsl, listener);
}
} finally {
boolean failed=false;
for( int i=buildEnvironments.size()-1; i>=0; i-- ) {
if (!buildEnvironments.get(i).tearDown(FlowRun.this,listener)) {
failed=true;
}
}
if (failed) return Result.FAILURE;
}
return getState().getResult();
}
代码示例来源:origin: jenkinsci/envinject-plugin
@Nonnull
public static Map<String, String> getEnvVarsPreviousSteps(
@Nonnull Run<?, ?> build, @Nonnull EnvInjectLogger logger)
throws IOException, InterruptedException, EnvInjectException {
Map<String, String> result = new HashMap<String, String>();
// Env vars contributed by build wrappers; no replacement in Pipeline
if (build instanceof AbstractBuild) {
List<Environment> environmentList = ((AbstractBuild)build).getEnvironments();
if (environmentList != null) {
for (Environment e : environmentList) {
if (e != null) {
e.buildEnvVars(result);
}
}
}
}
EnvInjectPluginAction envInjectAction = build.getAction(EnvInjectPluginAction.class);
if (envInjectAction != null) {
result.putAll(getCurrentInjectedEnvVars(envInjectAction));
//Add build variables with axis for a MatrixRun
if (build instanceof MatrixRun) {
result.putAll(((MatrixRun)build).getBuildVariables());
}
} else {
result.putAll(EnvInjectVariableGetter.getJenkinsSystemEnvVars(false));
result.putAll(getBuildVariables(build, logger));
}
return result;
}
代码示例来源:origin: org.jenkins-ci.plugins/ivy
return Result.FAILURE;
buildEnvironments.add(e);
e.buildEnvVars(envVars); // #3502: too late for
if (!buildEnvironments.get(i).tearDown(IvyModuleSetBuild.this, listener)) {
failed = true;
代码示例来源:origin: org.hudsonci.plugins/ivy
if (!buildEnvironments.get(i).tearDown(IvyBuild.this, listener)) {
failed = true;
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
@Override
public Environment setUp(AbstractBuild build, Launcher launcher,
BuildListener listener) throws IOException, InterruptedException {
return Environment.create(envVars);
}
代码示例来源:origin: jenkinsci/docker-custom-build-environment-plugin
private EnvVars buildContainerEnvironment() throws IOException, InterruptedException {
if (this.env == null) {
this.env = runInContainer.getDocker().getEnv(runInContainer.container, launcher);
}
EnvVars environment = new EnvVars(env);
// Let BuildWrapper customize environment, including PATH
for (Environment e : build.getEnvironments()) {
e.buildEnvVars(environment);
}
return environment;
}
代码示例来源:origin: org.jvnet.hudson.main/maven-plugin
return (r = Result.FAILURE);
buildEnvironments.add(e);
e.buildEnvVars(envVars); // #3502: too late for getEnvironment to do this
if (!buildEnvironments.get(i).tearDown(MavenModuleSetBuild.this,listener)) {
failed=true;
代码示例来源:origin: org.jenkins-ci.plugins/ivy
if (!buildEnvironments.get(i).tearDown(IvyBuild.this, listener)) {
failed = true;
代码示例来源:origin: org.eclipse.hudson/hudson-core
@Override
public Environment setUp(AbstractBuild build, Launcher launcher,
BuildListener listener) throws IOException, InterruptedException {
return Environment.create(envVars);
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@Override
public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException {
EnvVars env = super.getEnvironment(log);
FilePath ws = getWorkspace();
if (ws!=null) // if this is done very early on in the build, workspace may not be decided yet. see HUDSON-3997
env.put("WORKSPACE", ws.getRemote());
project.getScm().buildEnvVars(this,env);
if (buildEnvironments!=null)
for (Environment e : buildEnvironments)
e.buildEnvVars(env);
for (EnvironmentContributingAction a : getActions(EnvironmentContributingAction.class))
a.buildEnvVars(this,env);
EnvVars.resolve(env);
return env;
}
代码示例来源:origin: org.jvnet.hudson.plugins/ivy
if (!buildEnvironments.get(i).tearDown(IvyBuild.this, listener)) {
failed = true;
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@Override
public Environment setUp(AbstractBuild build, Launcher launcher,
BuildListener listener) throws IOException, InterruptedException {
return Environment.create(envVars);
}
代码示例来源:origin: org.hudsonci.plugins/git
Environment environment = nodeProperty.setUp(b, launcher, (BuildListener) buildListener);
if (environment != null) {
environment.buildEnvVars(env);
Environment environment = nodeProperty.setUp(b, launcher, buildListener);
if (environment != null) {
environment.buildEnvVars(env);
代码示例来源:origin: jenkinsci/promoted-builds-plugin
if (!buildEnvironments.get(i).tearDown(Promotion.this,listener)) {
failed=true;
代码示例来源:origin: hudson/hudson-2.x
@Override
public Environment setUp(AbstractBuild build, Launcher launcher,
BuildListener listener) throws IOException, InterruptedException {
return Environment.create(envVars);
}
内容来源于网络,如有侵权,请联系作者删除!