开发者

Cause TFS InvokeProcess Build Activity to run under other credentials

We have customized the build process with a InvokeProcess action that runs a powershell script that deploys our sln.

Problem is that this script must be run under a given user 开发者_运维技巧(not the tfsbuild user).

How can we achive this?

  • Alternative 1: Make the InvokeProcess run as a different user -
  • Alternative 2: Make the powershell script itself run as different user

Problem is that I have no idea of how to do any of this.


I have created a blog post on this how you can achieve this: Customize Team Build 2010 – Part 9: Impersonate activities (run under other credentials)


A pure PowerShell option, assuming you have PowerShell 2.0 on your TeamBuild machine, is to use a background job. Start-Job allows you to specify the credentials of another account to perform the work. After spinning up the background job in your script you will probably want to wait for the job to finish and grab the results to output from the main script e.g.:

$cred = Get-Credential
$job = Start-Job -ScriptBlock { ls c:\windows\system32 -r *.sys } -Cred $cred
Wait-Job $job
Receive-Job $job

With respect to capturing, storing and retrieving the credentials, see this blog post for a good treatise on the subject.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜