0

I'm having trouble getting a gitlab-runner to execute tasks and not sure what I am doing wrong. This is running in Kubernetes but probably not related to Docker or Kubernetes or anything else.

/bin/bash: line 1: /scripts-1002-1043121/prepare_script: Permission denied 

Executing into the actual pod:

runner-qeaugn8yj-project-1002-concurrent-0-m5ikq7m3:/# ps -auxwww USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 2416 1784 ? Ss 10:21 0:00 /bin/bash root 15 0.0 0.0 2740 2464 pts/0 Ss 10:50 0:00 bash root 21 0.0 0.0 1740 788 pts/0 R+ 10:50 0:00 ps -auxwww runner-qeaugn8yj-project-1002-concurrent-0-m5ikq7m3:/# ls -lahtr /scripts-1002-1043121/prepare_script -rwxrwxrwx 1 root root 434 Oct 4 10:21 /scripts-1002-1043121/prepare_script runner-qeaugn8yj-project-1002-concurrent-0-m5ikq7m3:/# /scripts-1002-1043121/prepare_script bash: /scripts-1002-1043121/prepare_script: Permission denied runner-qeaugn8yj-project-1002-concurrent-0-m5ikq7m3:/# bash /scripts-1002-1043121/prepare_script {"script": "/scripts-1002-1043121/prepare_script"} Running on runner-qeaugn8yj-project-1002-concurrent-0-m5ikq7m3 via gitlab-runner-7b66fddb55-tr6b5... {"command_exit_code": 0, "script": "/scripts-1002-1043121/prepare_script"} 

The script is running as root and so is my output from above.

runner-qeaugn8yj-project-1002-concurrent-0-m5ikq7m3:/# cat /scripts-1002-1043121/prepare_script #!/usr/bin/env bash start_json="{\"script\": \"$0\"}" echo "$start_json" ... 
1
  • 2
    In general such problem may be caused by noexec option given to mount. I don't know Kubernetes at all, so I cannot tell if (how, why) this is possible in your case. Commented Oct 4, 2023 at 15:51

1 Answer 1

1

Sometimes system security prevents scripts from running is certain directories. To get around this, you can try running the script in a different location or type bash before the script name. This invokes a sub shell with different file permissions.

bash /scripts-1002-1043121/prepare_script 
2
  • Thank you. This works, as shown above, but I don't know why the original script fails, which I have no control over. If there's a chmod or chown that I can run, I can gladly try that. Commented Oct 4, 2023 at 22:24
  • @brainwash The chmod command will help you because your permission is already at 777. This means the script is already executable. This is the command: chmod +x Commented Oct 5, 2023 at 0:03

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.