3

I am adding another Agent to my TeamCity build pool.

This is the error message I get when the Agent gets assigned to build a project

Agent failed to create build temp directory at /home/switchbuild/BuildAgent/temp/buildTmp.
Please check agent has necessary permissions and there is enough free space on disk.

There is plenty of space on the BuildAgent server

build5:~/BuildAgent/temp$ df -h
Filesystem             Size  Used Avail Use% Mounted on
udev                   3.9G     0  3.9G   0% /dev
tmpfs                  798M   18M  781M   3% /run
/dev/sda1             1000G   40G  910G   5% /

So I know it's not an issue of having enough free space.

How do I go about giving the BuildAgent java service permissions to create folders in its own workspace?

The file path is local to the build machine so this question does not help.

The Build Agent fails right away and gives the above error every time.

RAZ_Muh_Taz
  • 4,059
  • 1
  • 13
  • 26

1 Answers1

0

It was a simple fix that involved looking at the permissions of the tmp directory on build server in the BuildAgent directory.

Listing the permissions of the files and directories in the BuildAgent directory on the build server

switchbuild@nevcv-build5:~/BuildAgent$ ls -l
total 52
drwxr-xr-x  2 switchbuild switchbuild 4096 Jul 21  2020 bin
-rw-rw-r--  1 switchbuild switchbuild    0 Jul 21  2020 BUILD_78726
drwxr-xr-x  3 switchbuild switchbuild 4096 Apr 24 09:57 conf
drwxr-xr-x  3 switchbuild switchbuild 4096 Dec  9  2019 contrib
drwxr-xr-x  5 switchbuild switchbuild 4096 Jul 21  2020 launcher
drwxr-xr-x  3 switchbuild switchbuild 4096 Jul 21  2020 lib
drwxrwxr-x  2 switchbuild switchbuild 4096 Apr 24 10:01 logs
drwxr-xr-x 51 switchbuild switchbuild 4096 Jul 21  2020 plugins
-rw-rw-r--  1 switchbuild switchbuild  105 Mar 31 09:46 README.txt
-rw-r--r--  1 switchbuild switchbuild  184 Dec  9  2019 service.properties
drwxrwxr-x 14 switchbuild switchbuild 4096 Apr 24 09:57 system
drwxr-xr-x  4 root        root        4096 Apr 24 10:12 temp   <--- not sure why/how this folder got under root permissions...
drwxrwxr-x  5 switchbuild switchbuild 4096 Jul 21  2020 tools
drwxrwxr-x  3 switchbuild switchbuild 4096 Apr 15  2022 work

Change the folder owner to the build server user using chown

switchbuild@nevcv-build5:~/BuildAgent$ sudo chown switchbuild ./temp

switchbuild@nevcv-build5:~/BuildAgent$ ls -l
total 52
drwxr-xr-x  2 switchbuild switchbuild 4096 Jul 21  2020 bin
-rw-rw-r--  1 switchbuild switchbuild    0 Jul 21  2020 BUILD_78726
drwxr-xr-x  3 switchbuild switchbuild 4096 Apr 24 09:57 conf
drwxr-xr-x  3 switchbuild switchbuild 4096 Dec  9  2019 contrib
drwxr-xr-x  5 switchbuild switchbuild 4096 Jul 21  2020 launcher
drwxr-xr-x  3 switchbuild switchbuild 4096 Jul 21  2020 lib
drwxrwxr-x  2 switchbuild switchbuild 4096 Apr 24 10:01 logs
drwxr-xr-x 51 switchbuild switchbuild 4096 Jul 21  2020 plugins
-rw-rw-r--  1 switchbuild switchbuild  105 Mar 31 09:46 README.txt
-rw-r--r--  1 switchbuild switchbuild  184 Dec  9  2019 service.properties
drwxrwxr-x 14 switchbuild switchbuild 4096 Apr 24 09:57 system
drwxr-xr-x  4 switchbuild root        4096 Apr 24 10:12 temp    <--- has the correct owner but not correct group
drwxrwxr-x  5 switchbuild switchbuild 4096 Jul 21  2020 tools
drwxrwxr-x  3 switchbuild switchbuild 4096 Apr 15  2022 work

Change the folder group to the build server user using chgrp

switchbuild@nevcv-build5:~/BuildAgent$ chgrp switchbuild temp

switchbuild@nevcv-build5:~/BuildAgent$ ls -l
total 52
drwxr-xr-x  2 switchbuild switchbuild 4096 Jul 21  2020 bin
-rw-rw-r--  1 switchbuild switchbuild    0 Jul 21  2020 BUILD_78726
drwxr-xr-x  3 switchbuild switchbuild 4096 Apr 24 09:57 conf
drwxr-xr-x  3 switchbuild switchbuild 4096 Dec  9  2019 contrib
drwxr-xr-x  5 switchbuild switchbuild 4096 Jul 21  2020 launcher
drwxr-xr-x  3 switchbuild switchbuild 4096 Jul 21  2020 lib
drwxrwxr-x  2 switchbuild switchbuild 4096 Apr 24 10:01 logs
drwxr-xr-x 51 switchbuild switchbuild 4096 Jul 21  2020 plugins
-rw-rw-r--  1 switchbuild switchbuild  105 Mar 31 09:46 README.txt
-rw-r--r--  1 switchbuild switchbuild  184 Dec  9  2019 service.properties
drwxrwxr-x 14 switchbuild switchbuild 4096 Apr 24 09:57 system
drwxr-xr-x  4 switchbuild switchbuild 4096 Apr 24 10:12 temp    <--- has the correct owner and group
drwxrwxr-x  5 switchbuild switchbuild 4096 Jul 21  2020 tools
drwxrwxr-x  3 switchbuild switchbuild 4096 Apr 15  2022 work

After changing everything to the expected owner and group the BuildAgent was able to create the needed temporary directories to build.

RAZ_Muh_Taz
  • 4,059
  • 1
  • 13
  • 26