Woodpecker CI plugin library
Go to file
woodpecker-bot 2b17135e0c fix(deps): update github.com/urfave/cli/v3 digest to cd7d34a (#32)
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/32
Co-authored-by: woodpecker-bot <woodpecker-bot@obermui.de>
Co-committed-by: woodpecker-bot <woodpecker-bot@obermui.de>
2024-08-26 06:21:25 +00:00
.gitignore Add .gitignore (#28) 2024-07-22 21:37:31 +00:00
.woodpecker.yaml chore(deps): update golangci/golangci-lint docker tag to v1.60 2024-08-19 00:07:48 +00:00
commit.go Migrate to github.com/urfave/cli/v3 (#29) 2024-07-22 23:32:14 +00:00
flags.go Migrate to github.com/urfave/cli/v3 (#29) 2024-07-22 23:32:14 +00:00
flake.lock Add nix flake (#31) 2024-07-22 21:37:09 +00:00
flake.nix Add nix flake (#31) 2024-07-22 21:37:09 +00:00
forge.go Migrate to github.com/urfave/cli/v3 (#29) 2024-07-22 23:32:14 +00:00
go.mod fix(deps): update github.com/urfave/cli/v3 digest to cd7d34a (#32) 2024-08-26 06:21:25 +00:00
go.sum fix(deps): update github.com/urfave/cli/v3 digest to cd7d34a (#32) 2024-08-26 06:21:25 +00:00
http.go Migrate to github.com/urfave/cli/v3 (#29) 2024-07-22 23:32:14 +00:00
LICENSE Initial implementation 2023-01-08 04:53:03 +02:00
logger.go Migrate to github.com/urfave/cli/v3 (#29) 2024-07-22 23:32:14 +00:00
metadata_test.go Migrate to github.com/urfave/cli/v3 (#29) 2024-07-22 23:32:14 +00:00
metadata.go Migrate to github.com/urfave/cli/v3 (#29) 2024-07-22 23:32:14 +00:00
pipeline.go Migrate to github.com/urfave/cli/v3 (#29) 2024-07-22 23:32:14 +00:00
plugin_test.go Migrate to github.com/urfave/cli/v3 (#29) 2024-07-22 23:32:14 +00:00
plugin.go Migrate to github.com/urfave/cli/v3 (#29) 2024-07-22 23:32:14 +00:00
README.md Migrate to github.com/urfave/cli/v3 (#29) 2024-07-22 23:32:14 +00:00
renovate.json Configure Renovate (#4) 2023-10-16 16:52:34 +00:00
repo.go Migrate to github.com/urfave/cli/v3 (#29) 2024-07-22 23:32:14 +00:00
step.go Migrate to github.com/urfave/cli/v3 (#29) 2024-07-22 23:32:14 +00:00
system.go Migrate to github.com/urfave/cli/v3 (#29) 2024-07-22 23:32:14 +00:00

Library for creating Woodpecker CI plugins

Provides basic structure and helpers to load Woodpecker CI environment variables while also supporting reading Drone CI environment variables where available.

Adds logging support based on zerolog library and allows configurable HTTP client library.

Builtin settings

Settings Name Environment variable Default Description
log_level - info Sets log level (panic, fatal, error, warn, info, debug, trace)
skip_verify - false - Skip verification of TLS certificate
SOCKS_PROXY none SOCKS5 proxy to use for connections
SOCKS_PROXY_OFF none Do not use SOCKS5 proxy

Creating plugin

package main

import (
	"context"

	"codeberg.org/woodpecker-plugins/go-plugin"
	"github.com/rs/zerolog/log"
	"github.com/urfave/cli/v3"
)

type Settings struct {
	// TODO: Plugin settings
	SampleFlag string
}

type Plugin struct {
	*plugin.Plugin
	Settings *Settings
}

func (p *Plugin) Flags() []cli.Flag {
	return []cli.Flag{
		// TODO: Add flags
		&cli.StringFlag{
			Name:        "sample.flag",
			Usage:       "sample flag",
			Sources:     cli.EnvVars("PLUGIN_SAMPLE_FLAG"),
			Destination: &p.Settings.SampleFlag,
		},
	}
}

func (p *Plugin) Execute(ctx context.Context) error {
	// TODO: Implement execution
	log.Debug().Msg("executed")
	return nil
}

func main() {
	p := &Plugin{
		Settings: &Settings{},
	}

	p.Plugin = plugin.New(plugin.Options{
		Name:        "sample-plugin",
		Description: "Sample plugin",
		Flags:       p.Flags(),
		Execute:     p.Execute,
	})

	p.Run()
}