{"id":14980413,"url":"https://github.com/chris-peterson/pwsh-gitlab","last_synced_at":"2025-06-15T12:02:56.950Z","repository":{"id":38082372,"uuid":"379003538","full_name":"chris-peterson/pwsh-gitlab","owner":"chris-peterson","description":"PowerShell module for GitLab","archived":false,"fork":false,"pushed_at":"2025-02-03T20:37:26.000Z","size":803,"stargazers_count":23,"open_issues_count":19,"forks_count":11,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-02-05T08:13:39.307Z","etag":null,"topics":["gitlab","gitlab-api","powershell","powershell-cmdlets","powershell-core","powershell-module","pwsh-module"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chris-peterson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-21T16:59:09.000Z","updated_at":"2025-02-03T20:37:30.000Z","dependencies_parsed_at":"2024-10-26T05:58:05.228Z","dependency_job_id":"761720b2-dd25-415c-9b4d-925d848b2982","html_url":"https://github.com/chris-peterson/pwsh-gitlab","commit_stats":{"total_commits":421,"total_committers":10,"mean_commits":42.1,"dds":"0.21615201900237535","last_synced_commit":"2ce7574bb89d0adc6f827a0caa34fd0c8fa6a75f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-peterson%2Fpwsh-gitlab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-peterson%2Fpwsh-gitlab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-peterson%2Fpwsh-gitlab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-peterson%2Fpwsh-gitlab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chris-peterson","download_url":"https://codeload.github.com/chris-peterson/pwsh-gitlab/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238743897,"owners_count":19523197,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gitlab","gitlab-api","powershell","powershell-cmdlets","powershell-core","powershell-module","pwsh-module"],"created_at":"2024-09-24T14:01:44.198Z","updated_at":"2025-06-15T12:02:56.924Z","avatar_url":"https://github.com/chris-peterson.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitlabCli\n\n\u003cimg src=\"assets/icon.png\" width=\"64\"\u003e\u0026zwnj;\n[![PowerShell Gallery Version](https://img.shields.io/powershellgallery/v/GitlabCli)](https://www.powershellgallery.com/packages/GitlabCli)\n[![Platforms](https://img.shields.io/powershellgallery/p/GitlabCli)](https://www.powershellgallery.com/packages/GitlabCli)\n[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/GitlabCli?color=green)](https://www.powershellgallery.com/packages/GitlabCli)\n[![GitHub license](https://img.shields.io/github/license/chris-peterson/pwsh-gitlab.svg)](LICENSE)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/chris-peterson/pwsh-gitlab/deploy.yml?branch=main\u0026label=ci)](https://github.com/chris-peterson/pwsh-gitlab/actions/workflows/deploy.yml)\n\n Interact with [GitLab](https://about.gitlab.com/) via [PowerShell](https://github.com/powershell/powershell#-powershell)\n\n## Getting Started\n\n### Module\n\n```powershell\nInstall-Module -Name GitlabCli\n```\n\n### Docker Image\n\n```sh\ndocker run -it ghcr.io/chris-peterson/pwsh-gitlab/gitlab-cli\n```\n\n### Configuration\n\n#### Environment Variables\n\n##### `$env:GITLAB_ACCESS_TOKEN`\n\nObtain a \"Personal Access Token\" (PAT) for your GitLab instance\n\n`https://\u003cyour gitlab instance\u003e/-/profile/personal_access_tokens`\n\n\u003cimg width=600 src=\"PersonalAccessToken.jpg\"/\u003e\n\nMake the value available via\n\n`$env:GITLAB_ACCESS_TOKEN='\u003cyour pat\u003e'`.\n\nOne way to do this would be to add a line to your `$PROFILE`\n\n##### `$env:GITLAB_URL`\n\n(Optional) If using a gitlab instance that is not `gitlab.com`, provide it via:\n\n`$env:GITLAB_URL='\u003cyour gitlab instance\u003e'`\n\n#### Example PowerShell Profile\n\n```powershell\n$env:GITLAB_URL='gitlab.mydomain.com'\n$env:GITLAB_ACCESS_TOKEN='\u003cmy token\u003e'\nImport-Module GitlabCli\n```\n\n#### Configuration File\n\nThe following commands can be used to configure your system for use with **multiple** gitlab sites.\n\n* `Add-GitlabSite`\n* `Remove-GitlabSite`\n* `Set-DefaultGitlabSite`\n\n## Global Switches\n\nThe following switches are supported when possible:\n\n`-WhatIf` : For mutable operations (or for some complex query operations), gives a preview of what actions would be taken\n\n`-Select` : Select into a property of the response.  A shortcut for `| Select-Object -ExpandProperty` or select multiple properties separated by commas\n\n`-SiteUrl` : Optional.  By default, site url is inferred from the local git context.  Providing a value overrides this value.  The provided value must match a configured site's url (e.g. `gitlab.com`)\n\n`-Follow` : For operations that create a resource, follow the the URL after creation\n\n`-MaxPages`: For query operations, maximum number of pages to return.  Typically defaults to 1\n\n`-Recurse`: For tree-based operations, opt-in to recurse children (e.g. `Get-GitlabProject -GroupId 'mygroup' -Recurse`)\n\n`-CopyToClipboard` : For token-based operations, copy the resultant token to the clipboard rather than displaying in the terminal\n\n`-Wait` : For long-running operations (e.g. running a job/pipeline), wait for operation to complete.  In the meantime, the status is polled and reported to the terminal\n\n## Global Behaviors\n\nIf invoking commands from within a git repository, `.` can be used for `ProjectId` / `BranchName` to use the local context.\n\nMost objects returned from commands have a `Url` property.  This makes it so you can pipe one or more objects to `Open-InBrowser` (aka `go`)\n\n## Examples\n\n### Groups\n\n#### `Get-GitlabGroup`\n\n```powershell\nGet-GitlabGroup 'mygroup'\n```\n\n```plaintext\n  ID Name     Url\n  -- ----     ---\n  23 mygroup  https://gitlab.mydomain.com/mygroup\n```\n\n#### `Remove-GitlabGroup`\n\n```powershell\nRemove-GitlabGroup 'mygroup'\n```\n\n#### `Clone-GitlabGroup` (aka `Copy-GitlabGroupToLocalFileSystem`)\n\n```powershell\nClone-GitlabGroup 'mygroup'\n```\n\n### Projects\n\n#### `Get-GitlabProject` (by id)\n\n```powershell\nGet-GitlabProject 'mygroup/myproject'\n# OR\nGet-GitlabProject 42\n# OR\nGet-GitlabProject # use local context\n```\n\n```plaintext\n  ID Name        Group     Url\n  -- ----        -----     ---\n  42 myproject   mygroup   https://gitlab.mydomain.com/mygroup/myproject\n```\n\n#### `Get-GitlabProject` (by group)\n\n```powershell\nGet-GitlabProject -GroupId 'mygroup/subgroup'\n```\n\n```plaintext\n  ID Name        Group             Url\n  -- ----        -----             ---\n   1 database    mygroup/subgroup  https://gitlab.mydomain.com/mygroup/subgroup/database\n   2 infra       mygroup/subgroup  https://gitlab.mydomain.com/mygroup/subgroup/infra\n   3 service     mygroup/subgroup  https://gitlab.mydomain.com/mygroup/subgroup/service\n   4 website     mygroup/subgroup  https://gitlab.mydomain.com/mygroup/subgroup/website\n```\n\n_Optional Parameters_\n\n`-IncludeArchived` - Set this switch to include archived projects.  _By default, archived projects are not returned_\n\n#### `Transfer-GitlabProject` (aka `Move-GitlabProject`)\n\n```powershell\nTransfer-GitlabProject -ProjectId 'this-project' -DestinationGroup 'that-group'\n```\n\n### Merge Requests\n\n#### `New-GitlabMergeRequest`\n\n```powershell\nNew-GitlabMergeRequest\n```\n\n_Optional Parameters_\n\n`-ProjectId` - Defaults to local git context\n\n`-SourceBranch` - Defaults to local git context\n\n`-TargetBranch` - Defaults to the default branch set in repository config (typically `main`)\n\n`-Title` - Defaults to space-delimited source branch name\n\n## Other Examples\n\n### `mr`\n\nCreate or get merge request for current git context\n\n### Get Deployment\n\n```powershell\nGet-GitlabDeployment -Status 'created' -Environment 'nuget.org'\n```\n\n```plaintext\n        ID Status     EnvironmentName      Ref                     CreatedAt\n        -- ------     ---------------      ---                     ---------\n 196679897 created    nuget.org            main         9/26/2021 5:56:57 AM\n ```\n\n### Open Web Browser\n\n```powershell\n~/src/your-project\u003e Get-GitlabProject |\n  pipelines -Latest -Branch 'main' -Status 'success' | go\n```\n\nOpens latest successful pipeline in browser.\n\n### Resolve Variable\n\n`Resolve-GitlabVariable` (aka `var`) checks a project or group for a variable.  Walks up the group hierarchy until found, or no other nodes to check.\nAutomatically expands the value.\n\nExample\n```powershell\nGet-GitlabProject | var APPLICATION_NAME\n```\n```text\nYour application\n```\n\n ### Get pipeline for latest deployement\n \n ```powershell\n envs -Search prod | deploys -Latest -Select Pipeline [| go]\n ```\n\n### Deploy To Production\n\n```powershell\n~/src/your-project\u003e pipelines -Branch 'main' -Status 'success' -Latest |\n  jobs -Stage deploy -Name prod |\n  Play-GitlabJob\n```\n\n### Get Pipeline Schedule\n\n```powershell\n~/src/your-project\u003e schedule\n\n   ID Active Description                              Cron         NextRunAt\n   -- ------ -----------                              ----         ---------\n 1948 True   Weekly restore for database              0 3 * * 0    9/26/2021 10:04:00 AM\n ```\n\n## References / Acknowledgements\n\n* [PSGitLab](https://github.com/ngetchell/PSGitLab) (now archived)\n* [python-gitlab CLI documentation](https://python-gitlab.readthedocs.io/en/stable)\n* [GitLab API docs](https://docs.gitlab.com/ee/api/rest/index.html)\n* [powershell-yaml](https://github.com/cloudbase/powershell-yaml)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchris-peterson%2Fpwsh-gitlab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchris-peterson%2Fpwsh-gitlab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchris-peterson%2Fpwsh-gitlab/lists"}