For the past few days I have been trying to setup a GitLab pipeline for my Laravel application, so that it installs, tests, builds and deploys to my kubernetes cluster. However, when i am trying to install composer using the following line:
docker run --volume $(pwd):/app --rm $CONTAINER_REGISTRY_URL/internal/docker/composer:${COMPOSER_TAG} install $COMPOSER_ARGS
I am getting a permission denied error on the $(pwd) command. This is the error:
/scripts-66-218/step_script: eval: line 153: /builds/my-project/laravel-api: Permission denied
I am not an expert in GitLab CI/CD, but I do know my ways with dockers etc, but in this case I don't exactly know why I am getting this permission denied. The files are readable for every user, so I am not sure, but that seems correct. This is the full composer pipeline code:
composer-install-production:
extends: .custom-composer-install
variables:
COMPOSER_ARGS: "--ignore-platform-reqs --no-ansi --no-interaction --no-progress --optimize-autoloader --prefer-dist --no-dev --no-scripts"
before_script:
- echo $CONTAINER_REGISTRY_PASSWORD | docker login -u $CONTAINER_REGISTRY_USERNAME $CONTAINER_REGISTRY_URL --password-stdin
- cp .env.pipeline .env
only:
- tags
.custom-composer-install:
extends: .composer-install
variables:
COMPOSER_TAG: "2"
COMPOSER_SSH_DEPLOY_KEY: $GITLAB_RUNNER_RSA
artifacts:
paths:
- .env
- public/
- vendor/
- storage/
.composer-install:
# Default variables
variables:
COMPOSER_TAG: "prestissimo" # Change composer tag to use a differrent version.
COMPOSER_ARGS: "--ignore-platform-reqs --no-ansi --no-interaction --no-progress --optimize-autoloader --prefer-dist" # If provided, composer arguments are added to the install.
COMPOSER_AUTHJSON: "" # If provided, authentication can be added to install private packages like Nova.
COMPOSER_SSH_DEPLOY_KEY: "" # If provided, adds an SSH key to the composer image to access private packages.
stage: install
before_script:
- echo $CONTAINER_REGISTRY_PASSWORD | docker login -u $CONTAINER_REGISTRY_USERNAME $CONTAINER_REGISTRY_URL --password-stdin
script:
- $(pwd)
- >
if [ "$COMPOSER_AUTHJSON" != "" ]; then
echo $COMPOSER_AUTHJSON > auth.json
fi
- >
if [ "$COMPOSER_SSH_DEPLOY_KEY" == "" ]; then
docker run --volume $PWD:/app --rm $CONTAINER_REGISTRY_URL/internal/docker/composer:${COMPOSER_TAG} install $COMPOSER_ARGS
else
docker run --volume $PWD:/app --rm -e "SSH_DEPLOY_KEY=$COMPOSER_SSH_DEPLOY_KEY" $CONTAINER_REGISTRY_URL/internal/docker/composer:${COMPOSER_TAG} install --ignore-platform-reqs $COMPOSER_ARGS
fi
artifacts:
name: "$CI_JOB_ID-$CI_BUILD_REF_NAME"
expire_in: 1 day
paths:
- vendor/
interruptible: true
And the script crashes on this line:
- $(pwd)
Does somebody know what is going on here and how to fix this?
I would first test if using pws instead of $(pwd) (which executes a command in a subshell) would work:
script:
- pwd
- >
...
You would find $(pwd) when you want to assign the current working directory to a variable, as in here.
ci_app_path=$(pwd) && echo "INFO: current directory: $ci_app_path"
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments