project.scheduleBuild2(0, new Cause.RemoteCause("host", "note"), new ParametersAction(new StringParameterValue("name", "test"))) .get();
LOGGER.log(Level.FINEST, "Failed to get the Remote Host information form the RemoteCause."); return RemoteTrigger.create(remoteCause.getShortDescription(), host); } else if (source instanceof TimerTriggerCause) { return TimeTrigger.create(-1L, source.getShortDescription());
cause = new RemoteCause(req.getRemoteAddr(), causeText); } else { Object rebuild = req.getAttribute("rebuildCause");
/** * Creates a new freestyle project and build with a parameter value whose * type is unknown to rebuild plugin. Rebuild and verify that an no * exception occurs and page is displayed correctly. * * {@link RebuildableParameterValue}. * * @throws Exception * Exception */ public void testRebuildUnsupportedUnknownParameterValue() throws Exception { WebClient wc = createWebClient(); FreeStyleProject project = createFreeStyleProject(); project.addProperty(new ParametersDefinitionProperty( new UnsupportedUnknownParameterDefinition("param1", "defaultValue"))); assertBuildStatusSuccess(project.scheduleBuild2(0, new Cause.RemoteCause("host", "note"), new ParametersAction(new UnsupportedUnknownParameterValue( "param1", "value1")))); FreeStyleBuild build = project.getLastBuild(); // it is trying to fallback and use the HtmlPage page = wc.getPage(build, "rebuild"); // Check the hardcoded description is showing properly. assertTrue(page.asText().contains( "Configuration page for UnsupportedUnknownParameterValue")); }
/** * This is a copy (not a wrapper) of getBuildCause() in * {@link AbstractProject}. This is necessary, because we can't access * that field as our parent is loaded by a different class loader. * <p> * The function is used, because we need to splice-in one additional * {@link Action} for creation of Builds: {@link VersioningAction}. * <p> * FIXME: The ideal solution to this is to simply add an Extension Point * into Jenkins, that allows one to contribute additional actions. * * @param req * @return */ @SuppressWarnings("deprecation") public CauseAction getBuildCauseOverride(StaplerRequest req) { Cause cause; if (getAuthToken() != null && getAuthToken().getToken() != null && req.getParameter("token") != null) { // Optional additional cause text when starting via token String causeText = req.getParameter("cause"); cause = new RemoteCause(req.getRemoteAddr(), causeText); } else { cause = new UserIdCause(); } return new CauseAction(cause); }
/** * Creates a new freestyle project and build with a parameter value whose * type is unknown to rebuild plugin. Verify that rebuild succeeds if that * parameter value supports {@link RebuildableParameterValue}. * * @throws Exception * Exception */ public void testRebuildSupportedUnknownParameterValue() throws Exception { WebClient wc = createWebClient(); FreeStyleProject project = createFreeStyleProject(); project.addProperty(new ParametersDefinitionProperty( new SupportedUnknownParameterDefinition("param1", "defaultValue"))); assertBuildStatusSuccess(project .scheduleBuild2(0, new Cause.RemoteCause("host", "note"), new ParametersAction( new SupportedUnknownParameterValue("param1", "value1")))); FreeStyleBuild build = project.getLastBuild(); HtmlPage page = wc.getPage(build, "rebuild"); assertTrue(page.asText(), page.asText().contains("This is a mark for test")); }
/** * Computes the build cause, using RemoteCause or UserCause as appropriate. */ @Restricted(NoExternalUse.class) public static final CauseAction getBuildCause(ParameterizedJob job, StaplerRequest req) { Cause cause; @SuppressWarnings("deprecation") hudson.model.BuildAuthorizationToken authToken = job.getAuthToken(); if (authToken != null && authToken.getToken() != null && req.getParameter("token") != null) { // Optional additional cause text when starting via token String causeText = req.getParameter("cause"); cause = new Cause.RemoteCause(req.getRemoteAddr(), causeText); } else { cause = new Cause.UserIdCause(); } return new CauseAction(cause); }
/** * Computes the build cause, using RemoteCause or UserCause as appropriate. */ /* * package */ CauseAction getBuildCause(StaplerRequest req) { Cause cause; if (authToken != null && authToken.getToken() != null && req.getParameter("token") != null) { // Optional additional cause text when starting via token String causeText = req.getParameter("cause"); cause = new RemoteCause(req.getRemoteAddr(), causeText); } else { cause = new UserCause(); } return new CauseAction(cause); }
/** * Computes the build cause, using RemoteCause or UserCause as appropriate. */ /* * package */ CauseAction getBuildCause(StaplerRequest req) { Cause cause; if (authToken != null && authToken.getToken() != null && req.getParameter("token") != null) { // Optional additional cause text when starting via token String causeText = req.getParameter("cause"); cause = new RemoteCause(req.getRemoteAddr(), causeText); } else { cause = new UserCause(); } return new CauseAction(cause); }
public CauseDTO(Cause cause) { this.shortDescription = cause.getShortDescription(); if (cause instanceof Cause.UserIdCause) { Cause.UserIdCause userIdCause = (Cause.UserIdCause) cause; this.userId = userIdCause.getUserId(); this.userName = userIdCause.getUserName(); } else if (cause instanceof Cause.RemoteCause) { Cause.RemoteCause remoteCause = (Cause.RemoteCause) cause; this.remoteAddr = remoteCause.getAddr(); this.remoteNote = remoteCause.getNote(); } else if (cause instanceof Cause.UpstreamCause) { Cause.UpstreamCause upstreamCause = (Cause.UpstreamCause) cause; this.upstreamProject = upstreamCause.getUpstreamProject(); this.upstreamUrl = upstreamCause.getUpstreamUrl(); } }
public CauseDTO(Cause cause) { this.shortDescription = cause.getShortDescription(); if (cause instanceof Cause.UserIdCause) { Cause.UserIdCause userIdCause = (Cause.UserIdCause) cause; this.userId = userIdCause.getUserId(); this.userName = userIdCause.getUserName(); } else if (cause instanceof Cause.RemoteCause) { Cause.RemoteCause remoteCause = (Cause.RemoteCause) cause; this.remoteAddr = remoteCause.getAddr(); this.remoteNote = remoteCause.getNote(); } else if (cause instanceof Cause.UpstreamCause) { Cause.UpstreamCause upstreamCause = (Cause.UpstreamCause) cause; this.upstreamProject = upstreamCause.getUpstreamProject(); this.upstreamUrl = upstreamCause.getUpstreamUrl(); } }
/** * Computes the build cause, using RemoteCause or UserCause as appropriate. */ /*package*/ CauseAction getBuildCause(StaplerRequest req) { Cause cause; if (authToken != null && authToken.getToken() != null && req.getParameter("token") != null) { // Optional additional cause text when starting via token String causeText = req.getParameter("cause"); cause = new RemoteCause(req.getRemoteAddr(), causeText); } else { cause = new UserCause(); } return new CauseAction(cause); }
/** * Computes the build cause, using RemoteCause or UserCause as appropriate. */ /*package*/ CauseAction getBuildCause(StaplerRequest req) { Cause cause; if (authToken != null && authToken.getToken() != null && req.getParameter("token") != null) { // Optional additional cause text when starting via token String causeText = req.getParameter("cause"); cause = new RemoteCause(req.getRemoteAddr(), causeText); } else { cause = new UserCause(); } return new CauseAction(cause); }
/** * Computes the build cause, using RemoteCause or UserCause as appropriate. */ @Restricted(NoExternalUse.class) public static final CauseAction getBuildCause(ParameterizedJob job, StaplerRequest req) { Cause cause; @SuppressWarnings("deprecation") hudson.model.BuildAuthorizationToken authToken = job.getAuthToken(); if (authToken != null && authToken.getToken() != null && req.getParameter("token") != null) { // Optional additional cause text when starting via token String causeText = req.getParameter("cause"); cause = new Cause.RemoteCause(req.getRemoteAddr(), causeText); } else { cause = new Cause.UserIdCause(); } return new CauseAction(cause); }