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


Java Stapler.getCurrentRequest方法代码示例

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


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

示例1: doIndex

import org.kohsuke.stapler.Stapler; //导入方法依赖的package包/类
@SuppressWarnings("unused")
public void doIndex() throws IOException {
  HttpServletRequest req = Stapler.getCurrentRequest();
  GerritProjectEvent projectEvent = getBody(req);

  log.info("GerritWebHook invoked for event " + projectEvent);

  List<Item> jenkinsItems = Jenkins.getActiveInstance().getAllItems();
  for (Item item : jenkinsItems) {
    if (item instanceof SCMSourceOwner) {
      SCMSourceOwner scmJob = (SCMSourceOwner) item;
      log.info("Found SCM job " + scmJob);
      List<SCMSource> scmSources = scmJob.getSCMSources();
      for (SCMSource scmSource : scmSources) {
        if (scmSource instanceof GerritSCMSource) {
          GerritSCMSource gerritSCMSource = (GerritSCMSource) scmSource;
          if (projectEvent.matches(gerritSCMSource.getRemote())) {
            log.info(
                "Triggering SCM event for source " + scmSources.get(0) + " on job " + scmJob);
            scmJob.onSCMSourceUpdated(scmSource);
          }
        }
      }
    }
  }
}
 
开发者ID:GerritForge,项目名称:gerrit-plugin,代码行数:27,代码来源:GerritWebHook.java

示例2: AbstractScriptableParameter

import org.kohsuke.stapler.Stapler; //导入方法依赖的package包/类
/**
 * Inherited constructor.
 *
 * {@inheritDoc}
 *
 * @param name name
 * @param description description
 * @param randomName parameter random generated name (uuid)
 * @param script script used to generate the list of parameter values
 */
protected AbstractScriptableParameter(String name, String description, String randomName, Script script) {
    super(name, description, randomName);
    this.script = script;
    // Try to get the project name from the current request. In case of being called in some other non-web way,
    // the name will be fetched later via Jenkins.getInstance() and iterating through all items. This is for a
    // performance wise approach first.
    final StaplerRequest currentRequest = Stapler.getCurrentRequest();
    String projectName = null;
    if (currentRequest != null) {
        final Ancestor ancestor = currentRequest.findAncestor(AbstractItem.class);
        if (ancestor != null) {
            final Object o = ancestor.getObject();
            if (o instanceof AbstractItem) {
                final AbstractItem parentItem = (AbstractItem) o;
                projectName = parentItem.getName();
            }
        }
    }
    this.projectName = projectName;
}
 
开发者ID:imoutsatsos,项目名称:uno-choice-plugin,代码行数:31,代码来源:AbstractScriptableParameter.java

示例3: getUpUrl

import org.kohsuke.stapler.Stapler; //导入方法依赖的package包/类
@Override
public String getUpUrl() {
    final StaplerRequest req = Stapler.getCurrentRequest();
    if (req != null) {
        final List<Ancestor> ancs = req.getAncestors();
        for (int i = 1; i < ancs.size(); i++) {
            if (ancs.get(i).getObject() == this) {
                final Object parentObj = ancs.get(i - 1).getObject();
                if (parentObj instanceof DynamicBuild || parentObj instanceof DynamicSubProject) {
                    return ancs.get(i - 1).getUrl() + '/';
                }
            }
        }
    }
    return super.getDisplayName();
}
 
开发者ID:groupon,项目名称:DotCi,代码行数:17,代码来源:DynamicSubBuild.java

示例4: getUsernameFromAuthCode

import org.kohsuke.stapler.Stapler; //导入方法依赖的package包/类
@SuppressWarnings("unused")
public String getUsernameFromAuthCode() {
    final StaplerRequest request = Stapler.getCurrentRequest();
    if (request.hasParameter(getCodeParamKey())) {
        final User user = getUserForActivationCode(request.getParameter(getCodeParamKey()));
        if (user != null) {
            return user.getId();
        }
    }
    return "";
}
 
开发者ID:inFullMobile,项目名称:restricted-register-plugin,代码行数:12,代码来源:HudsonSecurityRealmRegistration.java

示例5: isGetParamSecretValid

import org.kohsuke.stapler.Stapler; //导入方法依赖的package包/类
public static boolean isGetParamSecretValid() {
    String secret = null;
    final StaplerRequest request = Stapler.getCurrentRequest();
    if (request.hasParameter(BaseFormField.SECRET.getFieldName())) {
        secret = request.getParameter(BaseFormField.SECRET.getFieldName());
    }
    return isSecretKeyValid(secret);
}
 
开发者ID:inFullMobile,项目名称:restricted-register-plugin,代码行数:9,代码来源:SecretKeyChecker.java

示例6: getRedirectURL

import org.kohsuke.stapler.Stapler; //导入方法依赖的package包/类
@Override
protected String getRedirectURL(DisplayURLProvider provider) {
    StaplerRequest req = Stapler.getCurrentRequest();
    String page = req.getParameter("page");
    String url;
    if ("changes".equals(page)) {
        url = provider.getChangesURL(run);
    } else {
        url = provider.getRunURL(run);
    }
    return url;
}
 
开发者ID:jenkinsci,项目名称:display-url-api-plugin,代码行数:13,代码来源:RunDisplayAction.java

示例7: getProject

import org.kohsuke.stapler.Stapler; //导入方法依赖的package包/类
/**
 * Method will return current project.
 *
 * @return currentProject.
 */
public Project getProject() {
    Project currentProject = null;
    StaplerRequest request = Stapler.getCurrentRequest();
    if (request != null) {
        currentProject = request.findAncestorObject(Project.class);
    }
    return currentProject;
}
 
开发者ID:myzhan,项目名称:gitlab-build-plugin,代码行数:14,代码来源:GitlabWebhookAction.java

示例8: getUrl

import org.kohsuke.stapler.Stapler; //导入方法依赖的package包/类
public static String getUrl(FlowNode node) {
    StaplerRequest currentRequest = Stapler.getCurrentRequest();
    String path = currentRequest.getContextPath();
    if (!path.endsWith("/")) {
        path += "/";
    }
    return path + "fabric8/";
}
 
开发者ID:fabric8io,项目名称:fabric8-jenkins-workflow-steps,代码行数:9,代码来源:FlowNodeAction.java

示例9: getUrl

import org.kohsuke.stapler.Stapler; //导入方法依赖的package包/类
public static String getUrl(WorkflowRun node) {
    StaplerRequest currentRequest = Stapler.getCurrentRequest();
    String path = currentRequest.getContextPath();
    if (!path.endsWith("/")) {
        path += "/";
    }
    return path + "fabric8/";
}
 
开发者ID:fabric8io,项目名称:fabric8-jenkins-workflow-steps,代码行数:9,代码来源:WorkflowRunAction.java

示例10: getUrl

import org.kohsuke.stapler.Stapler; //导入方法依赖的package包/类
public static String getUrl(WorkflowJob node) {
    StaplerRequest currentRequest = Stapler.getCurrentRequest();
    String path = currentRequest.getContextPath();
    if (!path.endsWith("/")) {
        path += "/";
    }
    return path + "fabric8";
}
 
开发者ID:fabric8io,项目名称:fabric8-jenkins-workflow-steps,代码行数:9,代码来源:WorkflowJobAction.java

示例11: findRun

import org.kohsuke.stapler.Stapler; //导入方法依赖的package包/类
/**
 * If the stapler request ancestor is a Run or one of the deploy now actions, will return {@code null},
 * otherwise returns the run.
 *
 * @return the run ancestor of the stapler request or {@code null} if there is none.
 */
@CheckForNull
protected Run findRun() {
    StaplerRequest request = Stapler.getCurrentRequest();
    if (request == null) {
        return null;
    }
    List<Ancestor> ancestors = request.getAncestors();
    for (int i = ancestors.size() - 1; i >= 0; i--) {
        Ancestor a = ancestors.get(i);
        Object object = a.getObject();
        if (object instanceof DeployNowRunAction) {
            return ((DeployNowRunAction) object).getOwner();
        }
        if (object instanceof DeployNowProjectAction) {
            return CapabilitiesResolver.getLastDeployableBuild((((DeployNowProjectAction) object).getOwner()));
        }
        if (object instanceof Run) {
            return (Run) object;
        }
        if (object instanceof Job) {
            return CapabilitiesResolver.getLastDeployableBuild((Job) object);
        }
    }

    return null;
}
 
开发者ID:jenkinsci,项目名称:deployer-framework-plugin,代码行数:33,代码来源:DeploySourceDescriptor.java

示例12: findJob

import org.kohsuke.stapler.Stapler; //导入方法依赖的package包/类
/**
 * If the stapler request ancestor is a Run or one of the deploy now actions, will return {@code null},
 * otherwise returns the job.
 *
 * @return the job ancestor of the stapler request or {@code null} if there is none.
 */
@CheckForNull
protected Job findJob() {
    StaplerRequest request = Stapler.getCurrentRequest();
    if (request == null) {
        return null;
    }
    List<Ancestor> ancestors = request.getAncestors();
    for (int i = ancestors.size() - 1; i >= 0; i--) {
        Ancestor a = ancestors.get(i);
        Object object = a.getObject();
        if (object instanceof DeployNowRunAction) {
            return null;
        }
        if (object instanceof DeployNowProjectAction) {
            return null;
        }
        if (object instanceof Run) {
            return null;
        }
        if (object instanceof Job) {
            return ((Job) object);
        }
    }

    return null;
}
 
开发者ID:jenkinsci,项目名称:deployer-framework-plugin,代码行数:33,代码来源:DeploySourceDescriptor.java

示例13: retrieveCurrentJob

import org.kohsuke.stapler.Stapler; //导入方法依赖的package包/类
private Job<?, ?> retrieveCurrentJob() {
    StaplerRequest request = Stapler.getCurrentRequest();
    if (request != null) {
        Ancestor ancestor = request.findAncestor(Job.class);
        return ancestor == null ? null : (Job<?, ?>) ancestor.getObject();
    }
    return null;
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:9,代码来源:GitLabPushTrigger.java

示例14: findBrowser

import org.kohsuke.stapler.Stapler; //导入方法依赖的package包/类
public static P4Browser findBrowser(String scmCredential) {
	// Retrieve item from request
	StaplerRequest req = Stapler.getCurrentRequest();
	Job job = req == null ? null : req.findAncestorObject(Job.class);

	// If cannot retrieve item, check from root
	P4BaseCredentials credentials = job == null
			? ConnectionHelper.findCredential(scmCredential, Jenkins.getActiveInstance())
			: ConnectionHelper.findCredential(scmCredential, job);

	if (credentials == null) {
		logger.fine("Could not retrieve credentials from id: '${scmCredential}");
		return null;
	}
	try {
		ConnectionHelper connection = new ConnectionHelper(credentials, null);
		String url = connection.getSwarm();
		if (url != null) {
			return new SwarmBrowser(url);
		} else {
			return null;
		}
	} catch (P4JavaException e) {
		logger.info("Unable to access Perforce Property.");
		return null;
	}
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:28,代码来源:PerforceScm.java

示例15: getTarget

import org.kohsuke.stapler.Stapler; //导入方法依赖的package包/类
@Override
public Object getTarget() {
    final StaplerRequest currentRequest = Stapler.getCurrentRequest();
    if (getAccessToken(currentRequest) == null)
        return new GithubOauthLoginAction();
    return this;
}
 
开发者ID:groupon,项目名称:DotCi,代码行数:8,代码来源:GithubReposController.java


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