Skip to content

Sed command in not executing as its executing in linux shell

I am trying to edit my config .yml file at build time.

gitlab-ci.yaml file

variables: QA_JDBC_URL: jdbc:sqlserver://domian:1433;database=Datamart

build: stage: build image: container-registry.ascendlearning.com/sre/docker-images/docker script: - sed -i 's/jdbc-url-value/'${QA_JDBC_URL}'/g' src/config.yml

config.yml file


spring: application: name: app datasource: nhavitals: readds: driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver jdbc-url: jdbc-url-value

Getting the below error: $ echo $QA_JDBC_URL jdbc:sqlserver://domian:1433;database=Datamart // echo is printing the exact value $ sed -i 's/jdbc-url-value/'${QA_JDBC_URL}'/g' src/config.yml sed: bad option in substitution expression ERROR: Job failed: command terminated with exit code 1

Have tried a lot of other options mentioned below: sed -i 's/jdbc-url-value/'${STG_JDBC_URL}'/g' sed -i "s/jdbc-url-value/'${STG_JDBC_URL}'/g" sed -i "s/jdbc-url-value/'$STG_JDBC_URL'/g" // its just adding the value $STG_JDBC_URL to config file not the value sed -i 's/jdbc-url-value/"STG_JDBC_URL"/g' // its just adding the value "STG_JDBC_URL" to config file not the value

Please let me know how can i make it work ,Thanks in advance.

Edited by kumar