0

Below is my gitlab-ci.yml file, where I have 2 stages.

stages:
  - upload
  - publish

upload-file:
  stage: upload
  script:
    - <command>
  when: manual

publish-file:
  stage: publish
  script:
    - command --fileId=1234    # Need to read fileId from the upload-file job output
  needs: [upload-theme]
  when: manual

When the first job 'upload-file' is successful, it outputs below json

{
  "fileId": "ef595c63-b5cb-453d-8f3a-8ad2697a0526"
}

I need to access this fileId in my second job -> 'publish-file'. How can I achieve this? Please advise.

3
  • docs.gitlab.com/ee/ci/jobs/job_artifacts.html Commented Apr 8, 2024 at 6:14
  • I tried adding artifacts as suggested, upload-file: stage: upload script: - <command> artifacts: paths: - file.txt publish-file: stage: publish script: - cat file.txt Getting below error. Uploading artifacts... WARNING: file.txt: no matching files. Ensure that the artifact path is relative to the working directory (/builds/org/web/app-files) ERROR: No files to upload. Please help. Commented Apr 8, 2024 at 6:58
  • Which path are you writting the file.txt to? it needs to be relative to the project dir. Paths are relative to the project directory ($CI_PROJECT_DIR) and can’t directly link outside it. Commented Apr 8, 2024 at 7:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.