简体   繁体   中英

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.

我创建了一个有关如何实现此目标的博客文章: 自定义Team Build 2010 –第9部分:模拟活动(在其他凭据下运行)

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 eg:

$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.

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