本文整理了Java中jenkins.model.Jenkins.getGlobalNodeProperties()
方法的一些代码示例,展示了Jenkins.getGlobalNodeProperties()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jenkins.getGlobalNodeProperties()
方法的具体详情如下:
包路径:jenkins.model.Jenkins
类名称:Jenkins
方法名:getGlobalNodeProperties
暂无
代码示例来源:origin: jenkinsci/jenkins
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
try {
Jenkins j = Jenkins.get();
JSONObject np = json.getJSONObject("globalNodeProperties");
if (!np.isNullObject()) {
j.getGlobalNodeProperties().rebuild(req, np, NodeProperty.for_(j));
}
return true;
} catch (IOException e) {
throw new FormException(e,"globalNodeProperties");
}
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Creates an environment variable override to be used for launching processes on this node.
*
* @see ProcStarter#envs(Map)
* @since 1.489
*/
public @Nonnull EnvVars buildEnvironment(@Nonnull TaskListener listener) throws IOException, InterruptedException {
EnvVars env = new EnvVars();
Node node = getNode();
if (node==null) return env; // bail out
for (NodeProperty nodeProperty: Jenkins.getInstance().getGlobalNodeProperties()) {
nodeProperty.buildEnvVars(env,listener);
}
for (NodeProperty nodeProperty: node.getNodeProperties()) {
nodeProperty.buildEnvVars(env,listener);
}
// TODO: hmm, they don't really belong
String rootUrl = Jenkins.getInstance().getRootUrl();
if(rootUrl!=null) {
env.put("HUDSON_URL", rootUrl); // Legacy.
env.put("JENKINS_URL", rootUrl);
}
return env;
}
代码示例来源:origin: jenkinsci/envinject-plugin
private boolean isGlobalEnvInjectActivatedOnMaster() {
DescribableList<NodeProperty<?>, NodePropertyDescriptor> globalNodeProperties = Jenkins.getActiveInstance().getGlobalNodeProperties();
for (NodeProperty<?> nodeProperty : globalNodeProperties) {
if (nodeProperty instanceof EnvInjectNodeProperty) {
return true;
}
}
return false;
}
代码示例来源:origin: jenkinsci/ssh-slaves-plugin
private EnvVars getEnvVars(Jenkins h) {
return getEnvVars(h.getGlobalNodeProperties());
}
代码示例来源:origin: org.jenkins-ci.plugins/ssh-slaves
private EnvVars getEnvVars(Jenkins h) {
return getEnvVars(h.getGlobalNodeProperties());
}
代码示例来源:origin: jenkinsci/envinject-plugin
);
for (NodeProperty<?> nodeProperty : Jenkins.getActiveInstance().getGlobalNodeProperties()) {
if (nodeProperty instanceof EnvironmentVariablesNodeProperty) {
EnvironmentVariablesNodeProperty variablesNodeProperty = (EnvironmentVariablesNodeProperty) nodeProperty;
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
try {
Jenkins j = Jenkins.getInstance();
JSONObject np = json.getJSONObject("globalNodeProperties");
if (!np.isNullObject()) {
j.getGlobalNodeProperties().rebuild(req, np, NodeProperty.for_(j));
}
return true;
} catch (IOException e) {
throw new FormException(e,"globalNodeProperties");
}
}
}
代码示例来源:origin: jenkinsci/docker-plugin
final EnvVars knownVariables = new EnvVars();
final Jenkins j = Jenkins.getInstance();
addEnvVars(knownVariables, j.getGlobalNodeProperties());
for (final ArgumentVariables v : ArgumentVariables.values()) {
代码示例来源:origin: org.jenkins-ci.plugins.workflow/workflow-job
@Override public EnvVars getEnvironment(TaskListener listener) throws IOException, InterruptedException {
EnvVars env = super.getEnvironment(listener);
Jenkins instance = Jenkins.getInstance();
if (instance != null) {
for (NodeProperty nodeProperty : instance.getGlobalNodeProperties()) {
nodeProperty.buildEnvVars(env, listener);
}
}
// TODO EnvironmentContributingAction does not support Job yet:
ParametersAction a = getAction(ParametersAction.class);
if (a != null) {
for (ParameterValue v : a) {
v.buildEnvironment(this, env);
}
}
EnvVars.resolve(env);
return env;
}
代码示例来源:origin: openshift/jenkins-plugin
if (Jenkins.getInstance().getGlobalNodeProperties() != null) {
if (Jenkins.getInstance().getGlobalNodeProperties()
.get(hudson.slaves.EnvironmentVariablesNodeProperty.class) != null) {
if (Jenkins
.getInstance()
.getGlobalNodeProperties()
.get(hudson.slaves.EnvironmentVariablesNodeProperty.class)
.getEnvVars() != null) {
.putAll(Jenkins
.getInstance()
.getGlobalNodeProperties()
.get(hudson.slaves.EnvironmentVariablesNodeProperty.class)
.getEnvVars());
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Creates an environment variable override to be used for launching processes on this node.
*
* @see ProcStarter#envs(Map)
* @since 1.489
*/
public @Nonnull EnvVars buildEnvironment(@Nonnull TaskListener listener) throws IOException, InterruptedException {
EnvVars env = new EnvVars();
Node node = getNode();
if (node==null) return env; // bail out
for (NodeProperty nodeProperty: Jenkins.getInstance().getGlobalNodeProperties()) {
nodeProperty.buildEnvVars(env,listener);
}
for (NodeProperty nodeProperty: node.getNodeProperties()) {
nodeProperty.buildEnvVars(env,listener);
}
// TODO: hmm, they don't really belong
String rootUrl = Jenkins.getInstance().getRootUrl();
if(rootUrl!=null) {
env.put("HUDSON_URL", rootUrl); // Legacy.
env.put("JENKINS_URL", rootUrl);
}
return env;
}
代码示例来源:origin: uber/phabricator-jenkins-plugin
public static void setEnvironmentVariables(JenkinsRule j, Map<String, String> params) throws IOException {
EnvironmentVariablesNodeProperty prop = new EnvironmentVariablesNodeProperty();
EnvVars envVars = prop.getEnvVars();
envVars.putAll(params);
j.jenkins.getGlobalNodeProperties().add(prop);
}
代码示例来源:origin: jenkinsci/envinject-plugin
for (NodeProperty<?> nodeProperty : Jenkins.getActiveInstance().getGlobalNodeProperties()) {
代码示例来源:origin: carlossg/jenkins-kubernetes-plugin
@Before
public void configureCloud() throws Exception {
cloud = setupCloud(this);
createSecret(cloud.connect());
cloud.getTemplates().clear();
cloud.addTemplate(buildBusyboxTemplate("busybox"));
// Agents running in Kubernetes (minikube) need to connect to this server, so localhost does not work
URL url = r.getURL();
String hostAddress = System.getProperty("jenkins.host.address");
if (hostAddress == null) {
hostAddress = InetAddress.getLocalHost().getHostAddress();
}
URL nonLocalhostUrl = new URL(url.getProtocol(), hostAddress, url.getPort(),
url.getFile());
JenkinsLocationConfiguration.get().setUrl(nonLocalhostUrl.toString());
r.jenkins.clouds.add(cloud);
DescribableList<NodeProperty<?>, NodePropertyDescriptor> list = r.jenkins.getGlobalNodeProperties();
EnvironmentVariablesNodeProperty newEnvVarsNodeProperty = new hudson.slaves.EnvironmentVariablesNodeProperty();
list.add(newEnvVarsNodeProperty);
EnvVars envVars = newEnvVarsNodeProperty.getEnvVars();
envVars.put("GLOBAL", "GLOBAL");
envVars.put("JAVA_HOME_X", "java-home-x");
r.jenkins.save();
}
代码示例来源:origin: jenkinsci/shiningpanda-plugin
/**
* Get the home directory for the given node.
*
* @param node
* The node
* @return The home directory
*/
public static FilePath get(Node node) {
// Get the potential properties
WorkspaceHomeProperty[] properties = new WorkspaceHomeProperty[] {
node.getNodeProperties().get(WorkspaceHomeProperty.class),
Jenkins.getInstance().getGlobalNodeProperties().get(WorkspaceHomeProperty.class) };
// Go threw the properties
for (WorkspaceHomeProperty property : properties)
// Check if exists
if (property != null)
// Check if valid
if (Util.fixEmpty(property.getHome()) != null)
// Return the home folder
return new FilePath(node.getChannel(), property.getHome());
// Else relative to root
return node.getRootPath().child(Workspace.BASENAME).child("jobs");
}
代码示例来源:origin: org.jenkins-ci.plugins/git
env.put("WORKSPACE", ws.getRemote());
for (NodeProperty nodeProperty: jenkinsInstance.getGlobalNodeProperties()) {
Environment environment = nodeProperty.setUp(b, launcher, (BuildListener)buildListener);
if (environment != null) {
代码示例来源:origin: carlossg/jenkins-kubernetes-plugin
Jenkins instance = Jenkins.getInstance();
DescribableList<NodeProperty<?>, NodePropertyDescriptor> globalNodeProperties = instance.getGlobalNodeProperties();
List<EnvironmentVariablesNodeProperty> envVarsNodePropertyList = globalNodeProperties
.getAll(EnvironmentVariablesNodeProperty.class);
代码示例来源:origin: jenkinsci/subversion-plugin
/**
* This test aims to verify that the environment variables (from Global Properties section) are available in SCM
* Polling.
*/
@Ignore("TODO org.tmatesoft.svn.core.SVNException: svn: E175002: PROPFIND of '/trunk/jenkins/test-projects/model-maven-project': 405 Method Not Allowed (https://svn.jenkins-ci.org)")
@Issue("JENKINS-31067")
@Test
public void pollingWithEnvVars() throws Exception {
jenkins.getInstance().getGlobalNodeProperties().add(new EnvironmentVariablesNodeProperty(new
EnvironmentVariablesNodeProperty.Entry("BRANCH", "trunk")));
FreeStyleProject project = jenkins.createFreeStyleProject();
project.setScm(new SubversionSCM(REPO_URL));
jenkins.assertBuildStatusSuccess(project.scheduleBuild2(0).get());
TaskListener listener = jenkins.createTaskListener();
PollingResult poll = project.poll(listener);
assertFalse(poll.hasChanges());
}
}
内容来源于网络,如有侵权,请联系作者删除!