Skip to content

How to run script from file in another project using include?

I'm trying to run a shell script from my template file located in another project via my include.

How should this be configured to work? Below scripts are oversimplified versions of my code.

ProjectA template.yml

deploy:
  before_script:
    - chmod +x ./.run.sh
    - source ./.run.sh

ProjectB gitlab-ci.yml

include:
 - project: 'project-name/ci-cd'
    ref: master
    file: '/template.yml'

stages:
  - deploy

Clearly, the commands are actually being run from ProjectB and not ProjectA where the template resides. This can further be confirmed by adding ls -a to see which files the template can see.

So how should we be calling run.sh? Both projects are on the same GitLab instance under different groups.