Reputation: 608
I have the below stage that will run a maven build on my java code, which works fine. However I have multiple Java projects running this same maven build, and one of the Java projects needs additional commands to be run through that script
.
For example the first command in the script
needs to be a npm i yarn
, but only for a single project. How would I use variables to add this?
build maven:
artifacts:
expire_in: 3 day # don't keep these around for long
paths:
- target/
script:
- echo "PIPELINE_DEFAULT_IMAGE - ${PIPELINE_DEFAULT_IMAGE}"
- mvn -version
- mvn package -Pprod -DskipTests=true
Upvotes: 0
Views: 789
Reputation: 1668
The variable CI_PROJECT_NAME
contains the name of the project.
Example .gitlab-ci.yml
:
myjob:
script:
- if [ "${CI_PROJECT_NAME}" == "test" ]; then echo I am a CI job in the test project; fi
- echo done
The first script line will only run in the test
project. The second script line will run in every project.
Upvotes: 1