Skip to content

GitLab🔗

=this.img
= ("> " + this.desc-short)

Item References
External Links = ("[Website](" + this.url + ")"), = ("[Documentation](" + this.docs + ")")
GitLab docs GL Markdown
Topics Agile
Related =(join(this.related, ", "))

Issues, Boards, Project Management🔗

See also GitLab: Agile

Markdown/HTML🔗

HTML style guide

  • open link in new tab (target="_blank") is unsafe, use instead, see GitLab Documentation

    1
    <a href="url" target="_blank" rel="noopener noreferrer"></a>
    

Web Interface🔗

Snippets🔗

GitLab documentation: Snippets

Projects🔗

Authentication🔗

Access Tokens🔗

There is a variety of different access tokens available in GitLab: groups, impersonation, projects, … and each can be fine-grained, setting a role, permissions and an expiry date.

For example, to give read access to a project an access token with role Reporter (Guest can be insufficient) and permissions read_repository can be used. Navigate to the project and select Access Tokens from the settings menu.

Automation and CI/CD🔗

By default .gitlab-ci.yml

GitLab CI/CD Documentation

Example YAML config
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
default:
interruptible: true # new pipeline may cancel running one (default false)
  image: ubuntu:latest # Docker image
  # or
  image: # docker image
    name: python:3
    pull_policy: if-not-present # default is "always", has to be enabled in runner config
variables:
  GIT_SUBMODULE_FORCE_HTTPS: "true"  # force (SSH) URLs to HTTPS
  GIT_SUBMODULE_STRATEGY: recursive  # init/update/pull SMs recursively

References

  • To Be Continuous: GitLab CI templates
    > to be continuous proposes a set of GitLab CI templates developed and maintained by DevOps and technology experts to build state-of-the-art CI/CD pipelines in minutes.

Stages🔗

  • pages: special and activated for projects where GitLab Pages feature is enabled. After build stage artifacts (default public/) are deployed to configured destination

Script🔗

Custom commands to be executed in script section

  • before_script: run before every command in script section. Per stage or globally defined.

Artifacts🔗

Projects settings

  • maximum artifact size
  • expiration and keeping artifacts of last successful pipeline

If deleting artifacts through the webinterface doesn’t reduce the storage consumption, you can use an API call to delete project artifacts12

1
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/<project id>/artifacts"

Docker🔗

Configure runner in runner config.toml (see explanations below)

1
2
3
[runners.docker]
image = "<image name>"
pull_policy = "if-not-present" # prioritise local images

Register runner with a config template (directory with this file has to be mounted as Docker volume)

1
gitlab-runner register --template-config=<config.toml>

To test a pipeline job from a .gitlab-ci.yaml file

1
2
3
gitlab-runner exec docker <job name> \
    --docker-image=<image name>:<image tag>
    --docker-pull-policy=never \ # for local images

Webhooks🔗

There’s a number of events to chose from as webhooks, for example Wiki page events, that can be used e.g. to trigger a pipeline (in a different project). The GitLab webinterface discourages the use of Webhooks, suggesting Integrations instead.

  • Wiki page events: âš  only triggers when changes are done through the GitLab Wiki webinterface, not when pushing changes to the GitLab Wiki repository.

Auto DevOps🔗

https://docs.gitlab.com/ee/topics/autodevops/index.md

Server🔗

Console🔗

Fixing requirement of both MFA and password some users experience

1
2
3
4
## gitlab-rails console
user = User.find_by(email: 'a.b.lastname@student.rug.nl')
user.password_automatically_set = true
user.save

LDAP🔗

See also LWP: GitLab > LDAP

https://docs.gitlab.com/ee/administration/auth/ldap/index.html

Rake tasks🔗

https://docs.gitlab.com/ee/raketasks/

  • LDAP

    1
    2
    sudo gitlab-rake gitlab:ldap:check # test bind_dn and pw, print 100 users as sample
    sudo gitlab-rake gitlab:ldap:check[5] # print only 5 users
    

Enterprise Edition (EE)🔗

Convert Community Edition to Enterprise Edition
Trial License
Activate

Rails Console🔗

Documentation

  • look up user info

    ```ruby
    u = User.find_by_username(‘someuser’)
    pp u.attributes

    send test email to user🔗

    Notify.test_email(u.email, “Test email for #{u.name}”, ‘Test email’).deliver_now

```

  • 2FA, MFA
    1
    2
    User.find_each(&:disable_two_factor!) # disable for all users (reset if enforced by admin settings)
    User.where(username: "username_goes_here").each(&:disable_two_factor!) # disable for certain user
    
  • (Re-)Set password ^1b2997

    1
    2
    3
    4
    5
    6
    new_password = 'examplepassword'
    user.password = new_password
    user.password_confirmation = new_password
    user.send_only_admin_changed_your_password_notification!
    user.save!
    # root: usually UID 1, else search for root
    

Or use a Rails Runner to execute commands non-interactively

1
sudo gitlab-rails runner "RAILS_COMMAND"

Rake Tasks🔗

Reset user password ^8cee12

1
sudo gitlab-rake "gitlab:password:reset[sidneyjones]"

Elasticsearch (EE)🔗

https://docs.gitlab.com/ee/integration/advanced_search/elasticsearch.html

Service Desk🔗

https://docs.gitlab.com/ee/user/project/service_desk/index.html

Wiki🔗

GitLab Documentation: Wiki

GitLab Pages🔗

Examples and References

References🔗