Unable to Execute Powershell Script

Hello Community,

I have configured Powershell Build runner to run the the following code

 

<#
Steps to run:
1) Login to Azure
2) Select correct subscription
3) Alter the path below to where you have the have saved the pester test locally
#>

$pesterParamters = @{
Path = '**.ps1 => pesterproject2.%build.number%.zip'
Parameters = @{
templateUri = '**.json => pesterproject2.%build.number%.zip
templateParameterObject = @{
resourcePrefix = 'pester'
adminPassword = 'Patters0n1234'
}
}
}

$parameterHash= @{
resourcePrefix = 'pester'
adminPassword = 'Patters0n1234'
}

Invoke-Pester -Script $pesterParamters -OutputFile "+:*/*.Xml => pesterproject2.%build.number%.zip" -OutputFormat NUnitXml -PassThru

 

The aim is run a Pester unit test and then output the report.

Everything appears to be working fine, except that when I run the runner I get the following error:

 
[14:11:11]The build is removed from the queue to be prepared for the start
[14:11:11]Collecting changes in 1 VCS root (1s)
[14:11:13]Starting the build on the agent Carlton-PC-1
[14:11:13]Clearing temporary directory: C:\BuildAgent\temp\buildTmp
[14:11:13]Publishing internal artifacts
[14:11:13]Using vcs information from agent file: bc118f391db066ca.xml
[14:11:13]Checkout directory: C:\BuildAgent\work\bc118f391db066ca
[14:11:13]Updating sources: auto checkout (on agent) (2s)
[14:11:16]Step 1/1: PowerShell
[14:11:16][Step 1/1] PowerShell Executable: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
[14:11:16][Step 1/1] Working directory: C:\BuildAgent\work\bc118f391db066ca\pesterproject2
[14:11:16][Step 1/1] Command: C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe
[14:11:16][Step 1/1] PowerShell arguments: -NoProfile, -NonInteractive, -ExecutionPolicy, ByPass, -File, C:\BuildAgent\temp\buildTmp\powershell2011325967314939264.ps1
[14:11:16][Step 1/1] At C:\BuildAgent\temp\buildTmp\powershell2011325967314939264.ps1:21 char:60
[14:11:16][Step 1/1] + adminPassword = '*******'
[14:11:16][Step 1/1] + ~
[14:11:16][Step 1/1] The string is missing the terminator: '.
[14:11:16][Step 1/1] At C:\BuildAgent\temp\buildTmp\powershell2011325967314939264.ps1:13 char:47
[14:11:16][Step 1/1] + resourcePrefix = 'pester'.
[14:11:16][Step 1/1] + ~~~~~~~~
[14:11:16][Step 1/1] Unexpected token 'pester'.
[14:11:16][Step 1/1] adminPassword = '*******'
[14:11:16][Step 1/1] }
[14:11:16][Step 1/1] }
[14:11:16][Step 1/1] }
[14:11:16][Step 1/1] $parameterHash= @{
[14:11:16][Step 1/1] resourcePrefix = 'pester'.
[14:11:16][Step 1/1] adminPassword = '*******'
[14:11:16][Step 1/1] }
[14:11:16][Step 1/1] Invoke-Pester -Script $pesterParamters -OutputFile "+:*/*.Xml =>
[14:11:16][Step 1/1] pesterproject2.4.zip" -OutputFormat NUnitXml -PassThru' in expression or
[14:11:16][Step 1/1] statement.
[14:11:16][Step 1/1] At C:\BuildAgent\temp\buildTmp\powershell2011325967314939264.ps1:13 char:47
[14:11:16][Step 1/1] + resourcePrefix = 'pester'.
[14:11:16][Step 1/1] + ~
[14:11:16][Step 1/1] The hash literal was incomplete.
[14:11:16][Step 1/1] At C:\BuildAgent\temp\buildTmp\powershell2011325967314939264.ps1:13 char:46
[14:11:16][Step 1/1] + resourcePrefix = 'pester'.
[14:11:16][Step 1/1] + ~
[14:11:16][Step 1/1] The hash literal was incomplete.
[14:11:16][Step 1/1] + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
[14:11:16][Step 1/1] ception
[14:11:16][Step 1/1] + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
[14:11:16][Step 1/1]
[14:11:16][Step 1/1] Process exited with code 1
[14:11:16][Step 1/1] Process exited with code 1
[14:11:16][Step 1/1] Step PowerShell failed
[14:11:16]Publishing internal artifacts
 
I have tried everything imaginable to get fix this but with no luck.
 
Any assistance will be greatly appreciated.
 
Thanks
 
Carlotn

 

0
1 comment
Avatar
Permanently deleted user

Hi 

 

I think I have fixed the problem by changing the code to the following:

<#
Steps to run:
1) Login to Azure
2) Select correct subscription
3) Alter the path below to where you have the have saved the pester test locally
#>

$pesterParamters = @{
Path = '**.ps1 => pesterproject2.%build.number%.zip'
Parameters = @{
templateUri = "**.json => pesterproject2.%build.number%.zip"
templateParameterObject = @{
resourcePrefix = "pester"
adminPassword = "Patters0n1234"
}
}
}

$parameterHash= @{
resourcePrefix = "pester"
adminPassword = "Patters0n1234"
}

Invoke-Pester -Script $pesterParamters -OutputFile "+:*/*.Xml => pesterproject2.%build.number%.zip" -OutputFormat NUnitXml -PassThru

 

But the results aren't being sent to an output file.

Any thoughts

Carlton

0

Please sign in to leave a comment.