0
votes

I'm trying to run this PowerShell script in Jenkins:

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." I can run the above code on the server that Jenkins is using and it works.

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. I'm using version 1.3 of the PowerShell plugin (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.

Thanks.

1
Did your workspace have a mapping relationship with TFS server? If you use the Jenkins TFS plugin did you get some error:"Unable to determine the workspace." Which info die you get if you are using the plugin.PatrickLu-MSFT

1 Answers

0
votes

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. I had to change the Jenkins Windows Service to use the correct TFS credentials - by default it uses the Local System Account. For others reading this, you'll want that account to have minimal rights on the machine running 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.