简体   繁体   English

在Jenkins中运行PowerShell TFS脚本

[英]Running PowerShell TFS script in Jenkins

I'm trying to run this PowerShell script in Jenkins: 我正在尝试在Jenkins中运行以下PowerShell脚本:

if ( (Get-PSSnapin -Name Microsoft.TeamFoundation.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
    Add-PsSnapin Microsoft.TeamFoundation.PowerShell
}
Update-TFSWorkspace -Overwrite -Recurse -Item C:\myWorkSpaceFolder

Jenkins returns the error "Unable to determine the workspace." Jenkins返回错误“无法确定工作空间”。 I can run the above code on the server that Jenkins is using and it works. 我可以在Jenkins使用的服务器上运行上面的代码,它可以工作。

Any idea how I can fix this? 知道我该如何解决吗? In case it matters, this is how Jenkins is executing the script: 如果很重要,这就是詹金斯执行脚本的方式:

powershell.exe -NonInteractive -ExecutionPolicy ByPass "& 'C:\Windows\TEMP\hudson3811725198776907360.ps1'"

I'm running Jenkins 2.6. 我正在运行Jenkins 2.6。 I'm using version 1.3 of the PowerShell plugin ( https://wiki.jenkins-ci.org/display/JENKINS/PowerShell+Plugin ). 我正在使用1.3版的PowerShell插件( https://wiki.jenkins-ci.org/display/JENKINS/PowerShell+Plugin )。 I'm not using the Jenkins TFS plugin because of How to stop Jenkins from listing all TFS workspaces . 我之所以没有使用Jenkins TFS插件,是因为如何阻止Jenkins列出所有TFS工作区

Thanks. 谢谢。

I made an incorrect assumption. 我做了一个错误的假设。 I had configured the Jenkins TFS plugin to use the correct TFS credentials, but I'm not using the TFS plugin. 我已经将Jenkins TFS插件配置为使用正确的TFS凭据,但是我没有使用TFS插件。 I had to change the Jenkins Windows Service to use the correct TFS credentials - by default it uses the Local System Account. 我必须将Jenkins Windows服务更改为使用正确的TFS凭据-默认情况下,它使用本地系统帐户。 For others reading this, you'll want that account to have minimal rights on the machine running Jenkins. 对于其他阅读此文章的人,您希望该帐户在运行Jenkins的计算机上具有最小权限。 This solution makes Jenkins run significantly faster because my TFS environment is significantly impacted by the bug described in How to stop Jenkins from listing all TFS workspaces . 此解决方案使Jenkins的运行速度大大提高,因为如何阻止Jenkins列出所有TFS工作区中所述的错误极大地影响了我的TFS环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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