java.lang.Object
io.jenkins.plugins.interactiveinput.model.Question
All Implemented Interfaces:
Serializable

public class Question extends Object implements 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 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; parameters carries native input-style fields (B24).
  • Method Details

    • getId

      @NonNull public String getId()
    • getPrompt

      @NonNull public String getPrompt()
    • getChoices

      @NonNull public List<Choice> getChoices()
      Returns:
      an unmodifiable view of the choices (never null).
    • getParameters

      @NonNull public List<ParameterDefinition> getParameters()
      Returns:
      an unmodifiable view of the native input-style parameters (never null).
    • hasParameters

      public boolean hasParameters()
      Returns:
      true if this question is answered by filling in parameters rather than a choice.
    • isAllowFreeText

      public boolean isAllowFreeText()
    • getSlaMs

      public long getSlaMs()
    • getContextMd

      @CheckForNull public String getContextMd()
    • getSubmitterFilter

      @CheckForNull public String getSubmitterFilter()
    • getJobFullName

      @NonNull public String getJobFullName()
    • getBuildNumber

      public int getBuildNumber()
    • getStartedBy

      @CheckForNull public String getStartedBy()
      Returns:
      the user id (or trigger label) that started the build, or null for legacy data.
    • getCreatedTs

      public long getCreatedTs()
    • isBridged

      public boolean isBridged()
    • getStatus

      @NonNull public QuestionStatus getStatus()
    • getExpiresAt

      public long getExpiresAt()
    • getAnswer

      @CheckForNull public Answer getAnswer()
    • isExpired

      public boolean isExpired(long now)
      Returns:
      true if an SLA is configured and it has elapsed relative to now.
    • remainingMs

      public long remainingMs(long now)
      Returns:
      remaining SLA milliseconds (-1 when no SLA, 0 when already due).
    • markAnswered

      public void markAnswered(@NonNull Answer answer)
      Record a human answer, moving the question to QuestionStatus.ANSWERED.

      Contract: invoked only by QuestionStore while holding this question's monitor; not intended for direct use elsewhere.

      Throws:
      IllegalStateException - if the question is already in a terminal state
    • markAborted

      public void markAborted(@NonNull Answer abortRecord)
    • markExpired

      public void markExpired()
    • 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 computing remainingMs
      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.