Synchronization fails with authentication error on Jenkins after upgrading to version 3.x

Problem

A synchronization security token was introduced in version 3.0.0 that is required when Jenkins makes REST calls to Jira. This token is generated and verified using a shared secret, that when a Jenkins site is added to Jira, will be shared with the Jenkins instance. This sharing only done when adding the Jenkins site or when the Jira add-on detects that the Jenkins add-on was installed after the Jenkins site was configured in Jira.

The Jira server add-on has a upgrade task to share this shared secret with the configured Jenkins sites, but this requires that the Jenkins add-on was already upgraded to at least version 3.0.0, if the Jenkins site was still running version 2.x of the add-on then the shared secret would not be saved by Jenkins.

Solution

There is a workaround that allows you to fix the problem by resetting the marker used by the Jira add-on to keep track if the Jenkins add-on is installed.

You will require database access in order to use this workaround!

To fix this you will need to manually change the data within the database.

  1. Make sure the linked Jenkins sites have the latest version of the add-on installed.
  2. Shutdown Jira.
  3. Connect to you Jira database using your favourite SQL tooling that is also appropriate for the database you have.
  4. (warning) Create a backup of your database!
  5. Once connected locate the table AO_[HASH]_SITES, there should only be a single table that matches this name.
  6. Next we reset the plugin installed marker for all sites, by executing the following query.

    • UPDATE AO_[HASH]_SITES SET JENKINS_PLUGIN_INSTALLED = NULL

  7. Start JIRA again.
  8. Navigate to the Jenkins Configuration page in Jira and trigger the synchronization of the all Jenkins sites by selecting the "Refresh Job List" action.