Class AutoBuildsListener

java.lang.Object
com.atlassian.jira.cloud.jenkins.listeners.AutoBuildsListener
All Implemented Interfaces:
SinglePipelineListener

public class AutoBuildsListener extends Object implements SinglePipelineListener
This class should listen to the events from Jenkins pipeline and send 2 builds: one in "IN_PROGRESS" state and the other one in the "final" or "resulting" state.

Challenges to keep in mind:

- order of the events: we shouldn't send IN_PROGRESS event if the final result has already been sent

- uncertainty about issue keys: they appear at some point during the execution of the pipeline and might not be in place at the moment we need them.

  • Constructor Details

    • AutoBuildsListener

      public AutoBuildsListener(org.jenkinsci.plugins.workflow.job.WorkflowRun run, PipelineLogger logger, String autoBuildsRegex, IssueKeyExtractor issueKeyExtractor)
  • Method Details

    • getBuildUrl

      public String getBuildUrl()
      Specified by:
      getBuildUrl in interface SinglePipelineListener
    • onCompleted

      public void onCompleted()
      Specified by:
      onCompleted in interface SinglePipelineListener
    • onNewHead

      public void onNewHead(org.jenkinsci.plugins.workflow.graph.FlowNode flowNode)
      There are 2 cases: with regex and without.

      Without regex: we are waiting for the first event with issue keys determined to send IN_PROGRESS update to Jira, then we sent the final update with WorkflowRun::result in onComplete().

      With regex: we are waiting for a StartNode with a display name that matches regex to determine the moment since which we can send "IN_PROGRESS" update to Jira, then we are waiting when the closing EndNode comes, then we wait when it's BallIcon status stops flickering and then we send the update.

      Specified by:
      onNewHead in interface SinglePipelineListener