Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-73115

Jira Step Edit Issue for Fix Version Replaces versions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • jira-steps-plugin
    • None

      In using the Jira Steps plugin we have a case, where multiple concurrent Jenkins builds start and all hit the Jira Step EditIssue call at the same time.  Since each job is running independently and will be creating different versions, there is no way to make each call wait for another to finish the updates.  We are seeing a Dirty Writes because of this.

      This issue seems to be with Jira itself.  To cause the problem in Jira, load an issue in two separate browser windows.  Create a unique version in the first  and click save. Then on the other window without reloading create a different version and click save.  Jira will report in the change history that the first windows version has been removed while the second windows version is now bound.

      Since this problem exists, we have found that the Jira Steps plugin doesn't handle this case well either and we are losing versions when the concurrent jobs all create their version. Through a lot of research it was found that the Jira REST API supports a method to Add/Remove versions using a slightly different syntax. A curl example I have confirm works is to call the issue end point but with an "update: fixVersions: add" body.

      curl --request PUT \
             -u ${user_pass} \
             --data '
                        {
                          "update": {
                             "fixVersions": [
                                {"add": 
                                   {"name": "${version}"}
                                 }
                             ]
                          }
                        }' \
             -H "Content-Type: application/json; charset=utf-8" \
             ${jira_site_url}/rest/api/2/issue/${jiraIssue}

      My thoughts on this would be to add a new api call addFixVersionToIssue(key, version).  The inverse could also be added removeFixVersionFromIssue(key, version).  In this case the calls would use the body in the above to perform the update. I have confirmed with the curl call, running it concurrently all version get added and nothing is removed.

      Reviewing the code base it doesn't seem to complicated to be added and would be a nice addition to the already awesome collection of Jira api calls.

        1. RemoveFixVersionStepTest.java
          2 kB
          Stephen
        2. RemoveFixVersionStep-config.jelly
          0.9 kB
          Stephen
        3. RemoveFixVersionStep.java
          3 kB
          Stephen
        4. jira_remove_fix_version.md
          1 kB
          Stephen
        5. jira_add_fix_version.md
          1 kB
          Stephen
        6. JENKINS-73115-fix-version-addition.patch
          4 kB
          Stephen
        7. AddFixVersionStepTest.java
          2 kB
          Stephen
        8. AddFixVersionStep-config.jelly
          0.9 kB
          Stephen
        9. AddFixVersionStep.java
          3 kB
          Stephen

            nrayapati Naresh Rayapati
            spaulin Stephen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: