0

I am trying to run a Jenkins job that uses TFVC plugin. We earlier had a problem with length of the TFS workspace names (exception for length > 75 chars). In order to address this we made a change in the TFVC configuration.

Default workspace name in TFVC: Hudson-${JOB_NAME}-${NODE_NAME}

After change: Hudson-${JOB_NAME}

Post this change the job had one successful run. We are unable to run this repeatedly as the TFS workspace created during the successful run was not deleted. and is throwing the following exception:

FATAL: hudson.remoting.ProxyException: com.microsoft.tfs.core.exceptions.TECoreException: The workspace scanAPI;tfsjenkins already exists on computer ip-XX-XX-XX-XX.

I have tried deleting the Jenkins workspace in pre/post build steps. This has no impact on the TFS workspace.

Additional information: The jobs are being run on a linux node and hence I am unable to run windows commands

Shurmajee
  • 1,027
  • 3
  • 12
  • 35
  • Hi Shurmajee, any update on this, did you get a chance to implement the solution that I suggested? Were you able to resolve by using tf command to delete tf workspace? – PatrickLu-MSFT Mar 19 '20 at 08:07
  • @PatrickLu-MSFT apologies for the delayed response but we are using a linux based node for this and I was unable to run the commands you mentioned. – Shurmajee Mar 24 '20 at 10:03
  • Hi Shurmajee , you should be able to use this through team explorer everywhere. It also include a tf command line. Take a look at https://stackoverflow.com/questions/6958530/setting-up-a-workspace-using-team-explorer-everywhere-on-linux Should be similar. – PatrickLu-MSFT Mar 25 '20 at 10:18

2 Answers2

0

You can use Post Build script that use tf.exe to delete the TFVC workpsace, with the delete command.

Create a global environment variable to be able to access the TF.exe easier. for example:

enter image description here

Note: the path to tf.exe it depend to which Visual Studio is installed in the Jenkins machine.

Add a Windows batch command from the scripts menu with the following command:

%TFS% workspace /delete /noprompt /collection:”https://tfs.codeplex.com:443/tfs/TFS27″ “Hudson-%JOB_NAME%;snd\7astlivec_cp”

Replace the URL with your TFS Server URL and change snd\7astlivec_cp with your TFS user. The command is going to delete the newly created TFS workspace.

Another option is to add tf.exe. location to the machine PATH variable and use it directly: tf workspace /delete .......

Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
0

Update

For Linux, you should be able to use this through team explorer everywhere. It also include a tf command line.

Take a look at Setting up a workspace using Team Explorer Everywhere on Linux

Should be similar on Linux.


Instead of creating the default workspace by specifying workspace name in UI setting, you could also use a Windows batch command to handle this process.

enter image description here

If you want to delete workspace, just add a new post build step, a cleanup command could be added to delete the previously created TFS workspace.

%TFS% workspace /delete /noprompt /collection:"{your-tfs-team-project-collection-url}" "Hudson-%JOB_NAME%;{your-domain-user-name}"

More details your could kindly refer this step-by-step tutorial Jenkins Get Source Code By Specific TFS Changeset

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62