Skip to content

Instantly share code, notes, and snippets.

@mrts
Created April 11, 2023 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrts/71a66ccbb04b856d0a3fc132800fb04c to your computer and use it in GitHub Desktop.
Save mrts/71a66ccbb04b856d0a3fc132800fb04c to your computer and use it in GitHub Desktop.
Deploy a Maven package to GitLab Packages
cat << 'EOF' > gitlab-mvn-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</id>
<configuration>
<httpHeaders>
<property>
<name>Deploy-Token</name>
<value>${env.GITLAB_DEPLOY_TOKEN}</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
</settings>
EOF
export GITLAB_DEPLOY_TOKEN='your GitLab deploy token'
mvn -s gitlab-mvn-settings.xml deploy # use --batch-mode in a CI job
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment