Skip to content

Latest commit

 

History

History
114 lines (72 loc) · 2.92 KB

File metadata and controls

114 lines (72 loc) · 2.92 KB

GitLab

https://gitlab.com

GitLab is the number 2 hosting provider for Git repos after GitHub

It has good feature parity with GitHub.com, although less 3rd party CI/CD integrations as everybody integrates to GitHub first .

GitLab CLI

Install doc

On Mac using Homebrew:

brew install glab
glab --help

Various GitLab CLI scripts are in HariSekhon/DevOps-Bash-tools repo.

Script to download latest binary from GitLab to /usr/local/bin or $HOME/bin:

git clone https://github.com/HariSekhon/DevOps-Bash-tools bash-tools
cd bash-tools
install/install_gitlab_cli.sh

Readme Card

GitLab CLI and API auth

For the glab CLI above and the gitlab_api.sh script in the DevOps-Bash-tools repo, create a Personal Access Token here:

GitLab -> Preferences -> Access Tokens

The add this to your shell / Bash profile:

export GITLAB_TOKEN=...

Gitlab CLI config can be found here:

 ~/.config/glab-cli/config.yml

Git Clone over HTTPS using API Token

Cloning with HTTPS then becomes:

git clone "https://GITLAB_TOKEN@gitlab.com/$ORG/$REPO.git"

or better using a credential helper...

Credential Helper

Taken from my .gitconfig:

[credential "https://gitlab.com"]
    helper = "!f() { sleep 1; echo \"password=${GITLAB_TOKEN}\"; }; f"
git clone "https://gitlab.com/$ORG/$REPO.git"

If you get a 401 or 403 authentication or authorization error, you can check Git debug output by setting:

export GIT_CURL_VERBOSE=1

GitLab CI/CD

Create a .gitlab-ci.yml into the root directory of your git repo, then git push to GitLab.

Template to get you started:

.gitlab-ci.yml

GitLab Official CI/CD Library

GitLab CI Library

GitLab Profile Page

See adjacent GitHub Profile Page doc.

Partial port from private Knowledge Base page 2012+