當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。