当前位置: 首页>>代码示例>>Java>>正文


Java Jenkins.getActiveInstance方法代码示例

本文整理汇总了Java中jenkins.model.Jenkins.getActiveInstance方法的典型用法代码示例。如果您正苦于以下问题:Java Jenkins.getActiveInstance方法的具体用法?Java Jenkins.getActiveInstance怎么用?Java Jenkins.getActiveInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jenkins.model.Jenkins的用法示例。


在下文中一共展示了Jenkins.getActiveInstance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: gatherEnvVarsMaster

import jenkins.model.Jenkins; //导入方法依赖的package包/类
@Nonnull
private static Map<String, String> gatherEnvVarsMaster(@Nonnull Job<?, ?> job) throws EnvInjectException {
    final Jenkins jenkins;
    try {
        jenkins = Jenkins.getActiveInstance();
    } catch(IllegalStateException ex) {
        throw new EnvInjectException(ex);
    }
    
    EnvVars env = new EnvVars();
    env.put("JENKINS_SERVER_COOKIE", Util.getDigestOf("ServerID:" + jenkins.getSecretKey()));
    env.put("HUDSON_SERVER_COOKIE", Util.getDigestOf("ServerID:" + jenkins.getSecretKey())); // Legacy compatibility
    env.put("JOB_NAME", job.getFullName());
    
    env.put("JENKINS_HOME", jenkins.getRootDir().getPath());
    env.put("HUDSON_HOME", jenkins.getRootDir().getPath());   // legacy compatibility

    String rootUrl = jenkins.getRootUrl();
    if (rootUrl != null) {
        env.put("JENKINS_URL", rootUrl);
        env.put("HUDSON_URL", rootUrl); // Legacy compatibility
        env.put("JOB_URL", rootUrl + job.getUrl());
    }

    return env;
}
 
开发者ID:jenkinsci,项目名称:envinject-api-plugin,代码行数:27,代码来源:EnvVarsResolver.java

示例2: doRun

import jenkins.model.Jenkins; //导入方法依赖的package包/类
@Override protected void doRun() throws Exception {

        // Trigger reprovisioning as well
        Jenkins.getActiveInstance().unlabeledNodeProvisioner.suggestReviewNow();

        final List<FleetStateStats> stats = new ArrayList<FleetStateStats>();
        for(final Cloud cloud : Jenkins.getActiveInstance().clouds) {
            if (!(cloud instanceof EC2FleetCloud))
                continue;

            // Update the cluster states
            final EC2FleetCloud fleetCloud =(EC2FleetCloud) cloud;
            LOGGER.log(Level.FINE, "Checking cloud: " + fleetCloud.getLabelString() );
            stats.add(fleetCloud.updateStatus());
        }

        for (final Widget w : Jenkins.getInstance().getWidgets()) {
            if (!(w instanceof FleetStatusWidget))
                continue;

            ((FleetStatusWidget)w).setStatusList(stats);
        }
    }
 
开发者ID:awslabs,项目名称:ec2-spot-jenkins-plugin,代码行数:24,代码来源:CloudNanny.java

示例3: find

import jenkins.model.Jenkins; //导入方法依赖的package包/类
/**
 * Search in Jenkins for a item with type T based on the job name
 * @param jobName job to find, for jobs inside a folder use : {@literal <folder>/<folder>/<jobName>}
 * @return the Job matching the given name, or {@code null} when not found
 */
static <T extends Item> T find(String jobName, Class<T> type) {
	Jenkins jenkins = Jenkins.getActiveInstance();
	// direct search, can be used to find folder based items <folder>/<folder>/<jobName>
	T item = jenkins.getItemByFullName(jobName, type);
	if (item == null) {
		// not found in a direct search, search in all items since the item might be in a folder but given without folder structure
		// (to keep it backwards compatible)
		for (T allItem : jenkins.getAllItems(type)) {
			 if (allItem.getName().equals(jobName)) {
			 	item = allItem;
			 	break;
			 }
		}
	}
	return item;
}
 
开发者ID:jenkinsci,项目名称:gogs-webhook-plugin,代码行数:22,代码来源:GogsUtils.java

示例4: triggerJobs

import jenkins.model.Jenkins; //导入方法依赖的package包/类
public GogsResults triggerJobs(String jobName, String deliveryID) {
  SecurityContext saveCtx = null;
  GogsResults result = new GogsResults();

  try {
    saveCtx = SecurityContextHolder.getContext();

    Jenkins instance = Jenkins.getActiveInstance();
    if (instance!=null) {
      ACL acl = instance.getACL();
      acl.impersonate(ACL.SYSTEM);

      BuildableItem project = GogsUtils.find(jobName, BuildableItem.class);
      if (project != null) {
        Cause cause = new GogsCause(deliveryID);
        project.scheduleBuild(0, cause);
        result.setMessage(String.format("Job '%s' is executed",jobName));
      } else {
        String msg = String.format("Job '%s' is not defined in Jenkins",jobName);
        result.setStatus(404, msg);
        LOGGER.warning(msg);
      }
    }
  } catch (Exception e) {
  } finally {
      SecurityContextHolder.setContext(saveCtx);
  }

  return result;
}
 
开发者ID:jenkinsci,项目名称:gogs-webhook-plugin,代码行数:31,代码来源:GogsPayloadProcessor.java

示例5: getComputer

import jenkins.model.Jenkins; //导入方法依赖的package包/类
/**
 * Gets the computer for the current launcher.
 *
 * @return the computer
 * @throws AbortException in case of error.
 */
@Nonnull
private Computer getComputer() throws AbortException {
    if (computer != null) {
        return computer;
    }

    String node = null;
    Jenkins j = Jenkins.getActiveInstance();

    for (Computer c : j.getComputers()) {
        if (c.getChannel() == launcher.getChannel()) {
            node = c.getName();
            break;
        }
    }

    if (node == null) {
        throw new AbortException("Could not find computer for the job");
    }

    computer = j.getComputer(node);
    if (computer == null) {
        throw new AbortException("No such computer " + node);
    }

    if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.log(Level.FINE, "Computer: {0}", computer.getName());
        try {
            LOGGER.log(Level.FINE, "Env: {0}", computer.getEnvironment());
        } catch (IOException | InterruptedException e) {// ignored
        }
    }
    return computer;
}
 
开发者ID:jenkinsci,项目名称:pipeline-maven-plugin,代码行数:41,代码来源:WithMavenStepExecution.java

示例6: isMultiScmAvailable

import jenkins.model.Jenkins; //导入方法依赖的package包/类
private boolean isMultiScmAvailable() {
    final Jenkins jenkins = Jenkins.getActiveInstance();
    boolean hasPlugin = jenkins.getPlugin("multiple-scms") != null;
    log.debug("Multiple-SCMs plugin found: %s", hasPlugin);
    return hasPlugin;
}
 
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:7,代码来源:ScmJobEventTriggerMatcher.java

示例7: isGitScmAvailable

import jenkins.model.Jenkins; //导入方法依赖的package包/类
private boolean isGitScmAvailable() {
    final Jenkins jenkins = Jenkins.getActiveInstance();
    boolean hasPlugin = jenkins.getPlugin("git") != null;
    log.debug("Git plugin found: %s", hasPlugin);
    return hasPlugin;
}
 
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:7,代码来源:ScmJobEventTriggerMatcher.java


注:本文中的jenkins.model.Jenkins.getActiveInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。