mirror of
https://codeberg.org/woodpecker-plugins/go-plugin
synced 2026-06-04 18:23:54 +08:00
92ff2797fa6b3d00d0ff5bec13205e9b3482618f
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/6 Co-authored-by: pat-s <patrick.schratz@gmail.com> Co-committed-by: pat-s <patrick.schratz@gmail.com>
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 |
- |
SOCKS_PROXY |
none | SOCKS5 proxy to use for connections | |
SOCKS_PROXY_OFF |
none | Do not use SOCKS5 proxy |
Creating plugin
import (
"context"
"codeberg.org/woodpecker-plugins/go-plugin"
"github.com/urfave/cli/v2"
"github.com/rs/zerolog/log"
)
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",
EnvVars: []string{"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{}
}
p.Plugin = plugin.New(Options{
Name: "sample-plugin",
Description: "Sample plugin",
Flags: p.Flags(),
Execute: p.Execute,
})
p.Run()
}
Description
Languages
Go
97%
Makefile
2%
Nix
1%