• Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • pagerduty-plugin
    • None

      We are seeing an error specifically in the build step 'PagerDuty Incident Trigger'.

       

      Error while trying to resolve 
      com.mashape.unirest.http.exceptions.UnirestException: java.lang.RuntimeException: java.lang.RuntimeException: org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1]
      Build step 'PagerDuty Incident Trigger' marked build as failure
      Email was triggered for: Failure - Any 

       

       

          [JENKINS-68532] PagerDuty RuntimeException

          Thomas Pretto added a comment -

          As an additional data point, these failures are intermittent and causing builds to flap between success and failure states:  Our build jobs do complete successfully but then we get this above noted transient failure across multiple build jobs which all fail due to this above error message but then the error will clear and we will have successful jobs once again.

          Thank you for looking into this issue.

          Thomas Pretto added a comment - As an additional data point, these failures are intermittent and causing builds to flap between success and failure states:  Our build jobs do complete successfully but then we get this above noted transient failure across multiple build jobs which all fail due to this above error message but then the error will clear and we will have successful jobs once again. Thank you for looking into this issue.

          I'm seeing this as well, with Jenkins 2.332.2, PagerDuty plugin 0.7.0. This sample pipeline:

          pipeline {
              agent { label 'Quick' }
           
              environment {
                  PAGERDUTY_INTEGRATION_KEY = credentials('pagerduty_integration_key')
              }
           
              stages {
                  stage('Main') {
                      steps {
                          bat label: 'this is a batch script', script: '''
                          exit 1
                          '''
                      }
                  }
              }    post {
                  failure {
                      pagerduty(resolve: false, routingKey: "${env.PAGERDUTY_INTEGRATION_KEY}", incidentSource: "Jenkins CI", incidentSummary: "something failed", \
                      incidentSeverity:"warning", incidentComponent:"component", incidentGroup:"group", incidentClass:"class")
                  }
           
              }
          } 

          results in an exception:

          summary something failed
          severity warning
          ERROR: Tried to trigger PD with routingKey = [****]
          com.github.dikhan.pagerduty.client.events.exceptions.NotifyEventException: com.mashape.unirest.http.exceptions.UnirestException: java.lang.RuntimeException: java.lang.RuntimeException: org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1]
          	at com.github.dikhan.pagerduty.client.events.HttpApiServiceImpl.notifyEvent(HttpApiServiceImpl.java:63)
          	at com.github.dikhan.pagerduty.client.events.PagerDutyEventsClient.sendEvent(PagerDutyEventsClient.java:124)
          	at com.github.dikhan.pagerduty.client.events.PagerDutyEventsClient.trigger(PagerDutyEventsClient.java:109)
          	at org.jenkinsci.plugins.pagerduty.util.PagerDutyUtils.triggerPagerDuty(PagerDutyUtils.java:103)
          	at org.jenkinsci.plugins.pagerduty.pipeline.PagerDutyTriggerStep$PagerDutyTriggerStepExecution.run(PagerDutyTriggerStep.java:174)
          	at org.jenkinsci.plugins.pagerduty.pipeline.PagerDutyTriggerStep$PagerDutyTriggerStepExecution.run(PagerDutyTriggerStep.java:140)
          	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
          	at hudson.security.ACL.impersonate2(ACL.java:451)
          	at hudson.security.ACL.impersonate(ACL.java:463)
          	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
          	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
          	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          	at java.lang.Thread.run(Thread.java:750)
          Caused by: com.mashape.unirest.http.exceptions.UnirestException: java.lang.RuntimeException: java.lang.RuntimeException: org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1]
          	at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:143)
          	at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)
          	at com.github.dikhan.pagerduty.client.events.HttpApiServiceImpl.notifyEvent(HttpApiServiceImpl.java:50)
          	... 14 more
          Caused by: java.lang.RuntimeException: java.lang.RuntimeException: org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1]
          	at com.mashape.unirest.http.HttpResponse.<init>(HttpResponse.java:106)
          	at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:139)
          	... 16 more
          Caused by: java.lang.RuntimeException: org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1]
          	at com.mashape.unirest.http.JsonNode.<init>(JsonNode.java:51)
          	at com.mashape.unirest.http.HttpResponse.<init>(HttpResponse.java:95)
          	... 17 more
          Caused by: org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1]
          	at org.json.JSONTokener.syntaxError(JSONTokener.java:505)
          	at org.json.JSONArray.<init>(JSONArray.java:109)
          	at org.json.JSONArray.<init>(JSONArray.java:162)
          	at com.mashape.unirest.http.JsonNode.<init>(JsonNode.java:48)
          	... 18 more 

           

           

           

          Austin English added a comment - I'm seeing this as well, with Jenkins 2.332.2, PagerDuty plugin 0.7.0. This sample pipeline: pipeline {     agent { label 'Quick' }       environment {         PAGERDUTY_INTEGRATION_KEY = credentials( 'pagerduty_integration_key' )     }       stages {         stage( 'Main' ) {             steps {                 bat label: ' this is a batch script' , script: '''                 exit 1                 '''             }         }     }    post {         failure {             pagerduty(resolve: false , routingKey: "${env.PAGERDUTY_INTEGRATION_KEY}" , incidentSource: "Jenkins CI" , incidentSummary: "something failed" , \             incidentSeverity: "warning" , incidentComponent: "component" , incidentGroup: "group" , incidentClass: "class" )         }       } } results in an exception: summary something failed severity warning ERROR: Tried to trigger PD with routingKey = [****] com.github.dikhan.pagerduty.client.events.exceptions.NotifyEventException: com.mashape.unirest.http.exceptions.UnirestException: java.lang.RuntimeException: java.lang.RuntimeException: org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1] at com.github.dikhan.pagerduty.client.events.HttpApiServiceImpl.notifyEvent(HttpApiServiceImpl.java:63) at com.github.dikhan.pagerduty.client.events.PagerDutyEventsClient.sendEvent(PagerDutyEventsClient.java:124) at com.github.dikhan.pagerduty.client.events.PagerDutyEventsClient.trigger(PagerDutyEventsClient.java:109) at org.jenkinsci.plugins.pagerduty.util.PagerDutyUtils.triggerPagerDuty(PagerDutyUtils.java:103) at org.jenkinsci.plugins.pagerduty.pipeline.PagerDutyTriggerStep$PagerDutyTriggerStepExecution.run(PagerDutyTriggerStep.java:174) at org.jenkinsci.plugins.pagerduty.pipeline.PagerDutyTriggerStep$PagerDutyTriggerStepExecution.run(PagerDutyTriggerStep.java:140) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47) at hudson.security.ACL.impersonate2(ACL.java:451) at hudson.security.ACL.impersonate(ACL.java:463) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang. Thread .run( Thread .java:750) Caused by: com.mashape.unirest.http.exceptions.UnirestException: java.lang.RuntimeException: java.lang.RuntimeException: org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1] at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:143) at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68) at com.github.dikhan.pagerduty.client.events.HttpApiServiceImpl.notifyEvent(HttpApiServiceImpl.java:50) ... 14 more Caused by: java.lang.RuntimeException: java.lang.RuntimeException: org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1] at com.mashape.unirest.http.HttpResponse.<init>(HttpResponse.java:106) at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:139) ... 16 more Caused by: java.lang.RuntimeException: org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1] at com.mashape.unirest.http.JsonNode.<init>(JsonNode.java:51) at com.mashape.unirest.http.HttpResponse.<init>(HttpResponse.java:95) ... 17 more Caused by: org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1] at org.json.JSONTokener.syntaxError(JSONTokener.java:505) at org.json.JSONArray.<init>(JSONArray.java:109) at org.json.JSONArray.<init>(JSONArray.java:162) at com.mashape.unirest.http.JsonNode.<init>(JsonNode.java:48) ... 18 more      

          Tom added a comment - - edited

          We're seeing the same issue when a job succeeds and attempts to resolve an incident for a previous failure where the routing key is a runtime environment variable token, i.e.
          ${ENV, var="pagerDutyRoutingKey"}.

           

          This is possibly caused by the resolveIncident method (https://github.com/jenkinsci/pagerduty-plugin/blob/ca6b9e6eb9880eac72bac450af733d91dc5b3407/src/main/java/org/jenkinsci/plugins/pagerduty/util/PagerDutyUtils.java#L39) not having the same token substitution calls as the triggerPagerDuty method (https://github.com/jenkinsci/pagerduty-plugin/blob/ca6b9e6eb9880eac72bac450af733d91dc5b3407/src/main/java/org/jenkinsci/plugins/pagerduty/util/PagerDutyUtils.java#L77).

          Tom added a comment - - edited We're seeing the same issue when a job succeeds and attempts to resolve an incident for a previous failure where the routing key is a runtime environment variable token, i.e. ${ENV, var="pagerDutyRoutingKey"}.   This is possibly caused by the resolveIncident method ( https://github.com/jenkinsci/pagerduty-plugin/blob/ca6b9e6eb9880eac72bac450af733d91dc5b3407/src/main/java/org/jenkinsci/plugins/pagerduty/util/PagerDutyUtils.java#L39) not having the same token substitution calls as the triggerPagerDuty method ( https://github.com/jenkinsci/pagerduty-plugin/blob/ca6b9e6eb9880eac72bac450af733d91dc5b3407/src/main/java/org/jenkinsci/plugins/pagerduty/util/PagerDutyUtils.java#L77 ).

            alexanderlz Alexander Leibzon
            maharsh_patel Maharsh Patel
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: