patternMinor
GitLab - trigger pipeline to build on specific runner
Viewed 0 times
triggergitlabrunnerspecificbuildpipeline
Problem
Scenario
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
The above
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?
- 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 failThe 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?
Solution
There currently isn't a solution for building on a specific runner in GitLab, but there is an issue open for Sticky Runners, which hopefully will be out in the next 3-6 months according to the Milestones!
The work around I've done so far to build a project on a specific runner is to use the GitLab Runner API, in a rather hacky way, along the lines of:
The work around I've done so far to build a project on a specific runner is to use the GitLab Runner API, in a rather hacky way, along the lines of:
- Get all project runners
- As I know I've deployed the latest runner, that would have the highest runner "number"
- Pause all the other runners associated with the project in question
- Trigger the pipeline to build on the latest runner
- Poll the GitLab API to get the status of the pipeline
- Once that succeeds, resume all other runners!
- If the pipeline fails, remember to resume the paused runners...
Context
StackExchange DevOps Q#2395, answer score: 2
Revisions (0)
No revisions yet.