### glab govern setup examples Source: https://docs.gitlab.com/cli/govern/setup/ Examples of using glab govern setup to sync sessions from various agents, install only hooks, or uninstall. The first command syncs Claude Code or previously set up agents; the second syncs OpenCode; the third syncs multiple agents; the fourth installs only hooks and plugin; the fifth removes everything. ```console # Sync Claude Code sessions, or the agents set up earlier $ glab govern setup # Sync OpenCode sessions $ glab govern setup --agents opencode # Sync Claude Code, OpenCode, and Codex sessions $ glab govern setup --agents claude-code,opencode,codex # Install only the hooks and plugin, without the fallback periodic sync $ glab govern setup --no-fallback-sync # Remove everything setup installed $ glab govern setup --uninstall ``` -------------------------------- ### Example .gitlab-ci.yml for Hosted Runners on Windows Source: https://docs.gitlab.com/ci/runners/hosted_runners/windows/ Use this example .gitlab-ci.yml to get started with hosted runners on Windows. The script section requires PowerShell commands because PowerShell is the configured shell. ```yaml .windows_job: tags: - saas-windows-medium-amd64 before_script: - Set-Variable -Name "time" -Value (date -Format "%H:%m") - echo ${time} - echo "started by ${GITLAB_USER_NAME} / @${GITLAB_USER_LOGIN}" build: extends: - .windows_job stage: build script: - echo "running scripts in the build job" test: extends: - .windows_job stage: test script: - echo "running scripts in the test job" ``` -------------------------------- ### Start GitLab and verify repositories Source: https://docs.gitlab.com/omnibus/settings/configuration/ Start GitLab with sudo gitlab-ctl start and verify that you can browse through the repositories in the web interface. ```shell sudo gitlab-ctl start ``` -------------------------------- ### Install GitLab Pages Source: https://docs.gitlab.com/install/self_compiled/ Installs GitLab Pages in /home/git/gitlab-pages. This step is optional and only needed if you wish to host static sites from within GitLab. Uses GNU Make. For additional setup steps, consult the administration guide for your version of GitLab. ```shell cd /home/git sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-pages.git cd gitlab-pages sudo -u git -H git checkout v$(/packages/nuget/v2" -u -p -Version 1.0.2 ``` -------------------------------- ### Start imapd Source: https://docs.gitlab.com/administration/reply_by_email_postfix_setup/ Starts the Courier IMAP daemon after installing courier-imap. ```shell imapd start ``` -------------------------------- ### Start courier-authdaemon Source: https://docs.gitlab.com/administration/reply_by_email_postfix_setup/ Starts the courier-authdaemon service, which is not started automatically after installation. Without it, IMAP authentication fails. ```shell sudo service courier-authdaemon start ``` -------------------------------- ### Create helloworld.go in project A Source: https://docs.gitlab.com/tutorials/scan_execution_policy/ Add this Go file to project A as part of the tutorial setup. It prints "Hello world" when run. ```go package main import "fmt" func main() { fmt.Println("Hello world") } ``` -------------------------------- ### Install orbit through GitLab CLI (glab) Source: https://docs.gitlab.com/19.5/orbit/local/getting-started/ Installs orbit using the GitLab CLI if glab is already installed. ```shell glab orbit --install ``` -------------------------------- ### Start the GDK Source: https://docs.gitlab.com/development/contributing/first_contribution/configure-dev-env-gdk/ Start the GDK. Wait for the message `GitLab available at http://127.0.0.1:3000`, then connect to that URL. ```shell gdk start ``` -------------------------------- ### Point setup.py at downloaded certificate Source: https://docs.gitlab.com/user/application_security/dependency_scanning/legacy_dependency_scanning/ Point setup.py at the newly downloaded certificate. Use this when using self-signed certificates for your private PyPi repository. ```python import setuptools.ssl_support setuptools.ssl_support.cert_paths = ['internal.crt'] ``` -------------------------------- ### Change directory to the project repository Source: https://docs.gitlab.com/17.11/tutorials/setup_steps/ Navigates to the root of the newly created zero-to-steps project repository. ```shell cd zero-to-steps ``` -------------------------------- ### Check Flux CLI installation with flux -v Source: https://docs.gitlab.com/user/clusters/agent/getting_started/ Run this to confirm that the Flux CLI is properly installed after completing the installation steps. ```shell flux -v ``` -------------------------------- ### Verify orbit installation through GitLab CLI (glab) Source: https://docs.gitlab.com/19.5/orbit/local/getting-started/ Run to confirm orbit is installed and accessible through the GitLab CLI. ```shell glab orbit help ``` -------------------------------- ### Run make development_setup to install test dependencies Source: https://docs.gitlab.com/runner/development/ Run after installing required binaries (VirtualBox, Vagrant, kubectl, minikube, Parallels, PowerShell) to set up the development environment. Some tests are skipped if their required binary is missing. ```shell make development_setup ``` -------------------------------- ### Run dev_dependencies.sh setup Source: https://docs.gitlab.com/operator/developer/installation/ From the root of the operator repository, run the setup script to deploy external services and generate configuration files. ```shell bash scripts/dev_dependencies.sh setup ``` -------------------------------- ### setup.py for Bookstore Inventory Management System Source: https://docs.gitlab.com/user/gitlab_duo/tutorials/fix_code_python_shop/ Project configuration for packaging the Flask and SQLite bookstore inventory application. ```python from setuptools import setup, find_packages setup( name="bookstore-inventory", version="0.1.0", packages=find_packages(), include_package_data=True, install_requires=[ "Flask>=2.2.0", "Flask-SQLAlchemy>=3.0.0", "SQLAlchemy>=2.0.0", "pytest>=7.0.0", "pytest-flask>=1.2.0", "python-dotenv>=1.0.0", ], python_requires=">=3.8", author="Your Name", author_email="your.email@example.com", description="A Flask web application for managing bookstore inventory", keywords="flask, inventory, bookstore", url="https://gitlab.com/your-username/python-shop-app", classifiers=[ "Development Status :: 3 - Alpha", "Environment :: Web Environment", "Framework :: Flask", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", ], ) ``` -------------------------------- ### Create a subscription example request Source: https://docs.gitlab.com/development/internal_api/gitlab_subscriptions/ Example request for creating a subscription. ```shell curl --request POST --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: " "https://gitlab.com/api/v4/internal/gitlab_subscriptions/namespaces/1234/gitlab_subscription?start_date="2020-07-15"&plan="premium"&seats=10" ``` -------------------------------- ### Verify orbit installation on macOS and Linux Source: https://docs.gitlab.com/19.5/orbit/local/getting-started/ Run after opening a new terminal to confirm the orbit binary is installed and accessible. ```shell orbit help ``` -------------------------------- ### Example devfile with postStart events Source: https://docs.gitlab.com/user/workspace/ A complete devfile configuration showing postStart events that reference exec commands across two containers. The container image is for demonstration purposes only. ```yaml schemaVersion: 2.2.0 variables: registry-root: registry.gitlab.com components: - name: tooling-container attributes: gl/inject-editor: true container: image: "{{registry-root}}/gitlab-org/remote-development/gitlab-remote-development-docs/ubuntu:22.04" env: - name: KEY value: VALUE endpoints: - name: http-3000 targetPort: 3000 - name: database-container attributes: overrideCommand: false container: image: mysql command: ["echo"] args: ["-n", "user-defined entrypoint command"] env: - name: MYSQL_ROOT_PASSWORD value: "my-secret-pw" commands: # Command 1: Container 1, no working directory (uses project directory) - id: install-dependencies exec: component: tooling-container commandLine: "npm install" # Command 2: Container 1, with working directory - id: setup-environment exec: component: tooling-container commandLine: "echo 'Setting up development environment'" workingDir: "/home/gitlab-workspaces" # Command 3: Container 2, no working directory (uses container default) - id: init-database exec: component: database-container commandLine: "echo 'Database initialized' > db-init.log" # Command 4: Container 2, with working directory - id: setup-database exec: component: database-container commandLine: "mkdir -p /var/lib/mysql/logs && echo 'DB setup complete' > setup.log" workingDir: "/var/lib/mysql" events: postStart: - install-dependencies - setup-environment - init-database - setup-database ``` -------------------------------- ### Remove Existing Garage Helm Repository and Re-run Setup Source: https://docs.gitlab.com/operator/developer/installation/ If a garage Helm repository with a different version already exists, the setup fails. Remove it first, then re-run setup. ```shell helm repo remove garage bash scripts/dev_dependencies.sh setup ``` -------------------------------- ### Example test environment setup log output Source: https://docs.gitlab.com/development/testing_guide/best_practices/ Shows the log messages produced when services for the test environment are automatically configured and started, including Gitaly, Workhorse, and Elasticsearch. This output appears in CI or when a service needs to be installed, and is omitted when running locally with no action needed. ```plaintext ==> Setting up Gitaly... Gitaly set up in 31.459649 seconds... ==> Setting up GitLab Workhorse... GitLab Workhorse set up in 29.695619 seconds... fatal: update refs/heads/diff-files-symlink-to-image: invalid : 8cfca84 From https://gitlab.com/gitlab-org/gitlab-test * [new branch] diff-files-image-to-symlink -> origin/diff-files-image-to-symlink * [new branch] diff-files-symlink-to-image -> origin/diff-files-symlink-to-image * [new branch] diff-files-symlink-to-text -> origin/diff-files-symlink-to-text * [new branch] diff-files-text-to-symlink -> origin/diff-files-text-to-symlink b80faa8..40232f7 snippet/multiple-files -> origin/snippet/multiple-files * [new branch] testing/branch-with-#-hash -> origin/testing/branch-with-#-hash ==> Setting up GitLab Elasticsearch Indexer... GitLab Elasticsearch Indexer set up in 26.514623 seconds... ``` -------------------------------- ### Successful Output for Multiple Steps Source: https://docs.gitlab.com/17.11/tutorials/setup_steps/ Example output of a successful pipeline run after adding the hello_steps step. ```shell Step Runner version: a7c7c8fd See https://gitlab.com/gitlab-org/step-runner/-/blob/main/CHANGELOG.md for changes. ... hello world hello gitlab steps Cleaning up project directory and file based variables Job succeeded ``` -------------------------------- ### Install the kubectl plugin with task install-kubectl-plugin Source: https://docs.gitlab.com/operator/developer/bridge/ Builds the SPA and runs go install, compiling the SPA into the binary with go:embed. The binary is placed in $GOBIN or $(go env GOPATH)/bin. ```shell task install-kubectl-plugin ``` -------------------------------- ### Successful Job Output Example Source: https://docs.gitlab.com/17.11/tutorials/setup_steps/ Example output of a successful job after following the pipeline logs. ```shell Step Runner version: a7c7c8fd See https://gitlab.com/gitlab-org/step-runner/-/blob/main/CHANGELOG.md for changes. ... hello world Cleaning up project directory and file based variables Job succeeded ``` -------------------------------- ### Install and start GitLab Runner as a service using Built-in System Account Source: https://docs.gitlab.com/runner/install/windows/ Run these commands in an elevated PowerShell prompt from the GitLab Runner directory (for example, C:\GitLab-Runner). This installs the runner as a Windows service under the Built-in System Account and starts it. Windows services do not provide interactive desktop sessions. ```powershell cd C:\GitLab-Runner .\gitlab-runner.exe install .\gitlab-runner.exe start ``` -------------------------------- ### Example database migrations AGENTS.md Source: https://docs.gitlab.com/user/duo_agent_platform/customize/agents_md/ Example instructions for a project-level AGENTS.md file to document database migration commands and failure handling. ```markdown # Database migrations - To run database migrations, use `bin/rails db:migrate` from the project root - Do not run `rake db:migrate` directly - If a migration fails with a lock timeout, wait and retry once. Do not attempt a schema workaround ``` -------------------------------- ### Deploy NGINX as an example with Kubernetes Deployment and Service YAML Source: https://docs.gitlab.com/user/clusters/agent/getting_started_deployments/ Add this YAML to clusters/applications/nginx/nginx.yaml to deploy NGINX as an example. It defines a Deployment and a Service in the default namespace. ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-example namespace: default spec: replicas: 1 selector: matchLabels: app: nginx-example template: metadata: labels: app: nginx-example spec: containers: - name: nginx image: nginx:1.25 ports: - containerPort: 80 protocol: TCP --- apiVersion: v1 kind: Service metadata: name: nginx-example namespace: default spec: ports: - port: 80 targetPort: 80 protocol: TCP selector: app: nginx-example ``` -------------------------------- ### Start GDK services and migrate database Source: https://docs.gitlab.com/development/data_seeder/ Starts the GDK database, installs bundle dependencies, and runs database migrations. Use this to prepare a GDK environment for the Data Seeder. ```shell $ gdk start db ok: run: services/postgresql: (pid n) 0s, normally down ok: run: services/redis: (pid n) 74s, normally down $ bundle install Bundle complete! $ bundle exec rake db:migrate main: migrated ci: migrated ``` -------------------------------- ### Run dev_dependencies.sh setup with Custom Namespace Source: https://docs.gitlab.com/operator/developer/installation/ Use a different namespace by setting the NAMESPACE environment variable. ```shell NAMESPACE=my-namespace bash scripts/dev_dependencies.sh setup ``` -------------------------------- ### Create a project service account example request Source: https://docs.gitlab.com/api/service_accounts/ Example request to create a service account in a project. ```shell curl --request POST \ --header "PRIVATE-TOKEN: " \ --url "https://gitlab.example.com/api/v4/projects/345/service_accounts" \ --data "email=custom_email@example.com" ``` -------------------------------- ### Create a GitLab project with glab Source: https://docs.gitlab.com/17.11/tutorials/setup_steps/ Creates a new GitLab project named zero-to-steps in your namespace using the GitLab CLI. Requires glab to be installed and signed in. ```shell glab project create zero-to-steps ``` -------------------------------- ### Install a package through the dependency firewall with glab df npm install Source: https://docs.gitlab.com/user/application_security/dependency_firewall/quickstart/ Clone the project the policy applies to, then run your usual install command prefixed with glab df. The CLI checks each resolved package against your policy; npm runs as it always does. ```shell git clone https://gitlab.example.com/my-group/my-project.git cd my-project glab df npm install ``` -------------------------------- ### Install and start GitLab Runner as a service using a user account Source: https://docs.gitlab.com/runner/install/windows/ Run these commands in an elevated PowerShell prompt from the GitLab Runner directory (for example, C:\GitLab-Runner). You must provide a valid password for the current user account because Windows requires it to start the service. Replace ENTER-YOUR-USERNAME and ENTER-YOUR-PASSWORD with your credentials. ```powershell cd C:\GitLab-Runner .\gitlab-runner.exe install --user ENTER-YOUR-USERNAME --password ENTER-YOUR-PASSWORD .\gitlab-runner.exe start ``` -------------------------------- ### Copy and enable example NGINX site configuration for GitLab Source: https://docs.gitlab.com/install/self_compiled/ Copies the example site configuration and creates a symbolic link to enable it. Edit the configuration file afterward to match your setup. ```shell sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab ``` -------------------------------- ### Install Go on macOS using installation package Source: https://docs.gitlab.com/19.4/runner/development/ Install Go runtime on macOS using the installation package method. ```shell wget https://storage.googleapis.com/golang/go1.26.5.darwin-amd64.pkg open go*-*.pkg export PATH="$(go env GOBIN):$PATH" YQ_BINARY="yq_$(go env GOHOSTOS)_$(go env GOHOSTARCH).tar.gz" wget https://github.com/mikefarah/yq/releases/download/latest/${YQ_BINARY}.tar.gz sudo tar -C /usr/local -xzf ${YQ_BINARY}.tar.gz ``` -------------------------------- ### Install postfix package Source: https://docs.gitlab.com/administration/reply_by_email_postfix_setup/ Install the postfix package if not already installed. When prompted, select 'Internet Site' and confirm the hostname matches gitlab.example.com. ```shell sudo apt-get install postfix ``` -------------------------------- ### Check a package without installing using glab df package Source: https://docs.gitlab.com/user/application_security/dependency_firewall/quickstart/ Run glab df package with a package URL to check a package without installing it. For more information, see glab dependency-firewall package. ```shell glab df package pkg:npm/lodash@4.17.15 ``` -------------------------------- ### Fetch instance identity and settings example request Source: https://docs.gitlab.com/development/internal_api/orbit/ Example request to retrieve the instance identity and settings. ```shell curl --header "Gitlab-Orbit-Api-Request: " "https://gitlab.example.com/api/v4/internal/orbit/instance" ``` -------------------------------- ### Globalize test gems in GitLab container Source: https://docs.gitlab.com/development/data_seeder/ Run the globalize_gems.rb script and bundle install inside the container. Use this after starting the container with GDK. ```shell docker exec gitlab bash -c "cd /opt/gitlab/embedded/service/gitlab-rails; ruby scripts/data_seeder/globalize_gems.rb; bundle install" ``` -------------------------------- ### Check GitLab CLI version with glab version Source: https://docs.gitlab.com/user/clusters/agent/getting_started/ Run to verify that the GitLab CLI is installed and available before bootstrapping the agent. ```shell glab version ``` -------------------------------- ### Example successful pipeline output Source: https://docs.gitlab.com/17.11/tutorials/setup_steps/ Example output from a successful pipeline run showing the step runner version, greeting outputs, and final all_greetings message. ```shell Step Runner version: a7c7c8fd See https://gitlab.com/gitlab-org/step-runner/-/blob/main/CHANGELOG.md for changes. ... {"name":"greeting","value":"hello world"} {"name":"greeting","value":"hello gitlab steps"} all my greetings say hello world and hello gitlab steps Cleaning up project directory and file based variables Job succeeded ``` -------------------------------- ### Regenerate Custom Resources with Custom Domain Source: https://docs.gitlab.com/operator/developer/installation/ Regenerate the custom resources without deploying anything, for example after changing the domain or chart version. ```shell GITLAB_DOMAIN=my-cluster.test bash scripts/dev_dependencies.sh generate ``` -------------------------------- ### Install Go on macOS using binary package Source: https://docs.gitlab.com/19.4/runner/development/ Install Go runtime on macOS using the binary package method. ```shell wget https://storage.googleapis.com/golang/go1.26.5.darwin-amd64.tar.gz sudo tar -C /usr/local -xzf go*-*.tar.gz export PATH="$(go env GOBIN):$PATH" YQ_BINARY="yq_$(go env GOHOSTOS)_$(go env GOHOSTARCH).tar.gz" wget https://github.com/mikefarah/yq/releases/download/latest/${YQ_BINARY}.tar.gz sudo tar -C /usr/local -xzf ${YQ_BINARY}.tar.gz ``` -------------------------------- ### Enable and start ufw service Source: https://docs.gitlab.com/tutorials/install_gitlab_single_node/ Enable and start the ufw service so it runs on boot. ```shell sudo systemctl enable --now ufw ``` -------------------------------- ### Fetch project info example request Source: https://docs.gitlab.com/development/internal_api/orbit/ Example request to retrieve project info. ```shell curl --header "Gitlab-Orbit-Api-Request: " "https://gitlab.example.com/api/v4/internal/orbit/project/1/info" ``` -------------------------------- ### Set up GitLab Orbit for an agent with glab orbit setup Source: https://docs.gitlab.com/orbit/quickstart/ Paste this prompt into your agent to have it run the GitLab Orbit setup and status commands. The agent downloads the GitLab Orbit CLI, installs the skill, and indexes the repository for code search. ```plaintext Set up GitLab Orbit for this agent. In this repository, run `glab orbit --yes setup --yes`, then run `glab orbit status --full-path` with this repository's GitLab project path and show me the result. If a command fails, see https://docs.gitlab.com/orbit/troubleshooting/. ``` -------------------------------- ### Install Gitaly Source: https://docs.gitlab.com/install/self_compiled/ Creates and restricts access to the git repository data directory, then fetches Gitaly source with Git and compiles with Go. Installs Gitaly in /home/git/gitaly and uses /home/git/repositories as the data directory. ```shell # Create and restrict access to the git repository data directory sudo install -d -o git -m 0700 /home/git/repositories # Fetch Gitaly source with Git and compile with Go cd /home/git/gitlab sudo -u git -H bundle exec rake "gitlab:gitaly:install[/home/git/gitaly,/home/git/repositories]" RAILS_ENV=production ``` -------------------------------- ### Run tests with bundle exec rspec Source: https://docs.gitlab.com/omnibus/development/contribute-to-omnibus-gitlab/ Run the test suite for the internal cookbook. You may need to run `bundle install` first. ```shell bundle exec rspec ``` -------------------------------- ### Extract and move orbit.exe to LOCALAPPDATA Programs Source: https://docs.gitlab.com/19.5/orbit/local/getting-started/ Extracts the archive, creates the target directory, and moves orbit.exe into $env:LOCALAPPDATA\Programs\orbit, the same default the installer uses. ```powershell Expand-Archive -Path .\orbit-cli-windows-x86_64.zip -DestinationPath . New-Item -ItemType Directory -Force -Path "$env:LOCALAPPDATA\Programs\orbit" Move-Item .\orbit.exe "$env:LOCALAPPDATA\Programs\orbit\orbit.exe" ``` -------------------------------- ### Install mailutils package Source: https://docs.gitlab.com/administration/reply_by_email_postfix_setup/ Install the mailutils package. ```shell sudo apt-get install mailutils ``` -------------------------------- ### App descriptor URL example for Jira Cloud app installation Source: https://docs.gitlab.com/development/integrations/jira_connect/ Use this URL format in the Jira 'From this URL' field when installing the GitLab for Jira Cloud app. The host and port must point to your GitLab instance. ```plaintext https://xxxx.gitpod.io/-/jira_connect/app_descriptor.json ``` -------------------------------- ### Start the runit server Source: https://docs.gitlab.com/19.5/omnibus/settings/configuration/ Starts the runit server. Required after moving the home directory for the GitLab user. ```shell sudo systemctl start gitlab-runsvdir ``` -------------------------------- ### Fetch a subscription example request Source: https://docs.gitlab.com/development/internal_api/gitlab_subscriptions/ Example request for fetching a subscription. ```shell curl --header "X-CUSTOMERS-DOT-INTERNAL-TOKEN: " "https://gitlab.com/api/v4/internal/gitlab_subscriptions/namespaces/1234/gitlab_subscription" ``` -------------------------------- ### Example output of systemctl list-jobs showing stuck plymouth-quit-wait.service Source: https://docs.gitlab.com/omnibus/troubleshooting/ This output shows plymouth-quit-wait.service in 'running' state, which may block gitlab-runsvdir from starting. Consider uninstalling Plymouth if this occurs. ```plaintext 1 graphical.target start waiting 107 plymouth-quit-wait.service start running 2 multi-user.target start waiting 169 ureadahead-stop.timer start waiting 121 gitlab-runsvdir.service start waiting 151 system-getty.slice start waiting 31 setvtrgb.service start waiting 122 systemd-update-utmp-runlevel.service start waiting ``` -------------------------------- ### Install and start GitLab Runner service on macOS Source: https://docs.gitlab.com/runner/install/osx/ Run these commands to install and start the GitLab Runner service. The install command creates a LaunchAgent plist at ~/Library/LaunchAgents/gitlab-runner.plist and registers it with launchctl. ```shell cd ~ gitlab-runner install gitlab-runner start ``` -------------------------------- ### Enable GitLab to start on boot with SysV init Source: https://docs.gitlab.com/install/self_compiled/ Run update-rc.d to enable GitLab on boot, or use systemctl commands if the machine runs systemd. ```shell sudo update-rc.d gitlab defaults 21 # or if running this on a machine running systemd sudo systemctl daemon-reload sudo systemctl enable gitlab.service ``` -------------------------------- ### Trust and install mise plugins Source: https://docs.gitlab.com/charts/development/environment_setup/ Run after cloning the charts repository to trust and install all mise plugins specified in the provided mise.toml. ```shell mise trust mise install ``` -------------------------------- ### Start a guided GitLab Orbit session with orbit-start skill Source: https://docs.gitlab.com/orbit/quickstart/ Paste this prompt into an agent that runs shell commands, such as Claude Code or Codex, to begin a guided first session. The agent asks which project or group to use, answers a first question, and offers to show how GitLab Orbit works. ```plaintext Get started with GitLab Orbit: run `glab orbit skills get orbit-start` and follow the skill that it prints. ``` -------------------------------- ### Initialize a Rust project with cargo init Source: https://docs.gitlab.com/ci/components/examples/ Run from the CI/CD component root directory to create the required Rust project files, including a src/main.rs hello world example. This step is sufficient to build the Rust source code in a component job with cargo build. ```shell cargo init ``` -------------------------------- ### Dependency Firewall npm examples Source: https://docs.gitlab.com/cli/dependency-firewall/npm/ Examples of running npm commands through the Dependency Firewall, including install, install a specific package, clean install from lockfile, and publish. ```console # Install dependencies through the Dependency Firewall glab dependency-firewall npm install # Install a package through the Dependency Firewall glab dependency-firewall npm install left-pad # Clean install from the lockfile through the Dependency Firewall glab dependency-firewall npm ci # Publish a package through the Dependency Firewall glab dependency-firewall npm publish ``` -------------------------------- ### Example project-specific guidelines AGENTS.md Source: https://docs.gitlab.com/user/duo_agent_platform/customize/agents_md/ Example instructions for a project-level AGENTS.md file to define project-specific guidelines. ```markdown # Project-specific guidelines - This project uses React with TypeScript - Follow the component structure in /src/components - Use our custom hooks from /src/hooks - State management uses Redux Toolkit ``` -------------------------------- ### Create a subscription example response Source: https://docs.gitlab.com/development/internal_api/gitlab_subscriptions/ Example response for creating a subscription. ```json { "plan": { "code":"premium", "name":"premium", "trial":false, "auto_renew":null, "upgradable":false }, "usage": { "seats_in_subscription":10, "seats_in_use":1, "max_seats_used":0, "seats_owed":0 }, "billing": { "subscription_start_date":"2020-07-15", "subscription_end_date":null, "trial_ends_on":null } } ``` -------------------------------- ### Start GitLab Rails console for source installations Source: https://docs.gitlab.com/administration/feature_flags/ Start a Rails console session on a source installation to enable or disable feature flags. ```shell sudo -u git -H bundle exec rails console -e production ``` -------------------------------- ### Example request: Get per-file diffs for a merge request diff Source: https://docs.gitlab.com/development/internal_api/orbit/ Example curl request to get per-file diffs for a MergeRequestDiff record. ```shell curl --header "Gitlab-Orbit-Api-Request: " \ "https://gitlab.example.com/api/v4/internal/orbit/project/1/merge_request_diffs/42" ``` -------------------------------- ### Example output of show databases and show clients Source: https://docs.gitlab.com/administration/reference_architectures/5k_users/ The output should be similar to the following. ```plaintext name | host | port | database | force_user | pool_size | reserve_pool | pool_mode | max_connections | current_connections ---------------------+-------------+------+---------------------+------------+-----------+--------------+-----------+-----------------+--------------------- gitlabhq_production | MASTER_HOST | 5432 | gitlabhq_production | | 20 | 0 | | 0 | 0 pgbouncer | | 6432 | pgbouncer | pgbouncer | 2 | 0 | statement | 0 | 0 (2 rows) type | user | database | state | addr | port | local_addr | local_port | connect_time | request_time | ptr | link | remote_pid | tls ------+-----------+---------------------+---------+----------------+-------+------------+------------+---------------------+---------------------+-----------+------+------------+----- C | pgbouncer | pgbouncer | active | 127.0.0.1 | 56846 | 127.0.0.1 | 6432 | 2017-08-21 18:09:59 | 2017-08-21 18:10:48 | 0x22b3880 | | 0 | (2 rows) ``` -------------------------------- ### Install dependencies with yarn install Source: https://docs.gitlab.com/tutorials/dependency_scanning/ Run in the Gitpod Terminal to install the newly added dependency. ```plaintext yarn install ``` -------------------------------- ### Install and start GitLab Runner as a service Source: https://docs.gitlab.com/runner/install/linux-manually/ Install GitLab Runner as a service and start it. Ensure /usr/local/bin/ is in $PATH for root to avoid 'command not found' errors. ```shell sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner sudo gitlab-runner start ``` -------------------------------- ### Start GitLab Helm chart with ClickHouse enabled Source: https://docs.gitlab.com/charts/development/clickhouse/ Installs or upgrades the GitLab chart using the ClickHouse example values file. Fill in the ClickHouse server details in examples/kind/enable-clickhouse.yaml before running. ```shell helm upgrade --install gitlab . \ --timeout 600s \ --set global.image.pullPolicy=Always \ --set global.hosts.domain=YOUR_IP.nip.io \ --set global.hosts.externalIP=YOUR_IP \ -f examples/kind/values-base.yaml \ -f examples/kind/values-no-ssl.yaml \ -f examples/clickhouse/enable-clickhouse.yaml ``` -------------------------------- ### Commit and Push to Trigger Pipeline Source: https://docs.gitlab.com/17.11/tutorials/setup_steps/ Run these commands to commit both files, push the repository, and check pipeline status with glab ci status. ```shell git add . git commit -m 'Part 1 complete' git push --set-upstream origin main glab ci status ``` -------------------------------- ### Create index.js for Fastify application Source: https://docs.gitlab.com/tutorials/dependency_scanning/ Sets up a Fastify server with static file serving and custom routes, listening on port 8080. Includes commented-out code for node-fetch and fastify-redis. ```javascript // Require the framework and instantiate it const fastify = require('fastify')({ logger: true }) const path = require('path') //const fetch = require('node-fetch') fastify.register(require('fastify-static'), { root: path.join(__dirname, 'public'), prefix: '/' }) fastify.register(require('./routes'), { message: "hello" }) // fastify.register(require('fastify-redis'), { url: constants.redisUrl, /* other redis options */ }) // Run the server! const start = async () => { try { await fastify.listen(8080, "0.0.0.0") fastify.log.info(`server listening on ${fastify.server.address().port}`) } catch (error) { fastify.log.error(error) //process.exit(1) } } start() ``` -------------------------------- ### GET changed_paths example request with curl Source: https://docs.gitlab.com/development/internal_api/orbit/ Example curl request for the GET changed_paths endpoint. Requires the Gitlab-Orbit-Api-Request header with a JSON web token. ```shell curl --header "Gitlab-Orbit-Api-Request: " "https://gitlab.example.com/api/v4/internal/orbit/project/1/repository/changed_paths?left_tree_revision=0123456789abcdef0123456789abcdef01234567&right_tree_revision=89abcdef0123456789abcdef0123456789abcdef" ``` -------------------------------- ### Example output of systemctl -t target showing inactive dead multi-user.target Source: https://docs.gitlab.com/omnibus/troubleshooting/ This output shows multi-user.target as 'inactive dead', indicating a problem that may prevent gitlab-runsvdir from starting. Investigate further with systemctl list-jobs. ```plaintext multi-user.target loaded inactive dead start Multi-User System ``` -------------------------------- ### Example monorepo context AGENTS.md Source: https://docs.gitlab.com/user/duo_agent_platform/customize/agents_md/ Example instructions for a user-level AGENTS.md file to provide monorepo context. ```markdown # Monorepo context - This is a monorepo with multiple services - Frontend code is in /apps/web - Backend services are in /services - Shared libraries are in /packages - Follow the architecture decision records in /docs/adr ``` -------------------------------- ### Create an empty step.yml file Source: https://docs.gitlab.com/17.11/tutorials/setup_steps/ Creates an empty step.yml file in the project root to hold the step specification and implementation. ```shell touch step.yml ``` -------------------------------- ### Example output of systemctl -t target showing all targets active Source: https://docs.gitlab.com/omnibus/troubleshooting/ This output indicates that all targets are loaded and active, which is the expected state for gitlab-runsvdir to start. If any line shows 'inactive dead', there may be a problem. ```plaintext UNIT LOAD ACTIVE SUB DESCRIPTION basic.target loaded active active Basic System cloud-config.target loaded active active Cloud-config availability cloud-init.target loaded active active Cloud-init target cryptsetup.target loaded active active Encrypted Volumes getty.target loaded active active Login Prompts graphical.target loaded active active Graphical Interface local-fs-pre.target loaded active active Local File Systems (Pre) local-fs.target loaded active active Local File Systems multi-user.target loaded active active Multi-User System network-online.target loaded active active Network is Online network-pre.target loaded active active Network (Pre) network.target loaded active active Network nss-user-lookup.target loaded active active User and Group Name Lookups paths.target loaded active active Paths remote-fs-pre.target loaded active active Remote File Systems (Pre) remote-fs.target loaded active active Remote File Systems slices.target loaded active active Slices sockets.target loaded active active Sockets swap.target loaded active active Swap sysinit.target loaded active active System Initialization time-sync.target loaded active active System Time Synchronized timers.target loaded active active Timers LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 22 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use 'systemctl list-unit-files'. ``` -------------------------------- ### Install Jenkins and start the service using Homebrew Source: https://docs.gitlab.com/development/integrations/jenkins/ Install Jenkins and start the service using Homebrew on macOS. ```shell brew install jenkins brew services start jenkins ``` -------------------------------- ### Enable courier-authdaemon on boot Source: https://docs.gitlab.com/administration/reply_by_email_postfix_setup/ Configures courier-authdaemon to start automatically at boot. ```shell sudo systemctl enable courier-authdaemon ``` -------------------------------- ### Build and install a Fleeting plugin with go install Source: https://docs.gitlab.com/runner/development/ Generates an executable binary for a Fleeting plugin and places it on your system's PATH. Ensure $GOPATH/bin is on your PATH before running. Run from the plugin's directory, e.g., fleeting-plugin-aws. ```shell cd cmd/fleeting-plugin-aws/ go install ``` -------------------------------- ### Example request to get a release by tag name Source: https://docs.gitlab.com/api/releases/ Example curl request to get a release by tag name. Requires a personal access token. ```shell curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/24/releases/v0.1" ``` -------------------------------- ### Example request: Get a single SCIM provisioned user Source: https://docs.gitlab.com/development/internal_api/ Example curl request to get a single SCIM provisioned user by ID. Requires a SCIM token for authorization. ```shell curl "https://gitlab.example.com/api/scim/v2/groups/test_group/Users/f0b1d561c-21ff-4092-beab-8154b17f82f2" \ --header "Authorization: Bearer " --header "Content-Type: application/scim+json" ``` -------------------------------- ### Move step.yml to hello directory Source: https://docs.gitlab.com/17.11/tutorials/setup_steps/ Run these shell commands to create a `hello` directory and move the existing `step.yml` into it. ```shell mkdir hello mv step.yml hello/ ``` -------------------------------- ### List all project service accounts example request Source: https://docs.gitlab.com/api/service_accounts/ Example request to list all service accounts in a project. ```shell curl --request GET \ --header "PRIVATE-TOKEN: " \ --url "https://gitlab.example.com/api/v4/projects/345/service_accounts" ``` -------------------------------- ### Define build and test stages in .gitlab-ci.yml Source: https://docs.gitlab.com/ci/ Add a .gitlab-ci.yml file to the root of your project to define pipeline stages and jobs. The filename is case-sensitive and defaults to .gitlab-ci.yml. This example defines build and test stages with corresponding jobs. ```yaml stages: - build - test build-job: stage: build script: - echo "Compiling the code..." test-job: stage: test script: - echo "Running tests..." ``` -------------------------------- ### Ask Chat for Python virtual environment setup best practices Source: https://docs.gitlab.com/user/gitlab_duo/tutorials/fix_code_python_shop/ Use this prompt to ask Chat about recommended steps for setting up a Python virtual environment with Flask, including requirements.txt and pip. ```plaintext What are the recommended steps for setting up a Python virtual environment with Flask? Include information about requirements.txt and pip. ``` -------------------------------- ### Start GitLab Rails console for Linux package installations Source: https://docs.gitlab.com/19.5/administration/feature_flags/ Use this command to start a Rails console session on a Linux package installation. Required before running Feature.enable or Feature.disable commands. ```shell sudo gitlab-rails console ``` -------------------------------- ### Example request: Get raw unified patch for a merge request diff Source: https://docs.gitlab.com/development/internal_api/orbit/ Example curl request to get the full unified patch for a MergeRequestDiff record as text/plain, streamed through Workhorse. ```shell curl --header "Gitlab-Orbit-Api-Request: " \ "https://gitlab.example.com/api/v4/internal/orbit/project/1/merge_request_diffs/42/raw_diffs" ``` -------------------------------- ### Create incoming user Source: https://docs.gitlab.com/19.5/administration/reply_by_email_postfix_setup/ Create a user for incoming email. ```shell sudo useradd -m -s /bin/bash incoming ``` -------------------------------- ### Get a single SCIM provisioned user example request Source: https://docs.gitlab.com/development/internal_api/ Example request for the Get a single SCIM provisioned user endpoint. Requires an Authorization Bearer token and Content-Type application/scim+json. ```shell curl "https://gitlab.example.com/api/scim/v2/application/Users/f0b1d561c-21ff-4092-beab-8154b17f82f2" \ --header "Authorization: Bearer " --header "Content-Type: application/scim+json" ``` -------------------------------- ### Create incoming user Source: https://docs.gitlab.com/administration/reply_by_email_postfix_setup/ Create a user for incoming email with a home directory and bash shell. ```shell sudo useradd -m -s /bin/bash incoming ``` -------------------------------- ### Get a list of SCIM provisioned users example response Source: https://docs.gitlab.com/development/internal_api/ Example response for the Get a list of SCIM provisioned users endpoint. Shows a SCIM ListResponse with one user resource. ```json { "schemas": [ "urn:ietf:params:scim:api:messages:2.0:ListResponse" ], "totalResults": 1, "itemsPerPage": 20, "startIndex": 1, "Resources": [ { "schemas": [ "urn:ietf:params:scim:schemas:core:2.0:User" ], "id": "0b1d561c-21ff-4092-beab-8154b17f82f2", "active": true, "name.formatted": "Test User", "userName": "username", "meta": { "resourceType":"User" }, "emails": [ { "type": "work", "value": "name@example.com", "primary": true } ], "groups": [ { "value": "86e7d437-1a55-4731-b3a3-2867fb4d2a94", "display": "Developers", "type": "direct" } ] } ] } ``` -------------------------------- ### Get a list of SCIM provisioned users example request Source: https://docs.gitlab.com/development/internal_api/ Example request for the Get a list of SCIM provisioned users endpoint. Requires an Authorization Bearer token and Content-Type application/scim+json. ```shell curl "https://gitlab.example.com/api/scim/v2/application/Users?filter=id%20eq%20%220b1d561c-21ff-4092-beab-8154b17f82f2%22" \ --header "Authorization: Bearer " \ --header "Content-Type: application/scim+json" ``` -------------------------------- ### List all instance service accounts example request and response Source: https://docs.gitlab.com/api/service_accounts/ Example request to list all instance service accounts and the corresponding JSON response. Requires administrator access to the instance. ```shell curl --request GET \ --header "PRIVATE-TOKEN: " \ --url "https://gitlab.example.com/api/v4/service_accounts" ``` ```json [ { "id": 114, "username": "service_account_33", "public_email": "", "name": "Service account user", "email": "service_account_33@noreply.gitlab.example.com" }, { "id": 137, "username": "service_account_34", "public_email": "", "name": "john doe", "email": "service_account_34@noreply.gitlab.example.com" } ] ``` -------------------------------- ### Disable metadata database for new self-compiled installations Source: https://docs.gitlab.com/administration/packages/container_registry_metadata_database/ Set `database.enabled` to `false` in `/home/git/gitlab/config/gitlab.yml` before the first registry start to keep a new installation on filesystem metadata. Without this, the registry starts in prefer mode and fails to start if no reachable metadata database is configured. ```yaml registry: database: enabled: false ``` -------------------------------- ### Install Go and dependencies on FreeBSD Source: https://docs.gitlab.com/runner/development/ Installs Go 1.26.10 and yq on FreeBSD. ```shell pkg install go-1.26.10 gmake git mercurial export PATH="$(go env GOBIN):$PATH" YQ_BINARY="yq_$(go env GOHOSTOS)_$(go env GOHOSTARCH).tar.gz" wget https://github.com/mikefarah/yq/releases/download/latest/${YQ_BINARY}.tar.gz sudo tar -C /usr/local -xzf ${YQ_BINARY}.tar.gz ``` -------------------------------- ### Example Patroni cluster status with all nodes stopped Source: https://docs.gitlab.com/administration/postgresql/replication_and_failover_troubleshooting/ Shows a Patroni cluster in an unknown or bad state where no node can start. Use this to identify the condition that may require resetting the Patroni state in Consul. ```plaintext + Cluster: postgresql-ha (6970678148837286213) ------+---------+---------+----+-----------+ | Member | Host | Role | State | TL | Lag in MB | +-------------------------------------+--------------+---------+---------+----+-----------+ | gitlab-database-1.example.com | 172.18.0.111 | Replica | stopped | | unknown | | gitlab-database-2.example.com | 172.18.0.112 | Replica | stopped | | unknown | | gitlab-database-3.example.com | 172.18.0.113 | Replica | stopped | | unknown | +-------------------------------------+--------------+---------+---------+----+-----------+ ``` -------------------------------- ### Start Rails console for Omnibus or source installations Source: https://docs.gitlab.com/administration/wikis/ Use this command to start the Rails console for GitLab Self-Managed. Choose the Omnibus or source installation variant as appropriate. ```shell # For Omnibus installations sudo gitlab-rails console # For installations from source sudo -u git -H bundle exec rails console -e production ``` -------------------------------- ### Create .gitlab-ci.yml File Source: https://docs.gitlab.com/17.11/tutorials/setup_steps/ Run this command in the root of the repository to create the .gitlab-ci.yml file. ```shell touch .gitlab-ci.yml ``` -------------------------------- ### Enable and start gitlab-runner service on FreeBSD Source: https://docs.gitlab.com/runner/install/freebsd/ Enables the gitlab_runner service to start at boot and starts it immediately. ```shell sudo sysrc gitlab_runner_enable=YES sudo service gitlab_runner start ```