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:

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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With