0

I have an output variable siteToDeploy and siteToStop. I am using postman to run a test script against the IIS Administration API. In the test portion of one of the requests I am trying to set the azure devops output variable. Its sort of working, but the variable value is getting cut off for some reason.

Here is the test script in postman: console.log(pm.globals.get("siteName"))

var response = pm.response.json();

var startedSite = _.find(response.websites, function(o) { return o.name.indexOf(pm.globals.get("siteName")) > -1 && pm.globals.get("siteName") &&  o.status == 'started'});
var stoppedSite = _.find(response.websites, function(o) { return o.name.indexOf(pm.globals.get("siteName"))  > -1 &&  o.status == 'stopped'});

if(stoppedSite && startedSite){

    console.log('sites found');

    console.log(stoppedSite.id)
    console.log('##vso[task.setvariable variable=siteToDeploy;]' + stoppedSite.id);
    console.log('##vso[task.setvariable variable=siteToStop;]' + startedSite.id);
}

Here is the output form Newman: Newman

Here is the output from a command line task echoing the $(siteToDeploy) variable. It's getting set, but not the entire value. enter image description here

I've tried escaping it, but that had no effect. I also created a static command line echo where the variable is set and that worked fine. So I am not sure if it is a Newman issue or Azure having trouble picking up the varaible.

DDiVita
  • 4,225
  • 5
  • 63
  • 117
  • Have you tried using Newman v4, just to rule things out? – Danny Dainton Nov 28 '18 at 08:09
  • @DannyDainton, newman is being installed to the latest version. You may be mistaking the the CLI Companion Task version. I uploaded a picture to verify 4.2.2 is being installed. – DDiVita Nov 28 '18 at 11:32
  • Ok, maybe I was confused because I saw v3 in the first image. So you're using newman via a tool that someone has created on Github rather than newman from postmanlabs? https://github.com/postmanlabs/newman – Danny Dainton Nov 28 '18 at 11:48
  • @DannyDainton, that is not a true statement. In the pipeline, NPM is installing Newman and the azure task plugin is using that under the hood. – DDiVita Nov 28 '18 at 13:58
  • I wasn't disagreeing about what you're using. It just helps people to understand your current issue, when you present the question with _all_ the information. It could potentially be an issue with the **NewmanPostman_VSTS_Task** code that you're using but no one would know to think that because you didn't say you were using it. I just saw it in one of the images :) – Danny Dainton Nov 28 '18 at 15:38

1 Answers1

0

The issue turned our to be how Azure is trying to parse the Newman console log output. I had to add an extra Powershell task to replace the ' coming back from the Newman output.

This is what is looks like:

##This task is only here because of how Newman is writing out the console.log 
Param(
[string]$_siteToDeploy = (("$(siteToDeploy)") -replace "'",""),
[string]$_siteToStop = (("$(siteToStop)") -replace "'","")
)
Write-Host ("##vso[task.setvariable variable=siteToDeploy;]{0}" -f  ($_siteToDeploy))
Write-Host ("##vso[task.setvariable variable=siteToStop;]{0}" -f ($_siteToStop))
DDiVita
  • 4,225
  • 5
  • 63
  • 117