Commit a6cb54e7 authored by Achilleas Pipinellis's avatar Achilleas Pipinellis

Merge branch 'improve-maven-docs' into 'master'

Update maven docs

Closes #8032

See merge request gitlab-org/gitlab-ee!8056
parents adf5bb7f a8cc116e
...@@ -74,7 +74,7 @@ To authenticate with a CI job token, add a corresponding section to your ...@@ -74,7 +74,7 @@ To authenticate with a CI job token, add a corresponding section to your
<httpHeaders> <httpHeaders>
<property> <property>
<name>Job-Token</name> <name>Job-Token</name>
<value>CI_JOB_TOKEN</value> <value>${env.CI_JOB_TOKEN}</value>
</property> </property>
</httpHeaders> </httpHeaders>
</configuration> </configuration>
...@@ -152,7 +152,7 @@ shows how to create a new package each time the `master` branch is updated: ...@@ -152,7 +152,7 @@ shows how to create a new package each time the `master` branch is updated:
<httpHeaders> <httpHeaders>
<property> <property>
<name>Job-Token</name> <name>Job-Token</name>
<value>CI_JOB_TOKEN</value> <value>${env.CI_JOB_TOKEN}</value>
</property> </property>
</httpHeaders> </httpHeaders>
</configuration> </configuration>
...@@ -167,24 +167,23 @@ shows how to create a new package each time the `master` branch is updated: ...@@ -167,24 +167,23 @@ shows how to create a new package each time the `master` branch is updated:
<repositories> <repositories>
<repository> <repository>
<id>gitlab-maven</id> <id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> <url>https://gitlab.com/api/v4/projects/${env.CI_PROJECT_ID}packages/maven</url>
</repository> </repository>
</repositories> </repositories>
<distributionManagement> <distributionManagement>
<repository> <repository>
<id>gitlab-maven</id> <id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> <url>https://gitlab.com/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url>
</repository> </repository>
<snapshotRepository> <snapshotRepository>
<id>gitlab-maven</id> <id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> <url>https://gitlab.com/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url>
</snapshotRepository> </snapshotRepository>
</distributionManagement> </distributionManagement>
``` ```
TIP: **Tip:** TIP: **Tip:**
You can either leave GitLab CI/CD to replace your project ID value while You can either let Maven utilize the CI environment variables or hardcode your project's ID.
the deploy job is running or hardcode your project's ID.
1. Add a `deploy` job to your `.gitlab-ci.yml` file: 1. Add a `deploy` job to your `.gitlab-ci.yml` file:
...@@ -192,10 +191,7 @@ shows how to create a new package each time the `master` branch is updated: ...@@ -192,10 +191,7 @@ shows how to create a new package each time the `master` branch is updated:
deploy: deploy:
image: maven:3.3.9-jdk-8 image: maven:3.3.9-jdk-8
script: script:
- 'cp ci_settings.xml /root/.m2/settings.xml' - 'mvn deploy -s ci_settings.xml'
- 'sed -i "s/CI_JOB_TOKEN/${CI_JOB_TOKEN}/g" /root/.m2/settings.xml'
- 'sed -i "s/PROJECT_ID/${CI_PROJECT_ID}/g" pom.xml'
- 'mvn deploy'
only: only:
- master - master
``` ```
...@@ -204,6 +200,5 @@ shows how to create a new package each time the `master` branch is updated: ...@@ -204,6 +200,5 @@ shows how to create a new package each time the `master` branch is updated:
The next time the `deploy` job runs, it will copy `ci_settings.xml` to the The next time the `deploy` job runs, it will copy `ci_settings.xml` to the
user's home location (in this case the user is `root` since it runs in a user's home location (in this case the user is `root` since it runs in a
Docker container), and `sed` will replace the placeholder values with the Docker container), and Maven will utilize the configured CI
contents of the actual
[environment variables](../../../ci/variables/README.md#predefined-variables-environment-variables). [environment variables](../../../ci/variables/README.md#predefined-variables-environment-variables).
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment