first stage:
download-previous-job-artifacts:
stage: build
rules:
- if: '$Teardownanddestroy && $PREVIOUS_JOB_ID'
image:
name: alpine:3.16
entrypoint: [ "" ]
script:
- apk add --no-cache openssh curl zip unzip
- 'curl --location --output artifacts.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/jobs/$PREVIOUS_JOB_ID/artifacts"'
- unzip artifacts.zip -d artifacts/
- ls -la
- mv artifacts/* $CI_PROJECT_DIR/
artifacts:
untracked: true
when: always
paths:
- "$CI_PROJECT_DIR/ssh_key.pem"
- "$CI_PROJECT_DIR/ssh_command.txt"
- "$CI_PROJECT_DIR/scp_command.txt"
- "$CI_PROJECT_DIR/terraform.tfstate"
- "$CI_PROJECT_DIR/admin_server.tfvars"
second stage rules:
teardown:
stage: teardown
allow_failure: true
extends:
- .ifteardown
third stage:
destroy-admin-server:
stage: cleanup
extends:
- .ifteardownanddestroy
allow_failure: true
interruptible: false
First stage is set always, so it should receive artifacts in both the other two stages but last stage is not getting arfiacts.
When I see the log, it is not able to access the artifacts shared and getting filenotfound errors.