Originally asked by Howard Kenny on 20 November 2020 (original question)
Hey,
Is it possible to map a Jira date field to a date/time field in Azure DevOps? Naturally, expecting the time aspect to default to 00.00.
Cheers.
Originally asked by Howard Kenny on 20 November 2020 (original question)
Hey,
Is it possible to map a Jira date field to a date/time field in Azure DevOps? Naturally, expecting the time aspect to default to 00.00.
Cheers.
Answer by Howard Kenny on 22 November 2020
For any potential future readers, this was the solution Francis gave me:
import java.text.SimpleDateFormat
...
def sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
def targetDate
if (replica.customFields."Planned Start Date"?.value){
targetDate = sdf.format(replica.customFields."Planned Start Date".value)
workItem."Microsoft.VSTS.Scheduling.StartDate" = targetDate
}
if (replica.customFields."Planned End Date"?.value){
targetDate = sdf.format(replica.customFields."Planned End Date".value)
workItem."Microsoft.VSTS.Scheduling.TargetDate" = targetDate
}
Answer by Francis Martens (Exalate) on 20 November 2020
Yes - it should - but the devil is in the eating of the pudding.
What fields do you need to sync?
Ha!
Iām sending this in the Outgoing Sync:
replica.customFields."Planned End Date" = issue.customFields."Planned End Date"
replica.customFields."Planned Start Date" = issue.customFields."Planned Start Date"
ā¦and this is the Incoming Sync section:
workItem.customKeys."Microsoft.VSTS.Scheduling.StartDate" = replica.customFields."Planned Start Date".value
workItem.customKeys."Microsoft.VSTS.Scheduling.TargetDate" = replica.customFields."Planned End Date".value
ā¦but nothing populates the fields Start Date and Target Date in DevOps.
For info, āMicrosoft.VSTS.Scheduling.StartDateā was taken from the JSON.
Iām also struggling to sync time tracking fields. This doesnāt seem to work:
workItem.customKeys."Microsoft.VSTS.Scheduling.Effort" = replica.originalEstimate
I had to do some experimentation myself ā¦
Found the trick - you have to use a string representation of the date
Incoming, Tested
import java.text.SimpleDateFormat
...
def sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
def targetDate = sdf.format(new Date())
//throw new Exception("Target date = ${targetDate}")
workItem."Microsoft.VSTS.Scheduling.StartDate" = targetDate
Also added some more documentation on how to access the fields
How to sync work item fields obtained through a REST API call
Iām having issues with thatā¦
'Script cannot be saved. Details: startup failed: Script297.groovy: 59: Unknown type: IMPORT at line
Iām thinking you didnāt expect me to copy and paste that whole snippet into my incoming script and instead do something special with āimport java.text.SimpleDateFormatā?
Euh - how does the script look like when trying to save?
I tried a few ways, not fully understanding how I was supposed to insert it (and not being convinced by any of my attempts!), butā¦
import java.text.SimpleDateFormat
...
def sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
def targetDate = sdf.format(new Date())
//throw new Exception("Target date = ${targetDate}")
workItem."Microsoft.VSTS.Scheduling.StartDate" = targetDate
workItem.customKeys."Microsoft.VSTS.Scheduling.StartDate" = replica.customFields."Planned Start Date".value
workItem.customKeys."Microsoft.VSTS.Scheduling.TargetDate" = replica.customFields."Planned End Date".value
I kept my two original lines at the end as I couldnāt see how your snippet referenced the source Jira Planned Start Date fields.
Ah - remove the elipsis (ā¦)
This is to denote any other code, but it is not a valid groovy construct
Also - remove the entries with the ācustomKeysā - it makes no sense
Of course - you will have to stringify the āPlanned Start Dateā to assign it to the Start Date.
I get an error when I use the
import java.text.SimpleDateFormat? |
---|
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.