Giter Club home page Giter Club logo

go-gocd's Introduction

GoCD SDK 0.6.14

Join the chat at https://gitter.im/beamly/go-gocd GoDoc Build Status codecov codebeat badge FOSSA Status

CLI

CLI tool to interface with GoCD Server.

Usage

Installation

Homebrew
brew tap beamly/tap
brew install go-gocd
Manual

Download the latest release from https://github.com/beamly/go-gocd/releases, and place the binary in your $PATH.

Quickstart

$ gocd configure
? GoCD Server (should contain '/go/' suffix) https://my-go-server:8154/go/
? Client Username my_user
? Client Password *****
? Skip SSL certificate validation (y/N) N
$ gocd list-agents

Configuration

The library can either be configured using environment variables, cli flags, or a yaml config file.

Name CLI Flag YAML Environment Variable
GoCD Server (with /go/ suffix) --server server $GOCD_SERVER
Username --username username $GOCD_USERNAME
Password --password password $GOCD_PASSWORD
Skip HTTPS/SSL Certification Check --skip_ssl_check skip_ssl_check $GOCD_SKIP_SSL_CHECK
YAML Config File

Run gocd configure to launch a wizard which will create a file at ~/.gocd.conf, or create the file manually:

default:
  server: https://goserver:8154/go
  username: admin
  password: mypassword
  skip_ssl_check: true
Configuration Profiles

Authentication credentials for multiple gocd servers can be stored by using the --profile flag. Configuration Profiles can be created using:

gocd --profile other-server configure

Which will create a new configuration block in ~/.beamly.conf

Configuration profiles can be used by specifying --profile before your command

gocd --profile other-server list-agents

Help

$ gocd -help

Library

Usage

Construct a new GoCD client and supply the URL to your GoCD server and if required, username and password. Then use the various services on the client to access different parts of the GoCD API. For example:

package main
import (
    "github.com/beamly/go-gocd/gocd"
    "context"
    "fmt"
)

func main() {
    cfg := gocd.Configuration{
        Server: "https://my_gocd/go/",
        Username: "ApiUser",
        Password: "MySecretPassword",
    }

    c := cfg.Client()

    // list all agents in use by the GoCD Server
    var a []*gocd.Agent
    var err error
    var r *gocd.APIResponse
    if a, r, err = c.Agents.List(context.Background()); err != nil {
        if r.HTTP.StatusCode == 404 {
            fmt.Println("Couldn't find agent")
        } else {
        	panic(err)
        }
    }

    fmt.Println(a)
}

If you wish to use your own http client, you can use the following idiom

package main

import (
    "github.com/beamly/go-gocd/gocd"
	"net/http"
    "context"
)

func main() {
    client := gocd.NewClient(
        &gocd.Configuration{},
        &http.Client{},
    )
    client.Login(context.Background())
}

Roadmap

This library is still in pre-release. It was initially developed to be an interface for a gocd terraform provider, which, at this stage, will heavily influence the direction of this library. A list of new features and the expected release schedule for those features can be found in the project for this github repository.

Background

This library's structure was initially inspired by https://github.com/google/go-github. There may still be some vestigial code and structures from this library which will be removed in future revisions and before v1.0.0 of this library.

License

This library is distributed under the Apache 2.0 license found in LICENSE file.

FOSSA Status

go-gocd's People

Contributors

drewsonne avatar aerostitch avatar peterrosell avatar ixalon avatar csghuser avatar fossabot avatar jakowicz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.