SOLVED: The error cause was the way I was declaring output var, please see the code
I am trying to create a regex to get the URL from a VSTS attachment in order to sync it with Jira. I tried to create a Run Javascript block with the following input:
Input Data
comment:
creationDate: 2017-10-11T11:31:19.293Z
lastModifiedDate: 2017-08-29T12:32:51.393Z
location: https://project.visualstudio.com/_apis/wit/attachments/ca6206de-0fab-451a-b0bc-89e70221dfcb
name: Capture.PNG
resourceId: 2255679
What I want to retrieve is the "location", so I thought that this would make the trick:
var regEx = new RegExp('location: (.*)', 'g'); // As mentioned in the comments, the 'g' part is not needed
var path = regEx.exec(inputData);
// output = path[1]; This was failing miserably
var output = [{'path': path[1], 'hello': 'world'}] //This works just fine, I guess the hello world part is not really needed :)
But I always get an error:
TypeError: Cannot read property '0' of null
I have tried to create a simple javascript test to run the same and it works just fine. Can you please help me?