Debian Linux, Unable to run custom script, error=13, Permission denied.

Hi all,

I have a problem when running the project build on the Teamcity web UI. I'm running it on localhost and on a Linux Debian VM. When running the project build I get the following error:

Cannot run process: Cannot run program "/home/debian/Share/TeamCity/buildAgent/temp/agentTmp/custom_script5201474448085333627" 
(in directory "/home/debian/Share/TeamCity/buildAgent/work/b27f44c52eb1144d"): error=13, Permission denied
Step Command Line failed with unexpected error

For some reason, this only occurs when running on the linux VM. I've been able to set up a build agent on windows, and it runs fine. The build was able to run successfully. The build step simply just runs a file that is on git. The file on git has execute permissions from what I checked with ls -l. The content of the file is just ./myscript.sh. I've also tried just myscript.sh or added #! /bin/bash, but none of that fixes the issue as I believe that it just can't run the custom script at all, so the contents shouldn't matter.

Other things I've done (Note that it is unable to run the custom_script, I've added random junk in custom_script and it still says build runner failed where it should've said 127 error):

  • I've installed TeamCity on Windows host machine, and ran the build agent on Linux VM and still get the permission denied error, but the build agent running on windows still worked fine.
  • I've also ran the ./agent.sh script as root and I still get the permission denied error.
  • I've explicitly added the username, user.name, and group (teamcity.agent.jvm.user.name, system.buildagent.username, system.buildagent.group) to the conf/buildAgent.properties file (shows up correctly on the web ui). In which the username and group was able to run the script manually, but I still get permission denied error when running it on the web ui.
  • I've reinstalled and installed back the build agent. Downloaded Full Zip, and then ran ./agent.sh
  • Installed latest java - OpenJDK 11.0.12 and team city is 2022.10.2
  • Added the custom scripts and work directory that teamcity generates onto $PATH
  • Gave execute permissions to agent.sh. Check ls -l and all files, folders, etc has read, write, and execute permissions in the TeamCity directory (includes the custom scripts and work directory)
  • I've tried running ./agent.sh executor on the build config xml file but that gives a different error: Failed to call agent preInit. Failed to deserialize build file, even though the build file looks correct and contains all the information show in in the web UI and the syntax looks correct.
  • I've tired running multiple projects. All work on windows host, all have permission denied in linux VM
  • I've also tried adding service file for the agent with the user and group being ones that I've tested that are able to run the custom script and its content
  • Tried both localhost and the ip from ipconfg/ifconfig and that didn't change anything
  • I've tried ./agent.sh start debug, but the logs that I see aren't very useful.

Is there a way to see what user exactly that teamcity is running the custom scripts on? I've checked in ps and the it runs on root or debian (user that could run the scripts) so it should work fine... Oddly enough, sometimes (very rarely) it is able to run the custom_script that it generates. Unable to replicate it.

Also not sure if it's a VM problem... I'm able to see the agent running on web UI, and I can access web UI on both machines, so I don't think it is...

Please let me know if there any information you need. I think I'm almost out of options. 
Thank you in advance!

0
2 comments

Hello,

When you say that you run "./agent.sh script as root", do you mean that you started the build agent from the root account?

The permission denied error suggests that the account running the build agent does not have sufficient permissions to run the script in the mentioned directory. Please make sure the account running the build agent has full permissions in the directory: 

/home/debian/Share/TeamCity/buildAgent/..

Please let me know if this helps!

Thank you,

Guilherme

0

Hi Guilherme,

I was able to fix it by moving build agent into a different folder (Documents folder). I found out that my auto mount script was causing problems when mounting the Shared folder.

Thanks for your time!

0

Please sign in to leave a comment.