Gitlab deployment using local vm

hello guys , im workin on a gitlab ci project , so i already built and tested the maven project , now i need to deploy it on a local virtual machine using ubunto 20.04 app.
I need the deployment to be triggerd in every merge request , but i dont have any clue how to to push the artifact the the vp , and how to deploy it…

Hi @akwa-wehed

The easiest way, IMO, is to have a GitLab runner on your deployment machine / VM, and create a CI job that only runs on your default branch which performs the deployment.

You can then tag the runner with a tag like production and tag the deploy job in your CI config with the same tag, to make sure that that job only runs on the right runner.

If you know how you would deploy your project manually via the command line, then it’s just a matter of transcribing those steps into the script of your deploy job.

hello @snim2
actually , i got a VM in which the runner is on , and i want to deploy my project in anther vm that i create in my own machine with vmbox , i already installed docker on it and i created the dockerfile , i just need to know how to copy the artefact the deployment vm and run it
ps: im new in devops x)

Right, so you want a second runner on your deployment VM, which handles this. It’s quite normal to have a number of different runners for one project, some might be used to have the capacity to have lots of feature branch pipelines running all at once, and some might be for deployments.

That’s partly why you want to use tags to “pin” some deploy jobs to the right runner on your staging or production server.

A typical pattern is to run all of the “build” and “test” jobs on a build runner, and then the deploy job moves the generated artifacts to the deployment VM / machine.

If you do it this way, you don’t need to “move” anything explicitly, because the artifacts will be passed automatically from one pipeline stage to the next.