I am trying to figure out the cleanest/simplest way to set my connection string in an application.properties file in my spring boot app from our ci/pipeline. We are using gitlab. We are deploying two instances of our services, etc. I also have little/no yaml experience.
So the current application.properties has a value/property: spring.data.mongodb.uri=mongodb://.........
Our .gitlab-ci.yml looks something like this:
cache:
untracked: true
build:
stage: build
script: "mvn install -B -DskipTests"
artifacts:
paths:
- target/*.jar
test:
script: "mvn test -B"
integration-test:
script: "mvn failsafe:integration-test failsafe:verify -B"
deploy:
stage: deploy
script:
- scp target/*.jar server:~/deployments/${CI_PROJECT_NAME}.jar
- ssh -t -t server "sudo systemctl restart ${CI_PROJECT_NAME}"
environment:
name: test
only:
- master
deploy_demo:
stage: deploy
script:
- "docker build -t server:5000/service ."
- "docker push server:5000/service"
- "ssh server 'docker-compose pull service'"
- "ssh server 'docker-compose up -d service'"
environment:
name: test
when: manual
only:
- master
I've read some options like adding profiles, etc. I'm just looking for the easiest way to have the default build use one connection string and the deploy_demo job use another.
Thanks, Tim
I don't want to leave this open, I choose to create two profiles and in the build command set spring.profiles.active=demo for the one build and just used default for the other. Thanks mavriksc, for the info
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.