I'm attempting to substitute a value in package.json
by using sed
to find a static value and replace it with a dynamic bash variable . However, Circle CI is reporting this is wrong but it looks good to me.
Circle CI
GETTING CURRENT DEPLOYMENT INFORMATION...
sed: bad option in substitution expression
sed: bad option in substitution expression
Dockerfile
COPY --from=build /home/node/app/ .
## Get current GIT BRANCH and COMMIT HASH and provide to image
RUN mkdir /root/.gitinfo
COPY ./.git/HEAD /root/.gitinfo/.
COPY ./.git/config /root/.gitinfo/.
RUN echo "GETTING CURRENT DEPLOYMENT INFORMATION..."; \
cat /root/.gitinfo/config | grep url | head -1 | xargs > /GIT_VERSION_URL.txt; \
cat /root/.gitinfo/HEAD | head -1 | xargs > /GIT_VERSION_REF.txt; \
FILE_LINE=$(cat /GIT_VERSION_URL.txt | head -1 | xargs | tr -d '\n'); \
sed -i "s/DOCKER_WILL_PROVIDE_VALUE_A1/$FILE_LINE/g" /home/node/app/package.json; \
FILE_LINE=$(cat /GIT_VERSION_REF.txt | head -1 | xargs | tr -d '\n'); \
sed -i "s/DOCKER_WILL_PROVIDE_VALUE_A2/$FILE_LINE/g" /home/node/app/package.json; \
cat /GIT*; \
rm -rf /root/.gitinfo;
## END
package.json
...
"git": {
"GIT_URL": "DOCKER_WILL_PROVIDE_VALUE_A1",
"GIT_REF": "DOCKER_WILL_PROVIDE_VALUE_A2"
},
...
Why won't sed do the replacement?
EDIT: I do not believe this is a duplicate. What makes this situation unique is that I'm trying to run this inside Docker and doing a dynamic variable replacement in the replace regex. I am NOT using "/" in the regex so this Sed error : bad option in substitution expression is not similar to my problem. Thanks!
EDIT 2: I actually am using "/" in the GIT URL. As Charles pointed out below, this is the likely culprit.