https://github.com/nikhilsbhat/gocd-cli
A command-line tool for interacting with GoCD
https://github.com/nikhilsbhat/gocd-cli
cd ci ci-server cicd command-line continuous-delivery continuous-integration create delete diff go-cont gocd gocd-cli golang update
Last synced: 4 months ago
JSON representation
A command-line tool for interacting with GoCD
- Host: GitHub
- URL: https://github.com/nikhilsbhat/gocd-cli
- Owner: nikhilsbhat
- License: mit
- Created: 2023-02-11T13:59:39.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-07-31T14:34:46.000Z (11 months ago)
- Last Synced: 2025-10-25T17:53:58.200Z (8 months ago)
- Topics: cd, ci, ci-server, cicd, command-line, continuous-delivery, continuous-integration, create, delete, diff, go-cont, gocd, gocd-cli, golang, update
- Language: Go
- Homepage: https://github.com/nikhilsbhat/gocd-cli/blob/main/docs/doc/gocd-cli.md
- Size: 1.36 MB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GoCD commandline interface
[](https://goreportcard.com/report/github.com/nikhilsbhat/gocd-cli)
[](https://github.com/nikhilsbhat/gocd-cli/blob/main/LICENSE)
[](https://godoc.org/github.com/nikhilsbhat/gocd-cli)
[](https://github.com/nikhilsbhat/gocd-cli/tags)
[](https://github.com/nikhilsbhat/gocd-cli/releases)
command-line interface for `GoCD` that helps in interacting with [GoCD](https://www.gocd.org/) server.
## Introduction
While GoCD offers a user interface for performing various tasks, this CLI is designed for administrators responsible for managing GoCD.
It aims to provide CLI-based functionality equivalent to the UI.
This tool communicates with the `GoCD` server's API to perform tasks such as encrypting and decrypting secrets, retrieving lists of pipelines, creating configuration repositories, and more.
This CLI utilizes the GoCD Golang [SDK](https://github.com/nikhilsbhat/gocd-sdk-go). If you encounter a bug with the CLI, it likely originates from the SDK.
## Requirements
* [Go](https://golang.org/dl/) 1.17 or above . Installing go can be found [here](https://golang.org/doc/install).
* Basic understanding of CI/CD server [GoCD](https://www.gocd.org/) and GoCD golang [sdk](https://github.com/nikhilsbhat/gocd-sdk-go).
## Authorization
The authorization configuration for GoCD can be locally cached for future use, streamlining subsequent operations.
The command `auth-config` will do the work.
```shell
# Running the below command should cache configurations under $HOME/.gocd/auth_config.default.yaml.
# Here 'default' is the profile of GoCD. And profile would help in handling multiple GoCD server with same CLI.
# If no profile is set, it defaults to 'default'. The profile can be set using flag '--profile'.
gocd-cli auth-config store --server-url --username --password
# Running below command by setting --profile would save cache under $HOME/.gocd/auth_config.central.yaml.
gocd-cli auth-config store --server-url --username --password --profile central
# User creds cached can be validated using below command.
gocd-cli who-am-i
# The response to the above command should be:
# user: admin
# Once we have authorization configurations cached, we do not need to pass the credentials every time we invoke the cli.
gocd-cli environment list
```
## Update
The `gocd-cli` will display any pending updates in a diff format, similar to how it is commonly done in other CLI tools such as Terraform.

## Documentation
Updated documentation on all available commands and flags can be found [here](https://github.com/nikhilsbhat/gocd-cli/blob/main/docs/doc/gocd-cli.md).
## Installation
* Recommend installing released versions. Release binaries are available on the [releases](https://github.com/nikhilsbhat/gocd-cli/releases) page.
#### Homebrew
Install `gocd-cli` on `macOS`
```shell
brew tap nikshilsbhat/stable git@github.com:nikhilsbhat/homebrew-stable.git
# for latest version
brew install nikshilsbhat/stable/gocd-cli
# for specific version
brew install nikshilsbhat/stable/gocd-cli@0.2.5
```
Check [repo](https://github.com/nikhilsbhat/homebrew-stable) for all available versions of the formula.
#### Docker
Latest version of docker images are published to [ghcr.io](https://github.com/nikhilsbhat/gocd-cli/pkgs/container/gocd-cli), all available images can be found there.
```bash
docker pull ghcr.io/nikhilsbhat/gocd-cli:latest
docker pull ghcr.io/nikhilsbhat/gocd-cli:
```
#### Build from Source
1. Clone the repository:
```sh
git clone https://github.com/nikhilsbhat/gocd-cli.git
cd gocd-cli
```
2. Build the project:
```sh
make local.build
```
### Note
* The `gocd-cli pipeline validate-syntax` command uses the GoCD plugin binary to validate the pipeline's syntax.
* Since the plugins are in JAR format, Java must be installed on the machine where the command will be executed.