I have two different projects. project1 and project2.
Inside project1, I have file_project1 file:
apply:
stage: apply
script:
- bash folder/scripts/automation.sh
rules:
- if: $CI_PIPELINE_SOURCE == "push"
when: always
In project2, I have created the .gitlab-ci.yml and I have included the project1 and the file_project1:
include:
- project: 'namespace/project1'
ref: main
file: 'file_project1'
During the execution, project2 does not recognize the folder/scripts/automation.sh. I got the following error:
bash: folder/scripts/automation.sh: No such file or directory
Please, how can the pipeline inside project2 executes correctly the bash instruction defined in project1 ?
I would clone project1 from the project2 job, then the script would be in project1/folder/scripts/automation.sh. See, GitLab CI/CD job token.
my-job:
script:
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.example.com/<namespace>/<project>
The include keyword is used for importing .yml files into .gitlab-ci.yml. So, it may not be useful, here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With