Scenario
- Create a new virtual machine with runner installed
- Trigger a pipeline to run (from another project), which runs on this new virtual machine
- Do something else, or fail if pipeline above fails on the new virtual machine
Question
I'm using GitLabs Triggers API to run a pipeline from a project, however would like it to run on this newly created virtual machine.
What would be the best way of parsing this information to the GitLab API, or would something like tags be the best way of doing this?
.gitlab-ci.yml
stages:
- deploy to test
- test
- deploy to prod
Terraform Deploy To Test:
stage: deploy to test
script:
- cd test_deploy
- python deploy.py
Testing:
stage: test
script:
- curl --request POST --form token=TOKEN --form ref=master http://gitlab.example.com/api/v4/projects/12/trigger/pipeline
Terraform Deploy to Prod:
stage: deploy to prod
script:
- do something if the above testing succeeds, or fail
The above gitlab-ci
file would generate a new build machine and deploy it to the "test group" within vsphere with a python script. (Deploying it would activate a gitlab-runner
and tie it to a specific project and have some tags associated with it).
To test, it then triggers a pipeline call using the GitLab API, and I would like that pipeline to run on the new generated build machine on vsphere.
Would a work around maybe be something like using gitlab runner exec command or using environments?
deploy.py
is just running some Terraform commands and can output the ip of the machine generated. I was more thinking of using tags, but then there are issues of tags on the existing project. Project 12 is just a test project with echo calls in a pipeline. Would you have any other suggestions on how to do something like this?