woodpecker-go/

directory
v2.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2024 License: Apache-2.0, Apache-2.0

README

woodpecker-go

import (
  "go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
  "golang.org/x/oauth2"
)

const (
  token = "dummyToken"
  host  = "http://woodpecker.company.tld"
)

func main() {
  // create an http client with oauth authentication.
  config := new(oauth2.Config)
  authenticator := config.Client(
    oauth2.NoContext,
    &oauth2.Token{
      AccessToken: token,
    },
  )

  // create the woodpecker client with authenticator
  client := woodpecker.NewClient(host, authenticator)

  // gets the current user
  user, err := client.Self()
  fmt.Println(user, err)

  // gets the named repository information
  repo, err := client.RepoLookup("woodpecker-ci/woodpecker")
  fmt.Println(repo, err)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL