2
1
0

Hi, Trying to sync Azure DevOps with Jira Server. Most fields are working, but I can't get the 'iteration' to sync to the 'fixVersion' from Azure to Jira, nor the opposite direction. 


Anyone have any experience with this?


Thanks

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi nick watts

      Lets take this one at a time, and first focus on the ADO → Jira sync of iterationPath


      What you need to do is

      a) Ensure that the iterationPath is part of the message sent from ADO to Jira

      b) Process the incoming message on the Jira side and map the iterationPath to the appropriate fixVersion.

      I compiled a video, because this might help to understand the setup.




      Outgoing sync (ADO)


      Ensure that the iterationPath is part of the message by adding following line to the outgoing sync on the ADO side.  Is is by default there, but it might have been removed


      replica.iterationPath  = workItem.iterationPath



      Incoming sync (Jira)


      Mapping the IterationPath to a FixVersion


      // create a map mapping the iterationPath to the targetVersionName
      // use triple single quotes for non interpretration of the special char \
      
      def pathMap = [ 
          "BugsRus\\Sprint 1":"1.0",
          "BugsRus\\Sprint 2":"1.1",
          ]
          
          
      // calculate the target version based on the replication iterationPath
      // default to 0.1 if the iterantionPath is not set, or not available in the map
      def targetVersionName = pathMap[replica.iterationPath ?: ""] ?: "0.1"
      
      


      A groovy map is easy to construct especially the <String>, <String> version.
      It is an array of key value pairs (denoted with the square brackets '[' ..., ... ']')
      And a pair is denoted with "<String>" : "<String>"

      The map get operator will search the keys for a match and return the value.
      pathMap["Some String"] will return the value which corresponds to 'Some String'



      Looking up the version


      Exalate provides a number of helper methods which can be used to look up particular objects - like nodeHelper.getVersion can be used to find the corresponding version


      def targetFixVersion = nodeHelper.getVersion(targetVersionName)



      Creating the version


      Of course it could be that the version doesn't exist yet, so using the nodeHelper.createVersion a version can be created


      if (! targetFixVersion) {
          // the version is not found - so create it
          targetFixVersion = nodeHelper.createVersion(issue, targetVersionName, "Auto created")
      }


      Setting the fixVersion itself


      Now the last step is to update the issue.fixVersions.  Because this is an array of versions, you need to construct an array.  Groovy makes this very simple by using the square brackets '['


      issue.fixVersions = [ targetFixVersion ]



      Other possibilities


      The crux of the story is the mapping. 
      In this example, I have been using a static map, but other approaches are possible.

      • Looking up all versions in a project (issue.project.versions)
      • Creating a dynamic map in the Jira 
      • Creating a dynamic map in the ADO



      In a next answer, I will be providing the way back.

        CommentAdd your comment...