How to release built artifacts back-and-forth from one to another repo on GitLab?

Viewed 781

I got a requirement to generate, archive and reuse the artifacts between two different repositories

Repository A: Compile Angular code and create a XLF file

Repository B: Use the 'XLF File' generated above and create a new XLF file

Repository A: Again use the newly generated XLF file to create the final output file

The activities mentioned above should be done using gitlab-ci.yml. I am not sure how to handle this using GitLab CI.

We can push the artifact from Repo A to Repo B. However, CI on Repo A should wait until Repo B pushes a new artifact to Repo A to complete the process

3 Answers

Ideally, you would not push a generated artifact to another Git source repository.

But a GitLab pipeline can retrieve an artifact produced by another one from its URL.

To avoid the back and forth, I would rather have 3 jobs instead of two

  • the first generates XLF file
  • the second curls/fetches that file, and use it to generate new XLF file
  • the third job curls/fetches that file, and complete the process.

How to release built artifacts back-and-forth from one to another repo on GitLab?

Overall, what you need is rules: and needs: documentation. On older gitlab, it was done with API.

CI on Repo A should wait until Repo B pushes a new artifact to Repo A to complete the process

Don't wait. Let the API trigger it.

I tried the following approach and it worked fine or at least I was able to proceed

Due to some reason 'variables' along with CURL did not work as expected but I did not analyze the root cause

Repo A - Pipeline

trigger-repob:                        (Trigger Project B of Repo B)                           
  stage: repob
  trigger:
    project: repob-namespace/projectb
    branch: devops 

test_job:
  image: $CI_REGISTRY/$CI_PROJECT_PATH/base-image:latest
  stage: test_pipeline
  when: delayed
  start_in: 2 minutes
  needs:                                (Use artifacts from Repo B/Project B)
    - 
      project: repob-namespace/projectb
      job: buildprojectb
      ref: devops
      artifacts: true
  script:
  - do something here

Repo B Pipeline

buildprojectb:
  image: php:7.4.11  
  stage: build
  script:
  - do something here
  artifacts:
    paths:
    - outputs/*.xlf
Related