- Preference > Access Token
- Define Token name, Expiration date, Scopes
- Memorize the PTA
- When you access the remote repository, you are asked to provide the information below
Username for 'https://gitlab.com': [YOUR GITLAB EMAIL ADDRESS]
Password for 'https://xxxxx@xxxxx.com@gitlab.com': [PTA]
Option2: SSH key
Ubuntu terminal
- Generate SSH key
You set up the password for the key.
mkdir ~/.ssh
cd ~/.ssh
ssh-keygen -t rsa -C xxxxx@xxxxx.com
- Display the public key and copy
cat ~/.ssh/id_rsa.pub
GitLab portal
- Set up the public key at GitLab
- Preferences > SSH key
- Paste the public key
- Define Title, Usage type, Expiration date
- Get the SSH URL for your project
- Clone with SSH
Example URL
git@gitlab.com:xxxxx/xxxxx.git
Ubuntu terminal
- Create config file based on the GitLab URL
touch ~/.ssh/config
chmod 644
vi ~/.ssh/config
~/.ssh/config
Host gitlab.com
HostName gitlab.com
User git
IdentityFile ~/.ssh/id_rsa
- Set SSH connection to the remote repository
git remote -v
git remote set-url origin git@gitlab.com:xxxxxxx/xxxxx.git
- Automate ssh-agent so you can avoid inputting the password every time
vi ~/.bashrc
~/.bashrc
# Enable ssh-agent
eval `ssh-agent` 1>/dev/null
ssh-add ~/.ssh/id_rsa
vi ~/.bash_logout
~/.bash_logout
# Disable ssh-agent
eval `ssh-agent -k`
- Restart the terminal
GitLab Runner installation for EC2 (Project-specific runner)
Install Git
- Install from the official site
Install Powershell
- Install the up-to-date Powershell from the official site
- Make sure pwsh command works from Command Prompt
Microsoft Windows [Version 10.0.20348.1487]
(c) Microsoft Corporation. All rights reserved.
C:\Users\Administrator>pwsh
PowerShell 7.3.1
PS C:\Users\Administrator>
Install GitLab Runner
Obtain registration token
- GitLab project > Settings > CI/CD > Runners > Expand
- Shared runners > Enable shared runners for this project > disabled
- Specific runners > registration token
Install and register GitLab Runner
- Go to the GitLab official site
- Create C:\GitLab-Runner directory
- Download the installer at C:\GitLab-Runner directory
- Change the installer file name to gitlab-runner.exe
- Install GitLab-Runner
.\gitlab-runner.exe install
- Register GitLab-Runner
.\gitlab-runner.exe register
- Enter your settings
- GitLab URL: https://gitlab.com/
- Registration token: {The token you obtained from the previous step}
- Description: {Description you see at GitLab portal}
- Tags: ami-runner (Tag is used at .gitlab-ci.yml)
- Executor: shell
- Start GitLab-Runner
.\gitlab-runner.exe start
- Verify GitLab-Runner
.\gitlab-runner.exe verify
- GitLab project > Settings > CI/CD > Runners > Expand
- Check if there is the specific runner available
Check configuration file
- C:\GitLab-Runner\confg.toml
- shell = "pwh"
GitLab Runner default directory
$ ls
Directory: C:\GitLab-Runner\builds\Mjr8XAEh\0\{account}\{project}
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 1/26/2023 6:25 AM cfn
-a--- 1/26/2023 6:30 AM 212 .gitlab-ci.yml
-a--- 1/25/2023 1:47 PM 6283 README.md
$ pwd
Path : C:\GitLab-Runner\builds\Mjr8XAEh\0\{account}\{project}
No comments:
Post a Comment