- Global shortcuts
Shift, Display keyboard shortcuts ShiftP Go to project dashboard ShiftG Go to group dashboard ShiftL Go to milestone dashboard ShiftI Go to issue dashboard (it displays by default the issues assigned to the current user) ShiftT Go to todo dashboard Shift:
SSearch - Project shortcuts
GP Go to project overview GI Go to issues I Create a new issue GM Go to merge requests GN Go to repository graph GD Go to repository analytics GW Go to wiki
- use
````to be able to write suggestions containing markdown````suggestion:-0+2 ```shell git log ``` ```` - Create a sortable and filterable table
```json:table { "fields" : [ { "key": "client", "label": "Client", "sortable": "true" }, { "key": "techno", "label": "Technology", "sortable": "true" } ], "items" : [ { "client": "Acme", "techno": "Cucumber" }, { "client": "Fuzzy", "techno": "Agilitest" }, { "client": "Knock-Knock", "techno": "Agilitest" }, { "client": "Opale", "techno": "Robot Framework" }, { "client": "Snurf", "techno": "Postman" }, { "client": "YAC", "techno": "Katalon" } ], "filter": "true" } ```
- Clone the repo of the wiki
git clone https://gitlab.com/mygroup/myproject.wiki.git - Insert a table of content
[[_TOC_]] - Admonitions
> [!note]
> The following information is useful.> [!tip]
> Tip of the day.> [!important]
> This is something important you should know.> [!caution]
> You need to be very careful about the following.
The title may be overridden:> [!warning]
> The following would be dangerous.
Multiline blockquotes can also be used:> [!warning] Data deletion
> he following instructions will make your data unrecoverable.>>> [!note] Things to consider
You should consider the following ramifications:
1. consideration 1
1. consideration 2
>>>
- get all notes of an issue
get all notes of an issue except fot GitLab activity notescurl --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "https://gitlab.com/api/v4/projects/34858181/issues/6354/notes" | jq
get all notes of an issue organised as a hierarchycurl --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "https://gitlab.com/api/v4/projects/34858181/issues/6354/notes?activity_filter=only_comments" | jqcurl --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "https://gitlab.com/api/v4/projects/34858181/issues/6354/discussions" | jq - retrieve the issue related to a merge request
curl --header "PRIVATE-TOKEN:$GITLAB_TOKEN" "https://gitlab.com/api/v4/projects/27169359/merge_requests/355" | jq -r '.description' head -1 | sed 's/.*#//' - delete the local branches that to do not exist anymore in GitLab
git checkout main git fetch -p git branch -vv | grep ': gone]' | awk '{print $1}' | xargs -n 1 -pr git branch -D - run the GitLab runner in Docker
wheredocker run --rm -t -i -v C:\gitlab-runner\config:/etc/gitlab-runner gitlab/gitlab-runner register --non-interactive --executor "docker" --docker-image alpine:latest --url "https://gitlab.com/" --registration-token "XXXXXXXXXXXXXXXXXXXX" --description "myrunner" --run-untagged="true" –locked="false"
docker run -d --name gitlab-runner --restart always -v C:\gitlab-runner\config:/etc/gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latestXXXXXXXXXXXXXXXXXXXXis the registration token for specific runners
C:\gitlab-runner\configwill be created - get the audit of group https://gitlab.com/henixdevelopment
get the audit of project https://gitlab.com/henixdevelopment/open-source/opentestfactory/orchestratorcurl --header "PRIVATE-TOKEN: <token>" https://gitlab.com/api/v4/groups/13404279/audit_events?per_page=500&page=1curl --header "PRIVATE-TOKEN: <token>" https://gitlab.com/api/v4/projects/27352872/audit_events?per_page=500&page=1 - in order to see what someone has crontibuted, rather use
Merged byrather thanAuthor
https://gitlab.com/groups/henixdevelopment/open-source/-/merge_requests/?sort=updated_desc&state=merged&merge_user=lmazure&first_page_size=20 -
Store a package in the registry with Maven
- configure the repository in
pom.xml<repositories> <repository> <id>gitlab-maven</id> <url>https://gitlab.com/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url> </repository> </repositories> <distributionManagement> <repository> <id>gitlab-maven</id> <url>https://gitlab.com/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url> </repository> <snapshotRepository> <id>gitlab-maven</id> <url>https://gitlab.com/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url> </snapshotRepository> </distributionManagement> - declare the repository in
setting.xml<settings> <servers> <server> <id>gitlab-maven</id> <configuration> <httpHeaders> <property> <name>Job-Token</name> <value>${CI_JOB_TOKEN}</value> </property> </httpHeaders> </configuration> </server> </servers> </settings> - configure the deployment in
.gitlab-ci.ymlvariables: MAVEN_CLI_OPTS: "--batch-mode --settings settings.xml" MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository" cache: paths: - .m2/repository/ … package: stage: package script: - mvn $MAVEN_CLI_OPTS -Dmaven.test.skip compile assembly:single deploy
- configure the repository in
- GraphQL request to get AI consumption
query getUserSubscriptionUsage { subscriptionUsage(namespacePath: "henixdevelopment") { enabled lastEventTransactionAt subscriptionPortalUsageDashboardUrl purchaseCreditsPath startDate endDate paidTierTrial { isActive } usersUsage { users(sort: TOTAL_CREDITS_USED_DESC) { nodes { id name username avatarUrl usage { totalCredits creditsUsed monthlyCommitmentCreditsUsed monthlyWaiverCreditsUsed overageCreditsUsed paidTierTrialCreditsUsed } } } } } } - Python scripts
- base methods
import requests import urllib.parse def makeHeader(token): return {"Authorization": "Bearer " + args.token} def run_post_query(token, query): request = requests.post(query, headers=makeHeader(token)) if request.status_code == 201: return raise Exception("POST query \"{}\" failed to run by returning code of {}: {}".format(query, request.status_code, request.content)) def run_get_query(token, query): request = requests.get(query, headers=makeHeader(token)) if request.status_code == 200: return request.json() raise Exception("GET query \"{}\" failed to run by returning code of {}: {}".format(query, request.status_code, request.content)) def run_put_query(token, query, data = None): if data: request = requests.put(query, headers=makeHeader(token), data=data) else: request = requests.put(query, headers=makeHeader(token)) if request.status_code == 200: return raise Exception("PUT query \"{}\" failed to run by returning code of {}: {}".format(query, request.status_code, request.content)) def run_delete_query(token, query): request = requests.delete(query, headers=makeHeader(token)) if request.status_code in (200, 204): return raise Exception("DELETE query \"{}\" failed to run by returning code of {}: {}".format(query, request.status_code, request.content)) def run_graphql_query(token, query): request = requests.post("https://gitlab.com/api/graphql", json={'query': query}, headers = makeHeader(token)) if request.status_code == 200: return request.json() raise Exception("GraphQL query \"{}\" failed to run by returning code of {}: {}".format(query, request.status_code, request.content)) - create a group label
def create_group_label(token, groupPath, labelName, labelDescription, labelColor, labelPriority): params = { "name": labelName, "description": labelDescription, "color": labelColor, "priority": labelPriority } query = f"https://gitlab.com/api/v4/groups/{urllib.parse.quote(groupPath, safe='')}/labels?{urllib.parse.urlencode(params)}" run_post_query(token, query) print(f"label '{labelName}' added on group {groupPath}", flush=True) - get the issues of a group having a label but not another one
def get_group_issues_with_label(token, groupPath, havingOneOfTheLabelName, notHavingTheLabelName): issues = [] page = 1 while True: params = { "labels": havingOneOfTheLabelName, "not[labels]": notHavingTheLabelName, "scope": "all", "page": page } query = f"https://gitlab.com/api/v4/groups/{urllib.parse.quote(groupPath, safe='')}/issues?{urllib.parse.urlencode(params)}" result = run_get_query(token, query) if len(result) == 0: return issues for issue in result: issues.append({ "projectId": issue["project_id"], "issueIid": issue["iid"], "issueId": issue["id"]}) page += 1 - get the epics having a given label and a label in a given scope
cursor is properly managedepic_list_query = """ { group (fullPath: "henixdevelopment/squash") { epics (state: opened, labelName: ["Roadmap","Release::*"], after: "%s") { edges { cursor node { id iid title group { fullPath } startDateIsFixed startDateFixed dueDateIsFixed dueDateFixed labels { edges { node { title } } } } } } } } """ def handle_epic(): … def handle_epics(): cursor = "" while True: result = run_graphql_query(epic_list_query % cursor) if len(result["data"]["group"]["epics"]["edges"]) == 0: break for epic_node in result["data"]["group"]["epics"]["edges"]: handle_epic(epic_node["node"]) - set an epic to fixed dates
set_epic_date_request = """ mutation { updateEpic (input: { groupPath: "%s", iid: "%s", startDateIsFixed: true, startDateFixed: "%s", dueDateIsFixed: true, dueDateFixed: "%s" }) { clientMutationId } } """ def set_epic_dates(group_path, iid, start_date, due_date): run_graphql_query(set_epic_date_request % (group_path, iid, start_date, due_date)) - add a label to an issue
def add_label_to_issue(token, projectId, issueIid, labelName): params = { "add_labels": labelName } query = f"https://gitlab.com/api/v4/projects/{projectId}/issues/{issueIid}?{urllib.parse.urlencode(params)}" run_put_query(token, query) print(f"label '{labelName}' added to issue {issueIid} of project {projectId}", flush=True) - set (or change) the milestone of an issue
def get_milestone_id(project, milestoneName, token): query = f"https://gitlab.com/api/v4/projects/{urllib.parse.quote(project, safe='')}/milestones?include_parent_milestones=true&title={urllib.parse.quote(milestoneName, safe='')}" result = run_get_query(token, query) return result[0]["id"] def set_issue_milestone(project, issueIid, milestoneId, token): query = f"https://gitlab.com/api/v4/projects/{urllib.parse.quote(project, safe='')}/issues/{issueIid}?milestone_id={milestoneId}" run_put_query(token, query) … newMilestoneId = get_milestone_id(project, newMilestone, token) set_issue_milestone(project, issueIid, newMilestoneId, token)
- base methods