Troubleshooting JIRA Trigger no longer triggering builds

3 minute readKnowledge base

Issue

JIRA Triggers stop working. There are errors in the logs that look like:

Before 1.0.2
2022-08-09 00:00:00.000+0000 [id=xxxx]    WARNING    o.e.j.s.h.ContextHandler$Context#log: Error while serving https://jenkins.example.com/jira-trigger-webhook-receiver/
RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={}, errorMessages=[Jira error message.]}]}
    at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$2.apply(AbstractAsynchronousRestClient.java:173)
    at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$2.apply(AbstractAsynchronousRestClient.java:167)
    at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:48)
    at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:12)
    at com.atlassian.util.concurrent.Promises$Of$3.apply(Promises.java:268)
    at com.atlassian.util.concurrent.Promises$2.onSuccess(Promises.java:158)
    at com.google.common.util.concurrent.Futures$6.run(Futures.java:975)
    at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:253)
    at com.google.common.util.concurrent.ExecutionList$RunnableExecutorPair.execute(ExecutionList.java:149)
    at com.google.common.util.concurrent.ExecutionList.execute(ExecutionList.java:134)
    at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:170)
    at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:53)
    at com.atlassian.util.concurrent.Promises$Of$3.apply(Promises.java:268)
    at com.atlassian.util.concurrent.Promises$2.onSuccess(Promises.java:158)
    at com.google.common.util.concurrent.Futures$6.run(Futures.java:975)
    at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:253)
    at com.google.common.util.concurrent.ExecutionList$RunnableExecutorPair.execute(ExecutionList.java:149)
    at com.google.common.util.concurrent.ExecutionList.execute(ExecutionList.java:134)
    at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:170)
    at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:53)
    at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$1$1.run(SettableFuturePromiseHttpPromiseAsyncClient.java:46)
    at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateRunnable$1.run(SettableFuturePromiseHttpPromiseAsyncClient.java:197)
    at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient.runInContext(SettableFuturePromiseHttpPromiseAsyncClient.java:90)
    at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateRunnable.run(SettableFuturePromiseHttpPromiseAsyncClient.java:192)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
Caused: java.util.concurrent.ExecutionException
    at com.google.common.util.concurrent.AbstractFuture$Sync.getValue(AbstractFuture.java:289)
    at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:262)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:91)
    at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:69)
    at com.atlassian.jira.rest.client.internal.async.DelegatingPromise.get(DelegatingPromise.java:107)
    at java_util_concurrent_Future$get.call(Unknown Source)
    at com.ceilfors.jenkins.plugins.jiratrigger.jira.JrjcJiraClient.validateIssueKey(JrjcJiraClient.groovy:62)
    at com.ceilfors.jenkins.plugins.jiratrigger.jira.JiraClient$validateIssueKey.call(Unknown Source)
    at com.ceilfors.jenkins.plugins.jiratrigger.JiraTrigger.run(JiraTrigger.groovy:43)
    at com.ceilfors.jenkins.plugins.jiratrigger.JiraTrigger$run.call(Unknown Source)
    at com.ceilfors.jenkins.plugins.jiratrigger.JiraTriggerExecutor.scheduleBuildsInternal(JiraTriggerExecutor.groovy:79)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)
    at com.ceilfors.jenkins.plugins.jiratrigger.JiraTriggerExecutor.scheduleBuilds(JiraTriggerExecutor.groovy:68)
    at com.ceilfors.jenkins.plugins.jiratrigger.JiraTriggerExecutor$scheduleBuilds.callCurrent(Unknown Source)
    at com.ceilfors.jenkins.plugins.jiratrigger.JiraTriggerExecutor.changelogCreated(JiraTriggerExecutor.groovy:51)
    at com.ceilfors.jenkins.plugins.jiratrigger.webhook.JiraWebhookListener$changelogCreated.call(Unknown Source)
    at com.ceilfors.jenkins.plugins.jiratrigger.webhook.JiraWebhook.processEvent(JiraWebhook.groovy:66)
    at com.ceilfors.jenkins.plugins.jiratrigger.webhook.JiraWebhook$processEvent.callCurrent(Unknown Source)
    at com.ceilfors.jenkins.plugins.jiratrigger.webhook.JiraWebhook.doIndex(JiraWebhook.groovy:51)
    at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
    at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:396)
Caused: java.lang.reflect.InvocationTargetException
    ...
Version 1.0.2
2023-05-08 06:47:31.435+0000 [id=2780654]	WARNING	o.e.j.s.h.ContextHandler$Context#log: Error while serving https://ci.example.test/jenkins/jira-trigger-webhook-receiver/
java.lang.ClassCastException: class org.codehaus.groovy.runtime.GStringImpl cannot be cast to class java.lang.String (org.codehaus.groovy.runtime.GStringImpl is in unnamed module of loader org.eclipse.jetty.webapp.WebAppClassLoader @34f5090e; java.lang.String is in module java.base of loader 'bootstrap')
	at java.logging/java.util.logging.Logger.log(Logger.java:1143)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrap.invoke(PojoMetaMethodSite.java:213)
	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:144)
	at com.ceilfors.jenkins.plugins.jiratrigger.JiraTriggerExecutor.scheduleBuildsInternal(JiraTriggerExecutor.groovy:86)
	at jdk.internal.reflect.GeneratedMethodAccessor3018.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:185)
	at com.ceilfors.jenkins.plugins.jiratrigger.JiraTriggerExecutor.scheduleBuilds(JiraTriggerExecutor.groovy:69)
	at com.ceilfors.jenkins.plugins.jiratrigger.JiraTriggerExecutor$scheduleBuilds.callCurrent(Unknown Source)
	at com.ceilfors.jenkins.plugins.jiratrigger.JiraTriggerExecutor.changelogCreated(JiraTriggerExecutor.groovy:52)
	at com.ceilfors.jenkins.plugins.jiratrigger.webhook.JiraWebhookListener$changelogCreated.call(Unknown Source)
	at com.ceilfors.jenkins.plugins.jiratrigger.webhook.JiraWebhook.processEvent(JiraWebhook.groovy:66)
	at com.ceilfors.jenkins.plugins.jiratrigger.webhook.JiraWebhook$processEvent.callCurrent(Unknown Source)
	at com.ceilfors.jenkins.plugins.jiratrigger.webhook.JiraWebhook.doIndex(JiraWebhook.groovy:51)
	at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:710)
	at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:397)

Explanation

The issue is that trigger configuration can become invalid and cause an error from JIRA which leads to the Java Exception. If not handled properly it can break processing of the JIRA Webhook failing to trigger the jobs

Resolution

Update JIRA Trigger plugin to 1.0.3 or newer. It handles the JIRA errors gracefully, but you still need to fix a trigger configuration when it goes bad.

Monitor the system log for a WARNING message saying "Error triggering". It is followed by the full job name and JIRA exception. See "Understanding the JIRA error" below on how to interpret the Exception and fix the root cause to restore the trigger.

Workaround

Before 1.0.2 an error from JIRA is not handled safely breaking the processing of the webhook.

Each time this happens one needs to find the bad JIRA Trigger configuration and fix it. Since no job name is printed in an error, you need to use verbose logging to try and figure out which job is at fault (see below).

Understand the JIRA error

The exception above includes the cause of the error on the JIRA side. Look for the part of the exception that looks like:

RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={}, errorMessages=[Jira error message.]}]}

Find the Job with broken trigger

Follow the How do I create a logger in Jenkins for troubleshooting and diagnostic information? to increase the com.ceilfors.jenkins.plugins.jiratrigger logger to the FINE level.

Reproduce the issue and then look for the message like below that matches the timestamp of the corresponding stack trace with JIRA error.

2022-08-09 00:00:00.000+0000 [id=347535]	FINE	o.c.g.r.c.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrap#invoke: Received Webhook callback from comment. Event type: jira:issue_updated

Skip through the messages that report every job with JIRA trigger until you see the next "Received Webhook callback" message. The last job in the list most likely has the misconfigured trigger.