You have to publish a Maven package to GitLab's package registry from CI.
IntermediateScenarioGitLab CI
Answer
Situation read → Use the built-in registry with job token.
What I'd do →
- Configure
distributionManagementpointing to${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven. - Add a
settings.xmlserver with headerJob-Tokenand value${env.CI_JOB_TOKEN}. - Run
mvn deploy -s ci_settings.xml.
Why → The job token is short-lived and scoped to the pipeline.
Interview tip → Know that CI_JOB_TOKEN access to other projects is allow-list based.
More on GitLab CI
How does GitLab CI/CD work at a high level?BeginnerWhat is a GitLab Runner and what executors exist?IntermediateWhat are the types of runners (shared, group, project) and tags?IntermediateHow do `rules:` work and how do they replace `only/except`?IntermediateWhat are workflow rules and how do they prevent duplicate pipelines?AdvancedHow do artifacts and cache differ in GitLab CI?Intermediate