Situation:
TFS 2018
build process consists of two phases -- executed on Windows and Linux agents respectively
Get sources
(TFVC) has Clean
flag set to false
Problem:
Clean
flag -- it always executes tf workspace -delete
, ... -new
, etc.I've added "print variables" step and could clearly see that Build.Repository.Clean
is false
in every phase.
Is there any way to fix this?
More info:
Setting system.debug
to true
produces interesting log:
Querying workspace information.
##[debug]tf workspaces -format:xml "-collection:<tfs-server-url>" -jwt:******** -noprompt
##[debug]No workspace matching *;Project Collection Build Service (<collection-name>) on computer <computer-name> found in Team Foundation Server <tfs-server-url>.
##[debug]<?xml version="1.0" encoding="utf-8"?><workspaces/>
##[debug]Sources directory does not exist or is empty.
##[debug]tf workspaces ws_1_14 -computer:* -format:xml "-collection:<tfs-server-url>" -jwt:******** -noprompt
##[debug]No workspace matching ws_1_14;Project Collection Build Service (<collection-name>) on computer * found in Team Foundation Server <tfs-server-url>.
##[debug]Deleting: '/home/<user>/agent/_work/1/s'.
##[command]tf workspace -new -location:local -permission:Public ws_1_14 "-collection:<tfs-server-url>" -jwt:******** -noprompt
Workspace 'ws_1_14' created.
But when I login to that machine and run these commands myself (without -jwt:... -noprompt
) -- I get correct information about ws_1_14
workspace. Agent is being executed as daemon/service created via sudo ./svc.sh install; sudo ./svc.sh start
. Which means problem is somewhere in that daemon's environment.
This happens because my hostname
was FQDN (instead of shortname). It is an existing bug.
Solution is to change hostname to be short and without dots(e.g. sudo hostnamectl set-hostname shortname
) and run build again (it will recreate workspace with short hostname in Computer
column) and all subsequent builds should work fine.