Skip to content
Snippets Groups Projects
Commit 512333bd authored by Eskudero Gurrutxaga, Ibon's avatar Eskudero Gurrutxaga, Ibon
Browse files

parameterize deploy variables to make javadoc:jar % source:jar optional. Set...

parameterize deploy variables to make javadoc:jar % source:jar optional. Set pom folder instead of file
parent ed65a67e
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,7 @@ stages: ...@@ -22,7 +22,7 @@ stages:
Additionally the `mvn` program will look for the pom in the root of the repository, but typically we have all the java Additionally the `mvn` program will look for the pom in the root of the repository, but typically we have all the java
package inside a folder, so we need to tell mvn to look for the pom in that folder, for doing so we have to overwrite the package inside a folder, so we need to tell mvn to look for the pom in that folder, for doing so we have to overwrite the
`POM_FILE` variable defined in the [build.yml](build.yml) file. For doing so we have to write the following in ur CI file. `MAVEN_POM_DIR` variable defined in the [build.yml](build.yml) file. For doing so we have to write the following in ur CI file.
```yml ```yml
variables: variables:
...@@ -30,6 +30,14 @@ variables: ...@@ -30,6 +30,14 @@ variables:
``` ```
There are also 2 variables that are used in deploy command that can be overrided:
```yml
variables:
MAVEN_BUILD_OPTIONAL: "" # empty by default. Can be used for javadoc:jar, for example
MAVEN_BUILD_SOURCE: "jar" # Indicates the generated source type (jar, war ...)
```
## Example ## Example
An example of a valid .gitlab-ci.yml can be: An example of a valid .gitlab-ci.yml can be:
......
variables: variables:
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode" MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository" MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
POM_FILE: "pom.xml" MAVEN_POM_DIR: ""
cache: cache:
paths: paths:
...@@ -16,7 +16,7 @@ build: ...@@ -16,7 +16,7 @@ build:
script: script:
- mkdir -p $CI_PROJECT_DIR/.m2 - mkdir -p $CI_PROJECT_DIR/.m2
- cp $MAVEN_SETTINGS_XML $CI_PROJECT_DIR/.m2/settings.xml - cp $MAVEN_SETTINGS_XML $CI_PROJECT_DIR/.m2/settings.xml
- mvn $MAVEN_CLI_OPTS -f $POM_FILE compile - mvn $MAVEN_CLI_OPTS -f $MAVEN_POM_DIR/pom.xml compile
only: only:
- master - master
- tags - tags
......
variables:
MAVEN_BUILD_OPTIONAL: ""
MAVEN_BUILD_SOURCE: "jar"
deploy: deploy:
stage: deploy stage: deploy
image: $ACR_URL/maven:latest image: $ACR_URL/maven:latest
...@@ -5,6 +9,6 @@ deploy: ...@@ -5,6 +9,6 @@ deploy:
- docker - docker
script: script:
- cp $MAVEN_SETTINGS_XML $CI_PROJECT_DIR/.m2/settings.xml - cp $MAVEN_SETTINGS_XML $CI_PROJECT_DIR/.m2/settings.xml
- mvn $MAVEN_CLI_OPTS -f $POM_FILE -s $MAVEN_SETTINGS_XML clean javadoc:jar source:jar deploy - mvn $MAVEN_CLI_OPTS -f $MAVEN_POM_DIR/pom.xml -s $MAVEN_SETTINGS_XML clean $MAVEN_BUILD_OPTIONAL source:$MAVEN_BUILD_SOURCE deploy
only: only:
- tags - tags
deploy:
stage: deploy
image: $ACR_URL/maven:latest
tags:
- docker
script:
- cp $MAVEN_SETTINGS_XML $CI_PROJECT_DIR/.m2/settings.xml
- mvn $MAVEN_CLI_OPTS -f $POM_FILE -s $MAVEN_SETTINGS_XML clean $MAVEN_GENERATE_JAVADOC source:jar deploy
only:
- tags
...@@ -13,7 +13,7 @@ sonarqube-check: ...@@ -13,7 +13,7 @@ sonarqube-check:
script: script:
- mkdir -p $CI_PROJECT_DIR/.m2 - mkdir -p $CI_PROJECT_DIR/.m2
- cp $MAVEN_SETTINGS_XML $CI_PROJECT_DIR/.m2/settings.xml - cp $MAVEN_SETTINGS_XML $CI_PROJECT_DIR/.m2/settings.xml
- mvn $MAVEN_CLI_OPTS -f $POM_FILE verify sonar:sonar - mvn $MAVEN_CLI_OPTS -f $MAVEN_POM_DIR/pom.xml verify sonar:sonar
allow_failure: true allow_failure: true
only: only:
- master # or the name of your main branch - master # or the name of your main branch
......
...@@ -5,7 +5,7 @@ test: ...@@ -5,7 +5,7 @@ test:
- docker - docker
script: script:
- cp $MAVEN_SETTINGS_XML $CI_PROJECT_DIR/.m2/settings.xml - cp $MAVEN_SETTINGS_XML $CI_PROJECT_DIR/.m2/settings.xml
- mvn $MAVEN_CLI_OPTS -f $POM_FILE -s $MAVEN_SETTINGS_XML test - mvn $MAVEN_CLI_OPTS -f $MAVEN_POM_DIR/pom.xml -s $MAVEN_SETTINGS_XML test
only: only:
- master - master
- tags - tags
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment