Answer the question
In order to leave comments, you need to log in
How to change a line in a file in gitlab-ci?
Hello, I have the following issue. There is a .gitlab-ci.yml file in which you need to change a number of lines in the files before executing the docker build command, I will take the .env file as an example, you need to replace the DB_PASSWORD line.
Tried to execute:
docker-build:
stage: build
script:
- perl -pi -e 's/DB_PASSWORD=(\w+){1,}/DB_PASSWORD=${TEST_DB_PASS}/g' .env.build
- docker build -f docker/Dockerfile -t ${BASE_IMAGE}:latest .
only:
- develop
tags:
- docker
Can't open perl script "s/DB_PASSWORD=(\w+){1,}/DB_PASSWORD=${TEST_DB_PASS}/g": No such file or directory
Answer the question
In order to leave comments, you need to log in
It seems to me that gitlab does not like something in the syntax. I would try wrapping it in a bash or perl script.
Script type
:
- inject_password.sh .env.build
- docker build -f docker/Dockerfile -t ${BASE_IMAGE}:latest .
Or you can not edit at all, but substitute the password through the environment variable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question