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

public class Answer extends Object implements Serializable
An immutable record of a human's answer to a Question.

Exactly one of getChoiceId(), getFreeText() or getParameterValues() is normally set. Two special choice ids resolve the input without a positive answer while still continuing the pipeline (an outright abort uses the store's abort path, not an answer): __deny__ (a human denied but chose to continue) and __skip__ (an automation skipped the input). The step returns the sentinel verbatim so the pipeline can branch on it.

When the question declared input-style parameters (B24), the submitted values are held in getParameterValues() and returned to the pipeline with the built-in input step's contract (a single parameter returns its value; several return a name→value map).

See Also:
  • Field Details

    • DENY_CHOICE_ID

      public static final String DENY_CHOICE_ID
      Sentinel choice id for "denied, but continue the pipeline" (the modal's "Continue" action).
      See Also:
    • SKIP_CHOICE_ID

      public static final String SKIP_CHOICE_ID
      Sentinel choice id for "skip this input" (primarily for automation/AI answering via REST).
      See Also:
  • Constructor Details

    • Answer

      public Answer(@NonNull String questionId, @CheckForNull String choiceId, @CheckForNull String freeText, @NonNull String answeredBy, long answeredTs)
      Parameters:
      questionId - the answered question's id (required)
      choiceId - the picked choice id, or null if a free-text answer
      freeText - the free-text answer, or null if a choice was picked
      answeredBy - Jenkins user id of the submitter (or "SYSTEM" for internal paths)
      answeredTs - epoch millis when the answer was recorded
    • Answer

      public Answer(@NonNull String questionId, @CheckForNull String choiceId, @CheckForNull String freeText, @CheckForNull Map<String,Object> parameterValues, @NonNull String answeredBy, long answeredTs)
      Canonical constructor; parameterValues carries an input-style answer (B24).
  • Method Details

    • getQuestionId

      @NonNull public String getQuestionId()
    • getChoiceId

      @CheckForNull public String getChoiceId()
    • getFreeText

      @CheckForNull public String getFreeText()
    • getParameterValues

      @CheckForNull public Map<String,Object> getParameterValues()
      Returns:
      the submitted input-style parameter values (name→value), or null.
    • isParameterized

      public boolean isParameterized()
      Returns:
      true if this answer carries input-style parameter values (B24).
    • getAnsweredBy

      @NonNull public String getAnsweredBy()
    • getAnsweredTs

      public long getAnsweredTs()
    • isDeny

      public boolean isDeny()
      Returns:
      true if this answer is the sentinel "deny (continue)" answer.
    • isSkip

      public boolean isSkip()
      Returns:
      true if this answer is the sentinel "skip" answer.
    • toStepReturnValue

      @NonNull public Object toStepReturnValue()
      Resolve the value handed back to the pipeline by the askInteractive step.
      Returns:
      for a parameterized answer (B24), the single parameter's value when exactly one was declared, otherwise an ordered name→value Map — matching the built-in input step's contract exactly; for a choice, its id String; for free text, a {text, choice} map (§6.1).
    • toJson

      @NonNull public net.sf.json.JSONObject toJson()