harness / gitness

Gitness is an Open Source developer platform with Source Control management, Continuous Integration and Continuous Delivery.
https://gitness.com
Apache License 2.0
31.89k stars 2.78k forks source link

Deploying Code on Different Runners based on Branches in Drone CI/CD #3510

Closed tikbox closed 2 months ago

tikbox commented 2 months ago

Dear Drone developers,

I am currently using Drone as my CI/CD tool and have successfully deployed exec runners on multiple machines. However, I have a question regarding deploying code on different runners based on the pushed branches.

Specifically, I would like to know how I can configure Drone to deploy code on different runners depending on the branch being pushed. For instance, I would like code pushed to the "master" branch to be deployed on Runner A, while code pushed to "feature/*" branches should be deployed on Runner B.

Additionally, I have already set up the necessary labels (DRONE_RUNNER_NAME) for each runner, allowing me to differentiate them easily.

Thank you very much for your assistance. I look forward to your response and any insights you can provide.

bradrydzewski commented 2 months ago

We would generally advise using an SSH plugin to remote into a machine and perform the deployment [1] as opposed to pinning a pipeline to a specific runner. With that being said, you could create a multi-pipeline yaml [2] where branch filter logic is defined in the trigger section of the yaml [3] and is routed to a specific runner [4] using the nodes section in the yaml. I hope that helps!

[1] https://drone.discourse.group/t/how-to-route-a-pipeline-to-a-specific-runner/11009 [2] https://docs.drone.io/pipeline/configuration/#multiple-pipelines [3] https://docs.drone.io/pipeline/docker/syntax/trigger/#by-branch [4] https://docs.drone.io/pipeline/docker/syntax/routing/