Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab Shell Script Permission Denied

I am running a simple shell script with Gitlab CICD and I am getting Permission denied. Kindly suggest

When I do chmod +x test.sh it says operation not permitted.

stages:
  - build 

build: 
  stage: build 
  script: 
    - ls
    - ./test.sh

Shell test.sh

echo Hi

Error:

enter image description here

like image 967
Satheesh Avatar asked Feb 21 '26 09:02

Satheesh


2 Answers

Instead of simply running chmod on your local system, it's better to run git update-index --chmod=+x path/to/file. This adds an executable flag to a file in Git and should ensure that a script can be executed inside a GitLab pipeline.

See also this question.

like image 64
nichoio Avatar answered Feb 22 '26 21:02

nichoio


You have to either:

1- Run bash ./test.sh

OR

2- Add the line #!/bin/bash to the top of test.sh so that it knows to run it within bash

like image 31
frakman1 Avatar answered Feb 22 '26 22:02

frakman1