/** * 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); }
@SuppressWarnings("deprecation") private static boolean jobHasAuthToken(final hudson.model.BuildAuthorizationToken authToken) { return authToken != null && !isNullOrEmpty(authToken.getToken()); }
/** This is the token configured in the job. A feature found in Jenkins core. */ @SuppressWarnings("deprecation") private static boolean authenticationTokenMatches( final hudson.model.BuildAuthorizationToken authToken, final String givenToken) { final boolean jobHasAuthToken = jobHasAuthToken(authToken); final boolean authTokenWasGiven = !isNullOrEmpty(givenToken); if (jobHasAuthToken && authTokenWasGiven) { return authToken.getToken().equals(givenToken); } if (!jobHasAuthToken && !authTokenWasGiven) { return true; } return false; }
/** * 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. */ /* * 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); }
/** * 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); }
Cause cause = null; if (getAuthToken() != null && getAuthToken().getToken() != null && req.getParameter("token") != null) {