简体   繁体   中英

How to run a remote Powershell in VSTS release only if script exists?

In VSTS release management there is a nice remote Powershell task where we can run a script on the target machine. However I'd need a way to tell the release managment that only run this file if it exists, otherwise silently ignore that.

I know I can configure a task to not block the process in case of error, however in that case there still will be an exclamation mark in the log and the deployment will get the partial succeeded status. I'd like to avoid this and show success even if the file doesn't exist.

With this I need it to support kind of optional setup scripts for several deployed products.

There isn't the setting or feature in VSTS to check whether the script file is existing or not.

The simple way is that, you can create another script to call target script.

  1. Create another script (eg wapperScript.ps1) to call target script (can use parameter to accept the target script path) and add to source control
  2. Add Windows Machine copy task to copy wapperScript.ps1 to target machine
  3. Add Remote PowerShell task to run wapperScript.ps1

If you make your script more robust with a guard clause so that it can be called regardless of any given environmental condition. This keeps your pipeline less complicated. You can take action on the "file exists" leg and do a noop on the other. You can signal to the release process either way with log entries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM