Mani
Mani

Reputation: 741

Run a script from other project in Gitlab

I have a separate project which has only gitlab-ci.yml.

Pipeline project:

enter image description here

I have multiple projects which access this pipeline. But I have a .sh script in some projects which I need to run from the main pipeline project. I am not sure how to access the script in the pipeline project.

The file role.sh is in the other project which I should access from pipeline project.

.deploy_template: &deploy
  image: docker.artifactory.com/projects/finance:latest
  dependencies:
    - build  
  script:  
      - cp scripts/role.sh rc.sh
      - chmod +x rc.sh
      - ./rc.sh

Can you please guide me how to run script from one project in another project?

Upvotes: 2

Views: 1695

Answers (1)

Andromeda
Andromeda

Reputation: 1463

Given you have access to the project contains the scripts, you can clone the project and then run the script:

.deploy_template: &deploy
  image: docker.artifactory.com/projects/finance:latest
  dependencies:
    - build  
  script:  
      - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/${PROJECT_PATH}.git
      - cd ${directory_locates_script}
      - chmod +x rc.sh
      - ./rc.sh

Upvotes: 3

Related Questions