Calling another ps script from PreDeploy

Automated deployment for web applications and databases

Calling another ps script from PreDeploy

Postby segatarantino » Wed May 07, 2014 7:42 pm

Hello. Can you help me? I've a following text in my PreDeploy.ps1
Code: Select all
$packScriptPath = "c:\\lbs\\Pack.ps1"
$zipperPath = "C:\\Program Files (x86)\\7-Zip\\7z.exe"
if (my condition)
{
    Invoke-Expression "&`"$packScriptPath`" -zipperPath `"$zipperPath`" -workPath `"$RedGatePackageDirectoryPath`"
}


When I executed this script from PS-window - it's Ok. But when I make deploy with Red Gate, PreDeploy.ps1 seems like not working - Pack.ps1 not executed

Maybe I can't use Invoke-Expression in Red Gate?
Help me, please.[/code]
segatarantino
 
Posts: 2
Joined: Wed May 07, 2014 7:29 pm

Postby Mike Upton » Thu May 08, 2014 8:08 am

You can use any valid PowerShell from Deployment Manager, so Invoke-Expression should work.

Is it possible that the condition in:
if (my condition)

isn't evaluating to true when it's run in the context of the Deployment Agent? If you call some kind of output cmdlet (e.g. Write-Output) within the condition, does it execute?

I'm also not sure why you're using Invoke-Expression at all here. I'd suggest the following (including a Write-Output call so you can see if the condition is true):
Code: Select all
if (my condition)
{
    Write-Output "Calling `"& $packScriptPath -zipperPath $zipperPath -workPath $RedGatePackageDirectoryPath`""
    & $packScriptPath -zipperPath $zipperPath -workPath $RedGatePackageDirectoryPath
}
Mike Upton

Project Manager - SQL Compare|Data Compare|Comparison SDK
Redgate Software Ltd.
Mike Upton
 
Posts: 189
Joined: Wed May 11, 2011 8:04 am
Location: Redgate

Postby segatarantino » Thu May 08, 2014 8:11 am

Yes. Problem was in condition (agent service permissions)
Thanx! :)
segatarantino
 
Posts: 2
Joined: Wed May 07, 2014 7:29 pm


Return to Deployment Manager

Who is online

Users browsing this forum: No registered users and 0 guests