GitLab CI: Running JOBS Locally with GitLab Runner using Shell on Windows

GitLab CI: Running JOBS Locally with GitLab Runner using Shell on Windows.

Prerequisites:

  • GitLab account
  • Git installed in the system
  • PowerShell
  • A project hosted on GitLab

Steps to be followed

Step 1) Download Git Runner

Source to install Git Runner: https://docs.gitlab.com/runner/install/windows.html

Step 2) Create a folder named C:\GitLab-Runner\ and paste gitlab-runner.exe file (Download the binary for x86)

Step 3) Run the powershell or cmd with admin privileges

Step 4) Register the Runner

          To register a Runner under Windows:

  • Run the following command:

./gitlab-runner.exe register

  • Enter your GitLab instance URL:

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com )

https://gitlab.com

  • Enter the token you obtained to register the Runner: (refer image below)

Please enter the gitlab-ci token for this runner

xxxxxxxxxx

  • Enter a description for the Runner, you can change this later in GitLab’s UI:

Please enter the gitlab-ci description for this runner

Test Runner

  • Enter the tags associated with the Runner, you can change this later in GitLab’s UI:

Please enter the gitlab-ci tags for this runner (comma separated):

my-tag,another-tag

  • Enter the Runner executor:

Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-

Shell

Note: To find GitLab Runner token, Go to you GitLab Project->Settings->CI/CD->Expand Runner

r1.PNG

Find the Registration token in the above image.

Step 5) Start the runner service

./gitlab-runner.exe start

Check in the gitlab portal

You will be able to see active runners

r2

Step 6) Clone the Project Repo

Use git clone [repo URL] as shown below

r3.PNG

Step 7) Make sure you have gitlab-ci.yml file configured in your root folder

Current Sample Job in yaml file just for Testing the flow

r5

Step 8) Use exec command

The exec command is used to execute the builds locally

./gitlab-runner exec shell [Job Name in your YAML file]

r4.PNG

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s