How can I set the path of the settings.xml from environment variable in a mvn build?
I have tried:
export MAVEN_OPTS="-s /tmp/settings.xml"
or
export MAVEN_OPTS="--settings /tmp/settings.xml"
but it not works.
I need it, because I cannot modify the build command.
Starting with Maven 3.9, you can set it through MAVEN_ARGS:
export MAVEN_ARGS="--settings /tmp/settings.xml"
If you are using an older version, you could try something like this in your gitlab-ci build script, just before calling mvn:
(see https://maven.apache.org/configure.html#mvn-maven-config-file)
mkdir -p .mvn && echo "-s /tmp/settings.xml" >> .mvn/maven.config
This does not modify the repo, only adds a file to the local checkout within the running build job.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With