Override Gitlab CI Artifact in Package Registry

Viewed 1936

I'm using gitlab ci do build a antora ui bundle (works) and upload the built zip file to gitlabs package registry. This sort of works as well. But I always get a new entry for each built job execution. See https://gitlab.com/docs-central/antora-ui-bundle/-/packages/1771084 ... The result I desire is to have only one artifact in the package registry (hence the verseion "latest") and override this file with each successfull job execution.

Since I like to use this Latest-Build for my antora config, I need the URL to remain the same all the time. I just want to replace the artifact behind this URL with my latest build result.

my .gitlab-ci.yml file:

image: node:10.14.2-stretch

stages:
  - setup
  - verify
  - build
  - deploy

variables:
  PACKAGENAME: 'antora-ui-bundle'
  VERSION: 'LATEST'

install:
  stage: setup
  cache:
    paths:
    - .cache/npm
  script:
  - &npm_install
    npm install --quiet --no-progress --cache=.cache/npm

lint:
  stage: verify
  cache: &pull_cache
    policy: pull
    paths:
    - .cache/npm
  script:
  - *npm_install
  - node_modules/.bin/gulp lint

bundle-stable:
  stage: build
  only:
  - master@docs-central/antora-ui-bundle
  cache: *pull_cache
  script:
  - *npm_install
  - node_modules/.bin/gulp bundle
  artifacts:
    paths:
    - target/build/ui-bundle.zip

bundle-dev:
  stage: build
  except:
  - master
  cache: *pull_cache
  script:
  - *npm_install
  - node_modules/.bin/gulp bundle
  artifacts:
    expire_in: 1 day # unless marked as keep from job page
    paths:
    - target/build/ui-bundle.zip

upload-to-package-registry:
  stage: deploy
  script:
    - 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file target/build/ui-bundle.zip ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PACKAGENAME}/${VERSION}/${PACKAGENAME}-${VERSION}.zip'

Anyone got an idea on how I can achieve this? Thanks and best regards. Sebastian

0 Answers
Related