2 answers
- 210
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 }
CommentAdd your comment... - 10-1
Yes - it should - but the devil is in the eating of the pudding.
What fields do you need to sync?- Howard Kenny
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
- Francis Martens (Exalate)
I had to do some experimentation myself ...
Found the trick - you have to use a string representation of the dateIncoming, Testedimport 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 fieldsHow to sync work item fields obtained through a REST API call
- Howard Kenny
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'?
- Howard Kenny
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.
- Francis Martens (Exalate)
Ah - remove the elipsis (...)
This is to denote any other code, but it is not a valid groovy constructAlso - 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.
CommentAdd your comment...
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.