本文整理汇总了Java中org.kohsuke.stapler.StaplerRequest.hasParameter方法的典型用法代码示例。如果您正苦于以下问题:Java StaplerRequest.hasParameter方法的具体用法?Java StaplerRequest.hasParameter怎么用?Java StaplerRequest.hasParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kohsuke.stapler.StaplerRequest
的用法示例。
在下文中一共展示了StaplerRequest.hasParameter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUsernameFromAuthCode
import org.kohsuke.stapler.StaplerRequest; //导入方法依赖的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
示例2: isGetParamSecretValid
import org.kohsuke.stapler.StaplerRequest; //导入方法依赖的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);
}
示例3: doBuild
import org.kohsuke.stapler.StaplerRequest; //导入方法依赖的package包/类
@Override
public FormValidation doBuild(StaplerRequest req) throws IOException {
FormValidation result;
try {
Jenkins instance = GitHubWebHook.getJenkinsInstance();
if (!instance.hasPermission(Item.BUILD)) {
return FormValidation.error("Forbidden");
}
final String prNumberParam = "prNumber";
int prId = 0;
if (req.hasParameter(prNumberParam)) {
prId = Integer.valueOf(req.getParameter(prNumberParam));
}
if (prId == 0 || !getPulls().containsKey(prId)) {
return FormValidation.error("No branch to build");
}
final GitHubPRPullRequest localPR = getPulls().get(prId);
final GitHubPRCause cause = new GitHubPRCause(localPR, null, false, "Manual run.");
final JobRunnerForCause runner = new JobRunnerForCause(getJob(), ghPRTriggerFromJob(getJob()));
final QueueTaskFuture<?> queueTaskFuture = runner.startJob(cause);
if (nonNull(queueTaskFuture)) {
result = FormValidation.ok("Build scheduled");
} else {
result = FormValidation.warning("Build not scheduled");
}
} catch (Exception e) {
LOG.error("Can't start build", e.getMessage());
result = FormValidation.error(e, "Can't start build: " + e.getMessage());
}
return result;
}
示例4: doRebuild
import org.kohsuke.stapler.StaplerRequest; //导入方法依赖的package包/类
@RequirePOST
public FormValidation doRebuild(StaplerRequest req) throws IOException {
FormValidation result;
try {
Jenkins instance = GitHubWebHook.getJenkinsInstance();
if (!instance.hasPermission(Item.BUILD)) {
return FormValidation.error("Forbidden");
}
final String prNumberParam = "prNumber";
int prId = 0;
if (req.hasParameter(prNumberParam)) {
prId = Integer.valueOf(req.getParameter(prNumberParam));
}
Map<Integer, List<Run<?, ?>>> builds = getAllPrBuilds();
List<Run<?, ?>> prBuilds = builds.get(prId);
if (prBuilds != null && !prBuilds.isEmpty()) {
if (rebuild(prBuilds.get(0))) {
result = FormValidation.ok("Rebuild scheduled");
} else {
result = FormValidation.warning("Rebuild not scheduled");
}
} else {
result = FormValidation.warning("Build not found");
}
} catch (Exception e) {
LOG.error("Can't start rebuild", e);
result = FormValidation.error(e, "Can't start rebuild: " + e.getMessage());
}
return result;
}
示例5: doBuild
import org.kohsuke.stapler.StaplerRequest; //导入方法依赖的package包/类
@RequirePOST
public FormValidation doBuild(StaplerRequest req) throws IOException {
FormValidation result;
try {
Jenkins instance = GitHubWebHook.getJenkinsInstance();
if (!instance.hasPermission(Item.BUILD)) {
return FormValidation.error("Forbidden");
}
final String param = "branchName";
String branchName = null;
if (req.hasParameter(param)) {
branchName = req.getParameter(param);
}
if (isNull(branchName) || !getBranches().containsKey(branchName)) {
return FormValidation.error("No branch to build");
}
final GitHubBranch localBranch = getBranches().get(branchName);
final GitHubBranchCause cause = new GitHubBranchCause(localBranch, this, "Manual run.", false);
final JobRunnerForBranchCause runner = new JobRunnerForBranchCause(getJob(),
ghBranchTriggerFromJob(getJob()));
final QueueTaskFuture<?> queueTaskFuture = runner.startJob(cause);
if (nonNull(queueTaskFuture)) {
result = FormValidation.ok("Build scheduled");
} else {
result = FormValidation.warning("Build not scheduled");
}
} catch (Exception e) {
LOG.error("Can't start build", e.getMessage());
result = FormValidation.error(e, "Can't start build: " + e.getMessage());
}
return result;
}
示例6: doRebuild
import org.kohsuke.stapler.StaplerRequest; //导入方法依赖的package包/类
@Override
@RequirePOST
public FormValidation doRebuild(StaplerRequest req) throws IOException {
FormValidation result;
try {
Jenkins instance = GitHubWebHook.getJenkinsInstance();
if (!instance.hasPermission(Item.BUILD)) {
return FormValidation.error("Forbidden");
}
final String param = "branchName";
String branchName = "";
if (req.hasParameter(param)) {
branchName = req.getParameter(param);
}
Map<String, List<Run<?, ?>>> allBuilds = getAllBranchBuilds();
List<Run<?, ?>> branchBuilds = allBuilds.get(branchName);
if (branchBuilds != null && !allBuilds.isEmpty()) {
if (rebuild(branchBuilds.get(0))) {
result = FormValidation.ok("Rebuild scheduled");
} else {
result = FormValidation.warning("Rebuild not scheduled");
}
} else {
result = FormValidation.warning("Build not found");
}
} catch (Exception e) {
LOG.error("Can't start rebuild", e.getMessage());
result = FormValidation.error(e, "Can't start rebuild: " + e.getMessage());
}
return result;
}