Skip to content

Instantly share code, notes, and snippets.

@mcascone
Created January 11, 2023 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcascone/389e5b01455bac57e57aaa447af7942b to your computer and use it in GitHub Desktop.
Save mcascone/389e5b01455bac57e57aaa447af7942b to your computer and use it in GitHub Desktop.
GitLab cheat sheet
# Get list of projects
curl --request GET --header "PRIVATE-TOKEN: $YUM_GITLAB_TOKEN" "https://gitlab.yum.com/api/v4/projects?per_page=100&page=1" | jq '.[]'
# Get list of projects and select on with id 24
curl --request GET --header "PRIVATE-TOKEN: $YUM_GITLAB_TOKEN" "https://gitlab.yum.com/api/v4/projects?per_page=100&page=1" | jq '.[] | select(.id=="24")'
# Get list of projects with name search
curl --request GET --header "PRIVATE-TOKEN: $YUM_GITLAB_TOKEN" "https://gitlab.yum.com/api/v4/projects?per_page=100&page=1&search=olympus" | jq '.[]'
# Get list of files in root of repo
curl --request GET --header "PRIVATE-TOKEN: $YUM_GITLAB_TOKEN" "https://gitlab.yum.com/api/v4/projects/1676/repository/tree"
# Get list of repositories
curl --request GET --data 'name_regex=.*' --header "PRIVATE-TOKEN: $YUM_GITLAB_TOKEN" "https://gitlab.yum.com/api/v4/projects/27182/search"
curl --request GET --data 'name_regex=.*' --header "PRIVATE-TOKEN: $YUM_GITLAB_TOKEN" "https://gitlab.yum.com/api/v4/projects/528"
curl --request GET --header "PRIVATE-TOKEN: $YUM_GITLAB_TOKEN" "https://gitlab.yum.com/api/v4/projects/1676/registry/repositories"
# Get info on project id
curl --request GET --header "PRIVATE-TOKEN: $YUM_GITLAB_TOKEN" "https://gitlab.yum.com/api/v4/projects/528"
curl --request GET --header "PRIVATE-TOKEN: $YUM_GITLAB_TOKEN" "https://gitlab.yum.com/api/v4/projects/720"
# Get list of repositories
curl --request GET --data 'name_regex=.*' --header "PRIVATE-TOKEN: $YUM_GITLAB_TOKEN" "https://gitlab.yum.com/api/v4/projects/112/registry/repositories/"
# Get all docker tags in specific repository, pagination at the end
curl --request GET --data 'name_regex=.*' --header "PRIVATE-TOKEN: $YUM_GITLAB_TOKEN" "https://gitlab.yum.com/api/v4/projects/112/registry/repositories/91/tags?per_page=100&page=1" | jq .
# Gitlab advanced search, in this case for all files with `dockerfile` in the filename, search for FROM in those files.
curl --header "PRIVATE-TOKEN: $YUM_GITLAB_TOKEN" "https://gitlab.yum.com/api/v4/search?scope=blobs&search=FROM%20filename:*dockerfile*&per_page=100&page=1" | jq .
# Gitlab search jobs
curl --globoff --header "PRIVATE-TOKEN: $YUM_GITLAB_TOKEN" "https://gitlab.yum.com/api/v4/projects/72/jobs?scope[]=pending&scope[]=running"
# Delete a job?
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs/1/erase"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment