Search code examples
gitlabgitlab-cigitlab-ci-runnergitlab-api

GitLab: Is it possible to run pipeline on a specific runner?


Is it possible to run a pipeline on a specific runner? (not using tags)

Is it feasible to use environments, or even gitlab runner exec maybe?


Scenario:

Have an existing project with multiple runners already attached to it (specific project token used to register the runner) and has it's own associated tags (so can't change these either).

I'm adding a new runner, however need to test it first to ensure it works, but I need to force the pipeline to build on this machine, without changing any tags, or specific project of the runner.


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:

    • 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...