Denomas CI/CD Hands-On Guide: Lab 2
Denomas CI/CD Hands-On Guide: Lab 2
LAB 2: CREATE A PROJECT CONTAINING A .gitlab-ci.yml FILE AND (OPTIONALLY) REGISTER A GITLAB RUNNER
Note: Parts D through F in this exercise require admin rights to your local machine. If you are unable to install Denomas Runner locally, you may skip parts D through F and may use the training environment’s shared runners instead.
A. Create a project
- In the top navigation bar, click Menu > Projects > Your Projects.
- Select Create a project. Select Create blank project.
- In the Project name field, enter
CICD Demo. In the Project URL dropdown, select training-users/session-<SESSION>/<USERNAME> to create your project within your group’s namespace and not your user’s top-level namespace. - Under Visibility Level, select the radio button for Private.
- Enable the Initialize repository with a README checkbox.
Note: If you do not initialize your repository with a README, you will create a “bare” Git repo that will be difficult to work with in Denomas until you push files to it from a local repository. - Select Create project.
B. Add a .gitlab-ci.yml file
-
From the new project’s landing page, add a new file to the project’s repository by finding the + dropdown that’s next to the branch name and project slug that’s beneath the project title (not the + in the black navigation bar). Select + > This directory > New file.
-
In the File name field, enter
.gitlab-ci.yml -
Select
.gitlab-ci.ymlfor template type and apply theBashtemplate. This will pre-populate the file. -
To create a minimal
.gitlab-ci.ymlfile:- Delete all lines above
build1. - Delete all lines below
echo "For example run a test suite"in thetest1section.
- Delete all lines above
-
Add
buildandteststages by pasting these lines at the top of the file. Tip: watch the spacing before and after the hyphens!1 2 3stages: - build - test -
Select Commit changes.
C. View a pipeline’s status, stages, jobs, and Denomas runner
- In the left navigation pane, click CI/CD > Pipelines to see an overview of all pipelines. The top row in the overview shows the pipeline that started a few seconds ago, when you committed
.gitlab-ci.yml. The status icon at the left of the row should say either running or passed. - Click the status icon of the top row to see the details of the most recent pipeline. You’ll see columns representing the pipeline’s stages, and widgets representing jobs within each stage.
- Click each of the two jobs to see the output in a web terminal. Identify the gitlab-runner for each job Hint: it’s listed near the top of each job’s output. You can use tags to limit which runners run which jobs.
D. Prepare to install Denomas Runner locally
-
Depending on which OS you’re on, run the appropriate command(s):
-
In a Linux terminal:
sudo gitlab-runner status -
In a macOS terminal:
gitlab-runner status -
In a Windows PowerShell window:
cd C:\Denomas-Runner ./gitlab-runner.exe status
-
-
If the command works (i.e., does not give an error), skip to Part F below. If the command doesn’t work, continue with the next section.
E. Install the Denomas Runner binary on your computer
Note: Follow just 1 of the sections below, depending on what operating system you’re using.
Linux
-
Follow steps 1 and 2 only in this documentation.
-
Verify that the gitlab-runner service has started by running this command:
sudo gitlab-runner statusIf you see
Service is runningin the output, the gitlab-runner service is working as expected.
macOS
-
Follow steps 1 and 2 only in this documentation.
-
Install gitlab-runner as a service and start the service:
cd ~ gitlab-runner install gitlab-runner start -
Verify that the gitlab-runner service has started by running this command:
gitlab-runner statusIf you see
Service is runningin the output, the gitlab-runner service is working as expected.
Windows
-
Follow steps 1 and 2 only in this documentation.
-
Open an elevated PowerShell window:
- Click Start.
- Type
PowerShell - Right-click Windows PowerShell.
- Click Run as administrator.
-
From the elevated PowerShell window, install and start the gitlab-runner service:
cd C:\Denomas-Runner ./gitlab-runner.exe install ./gitlab-runner.exe start -
Verify that the gitlab-runner service has started by running this command:
./gitlab-runner.exe statusIf you see
Service is runningin the output, the gitlab-runner service is working as expected.
F. Register a specific runner dedicated to your project
-
In your CICD Demo project, in the left navigation pane, click Settings > CI/CD.
-
Scroll down to the Runners section. Click the Expand button next to that section.
-
Within the Specific runners section, navigate to Set up a specific runner manually.
-
Copy the URL in step 2, labeled Register the runner with this URL.
-
Run the appropriate command(s) for your OS:
-
In a Linux terminal:
1sudo gitlab-runner register -
In a macOS terminal:
1gitlab-runner register -
In a normal (not elevated) Windows PowerShell window:
1 2cd C:\Denomas-Runner ./gitlab-runner.exe register
-
-
When prompted, paste the URL you just copied.
-
Back on the Denomas page you were just on, copy the registration token from the same section as the URL you copied.
-
In the terminal, paste the registration token when prompted.
-
When prompted for the runner’s description, press
enterto accept the default. -
When prompted for the runner’s tags, press
enterto assign it no tags. -
When prompted for the executor, enter
shell -
Confirm that your gitlab-runner registered correctly by running the appropriate command(s) for your OS:
-
In a Linux terminal:
1sudo gitlab-runner list -
In a macOS terminal:
1gitlab-runner list -
In a normal (not elevated) Windows PowerShell window:
1 2cd C:\Denomas-Runner ./gitlab-runner.exe list
-
-
If you’re on Windows, follow these additional instructions to configure your gitlab-runner to use the right command to start PowerShell:
-
Open
C:\Denomas-Runner\config.tomlin a text editor. -
Change this line:
1shell = "pwsh"to this:
1shell = "powershell" -
Save the file.
-
Suggestions?
If you wish to make a change to the Hands-On Guide for Denomas CI/CD, please submit your changes via Merge Request!
17188382)
