Skip to content

Add CI Job token support to Maven packages API

What does this MR do?

Add CI Job token support to Maven packages API. You can build and upload maven packages from GitLab CI job

ci-settings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
  <servers>
     <server>
       <id>gitlab-maven</id>
       <configuration>
         <httpHeaders>
           <property>
             <name>Job-Token</name>
             <value>CI_JOB_TOKEN</value>
           </property>
         </httpHeaders>
       </configuration>
     </server>
   </servers>
 </settings>

.gitlab-ci.yml

deploy:
  script:
    - 'cp ci-settings.xml /root/.m2/settings.xml'
    - 'sed -i "s/CI_JOB_TOKEN/${CI_JOB_TOKEN}/g" /root/.m2/settings.xml'
    - 'mvn deploy'
  only:
    - master
  image: maven:3.3.9-jdk-8

What are the relevant issue numbers?

https://gitlab.com/gitlab-org/gitlab-ee/issues/5811

Does this MR meet the acceptance criteria?

Edited by Kamil Trzciński

Merge request reports