### glab skills install usage examples Source: https://docs.gitlab.cn/docs/cli/skills/install Examples demonstrating how to install core skills, specific skills by name, global installation, custom paths, and forcing an overwrite. ```console 1# 在当前项目中安装核心 glab 技能(默认) 2glab skills install 3 4# 通过名称安装特定的捆绑技能 5glab skills install glab-stack 6 7# 全局安装核心技能(用户范围) 8glab skills install --global 9 10# 将技能安装到自定义目录 11glab skills install glab-stack --path /path/to/skills 12 13# 覆盖现有技能文件 14glab skills install --force 15 ``` -------------------------------- ### Install a specific plugin with duo Source: https://docs.gitlab.cn/docs/jh/user/gitlab_duo_cli/customize Example of installing a plugin using the duo CLI. ```shell duo plugin install my-plugin@my-marketplace ``` ```shell duo plugin install my-plugin@my-marketplace --scope project ``` -------------------------------- ### Defining project setup in setup.py Source: https://docs.gitlab.cn/docs/jh/user/gitlab_duo/tutorials/fix_code_python_shop Example setup.py configuration for a bookstore inventory application. ```python 1setup( 2 name="bookstore-inventory", 3 version="0.1.0", 4 packages=find_packages(), 5 include_package_data=True, 6 install_requires=[ 7 "Flask>=2.2.0", 8 "Flask-SQLAlchemy>=3.0.0", 9 "SQLAlchemy>=2.0.0", 10 "pytest>=7.0.0", 11 "pytest-flask>=1.2.0", 12 "python-dotenv>=1.0.0", 13 ], 14 python_requires=">=3.8", 15 author="Your Name", 16 author_email="your.email@example.com", 17 description="A Flask web application for managing bookstore inventory", 18 keywords="flask, inventory, bookstore", 19 url="https://gitlab.com/your-username/python-shop-app", 20 classifiers=[ 21 "Development Status :: 3 - Alpha", 22 "Environment :: Web Environment", 23 "Framework :: Flask", 24 "Intended Audience :: Developers", 25 "License :: OSI Approved :: MIT License", 26 "Programming Language :: Python :: 3", 27 "Programming Language :: Python :: 3.8", 28 "Programming Language :: Python :: 3.9", 29 "Programming Language :: Python :: 3.10", 30 ], 31) ``` -------------------------------- ### Get commit sequence - curl example Source: https://docs.gitlab.cn/docs/jh/api/commits Example curl request to get the commit sequence number. ```shell curl --header "PRIVATE-TOKEN: " \ --url "https://gitlab.example.com/api/v4/projects/5/repository/commits/5937ac0a7beb003549fc5fd26fc247adbce4a52e/sequence" ``` -------------------------------- ### Run the setup script Source: https://docs.gitlab.cn/docs/runner/configuration/slot_based_cgroups Make the setup script executable and run it with sudo privileges. ```shell chmod +x gitlab-runner-systemd-slice-setup.sh sudo ./gitlab-runner-systemd-slice-setup.sh ``` -------------------------------- ### Get single SCIM identity - example response Source: https://docs.gitlab.cn/docs/jh/api/scim Example JSON response for the get single identity endpoint. ```json { "extern_uid": "be20d8dcc028677c931e04f387", "user_id": 48, "active": true } ``` -------------------------------- ### Example: glab repo list Source: https://docs.gitlab.cn/docs/cli/repo/list Example command to list repositories using the default options. ```console glab repo list ``` -------------------------------- ### Install and start Courier IMAP and authdaemon Source: https://docs.gitlab.cn/docs/jh/administration/reply_by_email_postfix_setup Install courier-imap, start imapd, and manually start courier-authdaemon because it does not auto-start after installation. Optionally enable courier-authdaemon to run at boot. Ubuntu 24.04 lacks the courier-imap package (see Ubuntu bug 2071662). ```shell sudo apt-get install courier-imap ``` ```shell imapd start ``` ```shell sudo service courier-authdaemon start ``` ```shell sudo systemctl enable courier-authdaemon ``` -------------------------------- ### Enable deploy key: response example Source: https://docs.gitlab.cn/docs/jh/api/deploy_keys Example JSON response for a successful enable, showing the enabled key details including key, id, title, created_at, and expires_at. ```json { "key": "ssh-rsa AAAA...", "id": 12, "title": "My deploy key", "created_at": "2015-08-29T12:44:31.550Z", "expires_at": null } ``` -------------------------------- ### Get raw blob content example request Source: https://docs.gitlab.cn/docs/jh/api/repositories Example curl request to get raw blob content. Uses a PRIVATE-TOKEN header for authentication. ```shell curl --header "PRIVATE-TOKEN: " \ --url "https://gitlab.example.com/api/v4/projects/13083/repository/blobs/79f7bbd25901e8334750839545a9bd021f0e4c83/raw" ``` -------------------------------- ### Setup development environment Source: https://docs.gitlab.cn/docs/runner/development/_index Run this command to prepare the local environment for running the test suite. ```shell make development_setup ``` -------------------------------- ### Get upstream repository - response example Source: https://docs.gitlab.cn/docs/jh/api/maven_virtual_registries Example JSON response for a successful get upstream request. Shows the structure of the upstream repository object. ```json { "id": 1, "group_id": 5, "url": "https://repo.maven.apache.org/maven2", "name": "Maven Central", "description": "Maven Central repository", "cache_validity_hours": 24, "metadata_cache_validity_hours": 24, "username": "user", "created_at": "2024-05-30T12:28:27.855Z", "updated_at": "2024-05-30T12:28:27.855Z", "registry_upstreams": [ { "id": 1, "registry_id": 1, "position": 1 } ] } ``` -------------------------------- ### Command examples Source: https://docs.gitlab.cn/docs/cli/ci/run-trig Examples showing how to trigger pipelines with tokens, branches, variables, and typed inputs. ```console 1glab ci run-trig -t xxxx 2glab ci run-trig -t xxxx -b main 3 4# 指定 CI 变量 5glab ci run-trig -t xxxx -b main --variables key1:val1 6glab ci run-trig -t xxxx -b main --variables key1:val1,key2:val2 7glab ci run-trig -t xxxx -b main --variables key1:val1 --variables key2:val2 8 9# 指定 CI 输入 10glab ci run-trig -t xxxx -b main --input key1:val1 --input key2:val2 11glab ci run-trig -t xxxx -b main --input "replicas:int(3)" --input "debug:bool(false)" --input "regions:array(us-east,eu-west)" ``` -------------------------------- ### Get epic discussion example: curl GET request Source: https://docs.gitlab.cn/docs/jh/api/discussions Example curl request to fetch a specific epic discussion. Uses PRIVATE-TOKEN header. ```shell curl --header "PRIVATE-TOKEN: " \ --url "https://gitlab.example.com/api/v4/groups/5/epics/11/discussions/" ``` -------------------------------- ### Get single SCIM identity - example request Source: https://docs.gitlab.cn/docs/jh/api/scim Example curl request to get a single SCIM identity. Replace with your access token. ```shell curl --location --request GET \ --url "https://gitlab.example.com/api/v4/groups/33/scim/be20d8dcc028677c931e04f387" \ --header "PRIVATE-TOKEN: " ``` -------------------------------- ### Libvirt prepare.sh script Source: https://docs.gitlab.cn/docs/runner/executors/custom_examples/libvirt Script to initialize the VM by copying the disk, installing the VM via virt-install, and waiting for network and SSH availability. ```shell #!/usr/bin/env bash # /opt/libvirt-driver/prepare.sh currentDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" source ${currentDir}/base.sh # Get variables from base script. set -eo pipefail # trap any error, and mark it as a system failure. trap "exit $SYSTEM_FAILURE_EXIT_CODE" ERR # Copy base disk to use for Job. qemu-img create -f qcow2 -b "$BASE_VM_IMAGE" "$VM_IMAGE" -F qcow2 # Install the VM virt-install \ --name "$VM_ID" \ --os-variant debian11 \ --disk "$VM_IMAGE" \ --import \ --vcpus=2 \ --ram=2048 \ --network default \ --graphics none \ --noautoconsole # Wait for VM to get IP echo 'Waiting for VM to get IP' for i in $(seq 1 30); do VM_IP=$(_get_vm_ip) if [ -n "$VM_IP" ]; then echo "VM got IP: $VM_IP" break fi if [ "$i" == "30" ]; then echo 'Waited 30 seconds for VM to start, exiting...' # Inform GitLab Runner that this is a system failure, so it # should be retried. exit "$SYSTEM_FAILURE_EXIT_CODE" fi sleep 1s done # Wait for ssh to become available echo "Waiting for sshd to be available" for i in $(seq 1 30); do if ssh -i /root/.ssh/id_rsa -o StrictHostKeyChecking=no gitlab-runner@$VM_IP >/dev/null 2>/dev/null; then break fi if [ "$i" == "30" ]; then echo 'Waited 30 seconds for sshd to start, exiting...' # Inform GitLab Runner that this is a system failure, so it # should be retried. exit "$SYSTEM_FAILURE_EXIT_CODE" fi sleep 1s done ``` -------------------------------- ### Examples: list agents and output as JSON Source: https://docs.gitlab.cn/docs/cli/cluster/agent/list Two examples showing how to list agents in the current project and how to list them with JSON output using the --output json flag. ```console # 列出当前项目中的 Agent glab cluster agent list # 以 JSON 格式列出 Agent glab cluster agent list --output json ``` -------------------------------- ### Get latest package revision - example response Source: https://docs.gitlab.cn/docs/jh/api/packages/conan_v2 Example JSON response for the get latest package revision endpoint. Contains the latest revision hash and its timestamp. ```json { "revision" : "3bdd2d8c8e76c876ebd1ac0469a4e72c", "time" : "2024-12-17T09:16:40.334+0000" } ``` -------------------------------- ### 设置域名(--set global.hosts.domain) Source: https://docs.gitlab.cn/docs/charts/installation/tools 使用 helm install 时,通过 --set global.hosts.domain=example.com 指定域名,用于将 gitlab、registry 和 minio 解析到 chart 的适当 IP 地址。 ```shell --set global.hosts.domain=example.com ``` -------------------------------- ### Examples for glab securefile get Source: https://docs.gitlab.cn/docs/cli/securefile/get Shows two example invocations: one using the get command and one using the show alias, both with file ID 1. ```console # 通过文件 ID 获取项目安全文件的详细信息。 glab securefile get 1 # 通过 'show' 别名获取项目安全文件的详细信息。 glab securefile show 1 ``` -------------------------------- ### Chocolatey install example with source name or URL Source: https://docs.gitlab.cn/docs/jh/user/packages/nuget_repository/_index Example of installing a package with Chocolatey CLI using either a source name or a full NuGet v2 source URL. The URL example includes authentication with a personal access token. ```shell choco install MyPackage -Source gitlab -Version 1.0.2 # 或 choco install MyPackage -Source "https://gitlab.example.com/api/v4/projects//packages/nuget/v2" -u -p -Version 1.0.2 ``` -------------------------------- ### Example usage of glab stack Source: https://docs.gitlab.cn/docs/cli/stack/_index Shows how to create a new stack and sync it. ```console glab stack create cool-new-feature glab stack sync ``` -------------------------------- ### glab repo members add examples Source: https://docs.gitlab.cn/docs/cli/repo/members/add Examples showing how to add users using usernames, user IDs, custom roles, and expiration dates. ```console 1# 将用户添加为开发者 2glab repo members add --username=john.doe --role=developer 3# 将用户添加为维护者并指定到期日期 4glab repo members add --username=jane.smith --role=maintainer --expires-at=2024-12-31 5# 通过 ID 添加用户 6glab repo members add --user-id=123 --role=reporter 7# 使用自定义角色添加用户 8glab repo members add --username=john.doe --role-id=101 ``` -------------------------------- ### get_project example prompt Source: https://docs.gitlab.cn/docs/jh/user/model_context_protocol/mcp_server_tools Example prompt to get the default branch of a project. ```text What is the default branch of gitlab-org/gitlab? ``` -------------------------------- ### Get file archive example request Source: https://docs.gitlab.cn/docs/jh/api/repositories Example curl request to get a file archive. Uses a PRIVATE-TOKEN header and includes query parameters for sha, path, and exclude_paths. ```shell curl --header "PRIVATE-TOKEN: " \ --url "https://gitlab.com/api/v4/projects//repository/archive?sha=&path=&exclude_paths=" ``` -------------------------------- ### glab config set usage examples Source: https://docs.gitlab.cn/docs/cli/config/set Examples showing how to set an editor, a token for a specific host, and a global configuration flag. ```console glab config set editor vim glab config set token xxxxx --host gitlab.com glab config set check_update false --global ``` -------------------------------- ### curl example for GET test upstream connection Source: https://docs.gitlab.cn/docs/jh/api/maven_virtual_registries Example curl command to test the upstream connection using the GET endpoint. Requires a private token and the upstream ID. ```shell curl --header "PRIVATE-TOKEN: " \ --header "Accept: application/json" \ --url "https://gitlab.example.com/api/v4/virtual_registries/packages/maven/upstreams/1/test" ``` -------------------------------- ### Create a deploy key - response example Source: https://docs.gitlab.cn/docs/jh/api/deploy_keys Example JSON response after successfully creating a deploy key. Includes the key's id, title, key, fingerprints, usage_type, created_at, and expires_at. ```json { "id": 5, "title": "My deploy key", "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDNJAkI3Wdf0r13c8a5pEExB2YowPWCSVzfZV22pNBc1CuEbyYLHpUyaD0GwpGvFdx2aP7lMEk35k6Rz3ccBF6jRaVJyhsn5VNnW92PMpBJ/P1UebhXwsFHdQf5rTt082cSxWuk61kGWRQtk4ozt/J2DF/dIUVaLvc+z4HomT41fQ==", "fingerprint": "4a:9d:64:15:ed:3a:e6:07:6e:89:36:b3:3b:03:05:d9", "fingerprint_sha256": "SHA256:Jrs3LD1Ji30xNLtTVf9NDCj7kkBgPBb2pjvTZ3HfIgU", "usage_type": "auth_and_signing", "created_at": "2024-10-03T01:32:21.992Z", "expires_at": "2024-12-31T08:00:00.000Z" } ```