Class Question
java.lang.Object
io.jenkins.plugins.interactiveinput.model.Question
- All Implemented Interfaces:
Serializable
A single human-in-the-loop question raised by the
askInteractive step (or mirrored from a
built-in input step by the bridge).
The metadata here is persisted via XStream under $JENKINS_HOME/interactive-input. State
transitions are guarded by the owning QuestionStore, which synchronises on the individual
Question instance (ยง8.9). This class performs the terminal-state bookkeeping but does not
itself enforce concurrency.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionQuestion(String id, String prompt, List<Choice> choices, boolean allowFreeText, long slaMs, String contextMd, String submitterFilter, String jobFullName, int buildNumber, String startedBy, long createdTs, boolean bridged) Question(String id, String prompt, List<Choice> choices, boolean allowFreeText, long slaMs, String contextMd, String submitterFilter, String jobFullName, int buildNumber, String startedBy, long createdTs, boolean bridged, List<ParameterDefinition> parameters) Canonical constructor;parameterscarries nativeinput-style fields (B24). -
Method Summary
Modifier and TypeMethodDescriptionintlonglonggetId()longgetSlaMs()booleanbooleanbooleanbooleanisExpired(long now) voidmarkAborted(Answer abortRecord) Move the question toQuestionStatus.ABORTED.voidmarkAnswered(Answer answer) Record a human answer, moving the question toQuestionStatus.ANSWERED.voidMove the question toQuestionStatus.EXPIRED.longremainingMs(long now) net.sf.json.JSONObjecttoJson(boolean includeAnswer, long now) Serialise this question to JSON for the REST API and the modal.
-
Constructor Details
-
Question
public Question(@NonNull String id, @NonNull String prompt, @CheckForNull List<Choice> choices, boolean allowFreeText, long slaMs, @CheckForNull String contextMd, @CheckForNull String submitterFilter, @NonNull String jobFullName, int buildNumber, @CheckForNull String startedBy, long createdTs, boolean bridged) -
Question
public Question(@NonNull String id, @NonNull String prompt, @CheckForNull List<Choice> choices, boolean allowFreeText, long slaMs, @CheckForNull String contextMd, @CheckForNull String submitterFilter, @NonNull String jobFullName, int buildNumber, @CheckForNull String startedBy, long createdTs, boolean bridged, @CheckForNull List<ParameterDefinition> parameters) Canonical constructor;parameterscarries nativeinput-style fields (B24).
-
-
Method Details
-
getId
-
getPrompt
-
getChoices
- Returns:
- an unmodifiable view of the choices (never
null).
-
getParameters
- Returns:
- an unmodifiable view of the native
input-style parameters (nevernull).
-
hasParameters
public boolean hasParameters()- Returns:
trueif this question is answered by filling in parameters rather than a choice.
-
isAllowFreeText
public boolean isAllowFreeText() -
getSlaMs
public long getSlaMs() -
getContextMd
-
getSubmitterFilter
-
getJobFullName
-
getBuildNumber
public int getBuildNumber() -
getStartedBy
- Returns:
- the user id (or trigger label) that started the build, or
nullfor legacy data.
-
getCreatedTs
public long getCreatedTs() -
isBridged
public boolean isBridged() -
getStatus
-
getExpiresAt
public long getExpiresAt() -
getAnswer
-
isExpired
public boolean isExpired(long now) - Returns:
trueif an SLA is configured and it has elapsed relative tonow.
-
remainingMs
public long remainingMs(long now) - Returns:
- remaining SLA milliseconds (
-1when no SLA,0when already due).
-
markAnswered
Record a human answer, moving the question toQuestionStatus.ANSWERED.Contract: invoked only by
QuestionStorewhile holding this question's monitor; not intended for direct use elsewhere.- Throws:
IllegalStateException- if the question is already in a terminal state
-
markAborted
Move the question toQuestionStatus.ABORTED. Store-only; seemarkAnswered(io.jenkins.plugins.interactiveinput.model.Answer). -
markExpired
public void markExpired()Move the question toQuestionStatus.EXPIRED. Store-only; seemarkAnswered(io.jenkins.plugins.interactiveinput.model.Answer). -
toJson
@NonNull public net.sf.json.JSONObject toJson(boolean includeAnswer, long now) Serialise this question to JSON for the REST API and the modal.- Parameters:
includeAnswer- whether to include the recorded answer (if any)now- reference time for computingremainingMs- Returns:
- a JSON object; string values are raw (JSON-escaped by the library). HTML/markdown escaping for UI rendering is handled at render time, never here.
-