/go-jenkins

Go client library for accessing the Jenkins API

Primary LanguageGoBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

go-jenkins

GoDoc Test Coverage Test Status

go-jenkins is a Go client library for accessing the Jenkins API.

❗️❗️❗️ The library is in active development and is not yet ready for use!

Installation

go-jenkins is compatible with modern Go releases in module mode, with Go installed:

go get github.com/yarlson/go-jenkins

Usage

import "github.com/yarlson/go-jenkins/jenkins"	

Example

package main

import (
	"context"
	"fmt"
	"github.com/yarlson/go-jenkins/jenkins"
)

func main() {
	client, err := jenkins.NewClient(
		jenkins.WithBaseURL("http://localhost:8080"),
		jenkins.WithUserPassword("admin", "admin"),
	)
	if err != nil {
		panic(err)
	}

	node, _, err := client.Nodes.Create(context.Background(), &jenkins.Node{
		Name:            "test-node",
		Description: "",
		RemoteFS:        "/var/lib/jenkins",
		NumExecutors:    1,
		Mode:            jenkins.NodeModeExclusive,
		Labels:          []string{"test"},
	})
	if err != nil {
		panic(err)
	}

	fmt.Println(node)
}