ci

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvailableFormatters

func AvailableFormatters() []string

AvailableFormatters returns the list of available formatter names

func VariableNames

func VariableNames(prefix string) map[string]string

VariableNames returns the standard variable names with optional prefix

Types

type AzureFormatter

type AzureFormatter struct{}

AzureFormatter outputs variables for Azure DevOps Uses ##vso[task.setvariable] format

func (*AzureFormatter) Format

func (f *AzureFormatter) Format(vars map[string]string) string

Format returns Azure DevOps variable commands

func (*AzureFormatter) Name

func (f *AzureFormatter) Name() string

Name returns the formatter name

func (*AzureFormatter) Write

func (f *AzureFormatter) Write(vars map[string]string, w io.Writer) error

Write writes the Azure DevOps commands to the writer

type CircleCIFormatter

type CircleCIFormatter struct{}

CircleCIFormatter outputs variables for CircleCI Appends to $BASH_ENV for environment persistence

func (*CircleCIFormatter) Format

func (f *CircleCIFormatter) Format(vars map[string]string) string

Format returns shell export statements (same as shell formatter)

func (*CircleCIFormatter) Name

func (f *CircleCIFormatter) Name() string

Name returns the formatter name

func (*CircleCIFormatter) Write

func (f *CircleCIFormatter) Write(vars map[string]string, w io.Writer) error

Write appends to BASH_ENV if available, otherwise writes to the provided writer

type Environment

type Environment string

Environment represents a detected CI/CD platform

const (
	EnvNone          Environment = "none"
	EnvGitHubActions Environment = "github"
	EnvGitLabCI      Environment = "gitlab"
	EnvAzureDevOps   Environment = "azure"
	EnvCircleCI      Environment = "circleci"
	EnvJenkins       Environment = "jenkins"
	EnvGeneric       Environment = "shell"
)

func Detect

func Detect() Environment

Detect returns the current CI environment based on environment variables

func (Environment) String

func (e Environment) String() string

String returns the string representation of the environment

type Formatter

type Formatter interface {
	// Name returns the formatter name
	Name() string

	// Format returns the formatted output as a string
	Format(vars map[string]string) string

	// Write writes the variables to the appropriate destination
	// For most CIs, this writes to specific files or stdout
	Write(vars map[string]string, w io.Writer) error
}

Formatter defines the interface for CI-specific output

func GetFormatter

func GetFormatter(env Environment) Formatter

GetFormatter returns the appropriate formatter for the environment

func GetFormatterByName

func GetFormatterByName(name string) (Formatter, error)

GetFormatterByName returns a formatter by name

type GitHubFormatter

type GitHubFormatter struct{}

GitHubFormatter outputs variables for GitHub Actions Writes to $GITHUB_OUTPUT and $GITHUB_ENV files

func (*GitHubFormatter) Format

func (f *GitHubFormatter) Format(vars map[string]string) string

Format returns the formatted output (for display purposes)

func (*GitHubFormatter) Name

func (f *GitHubFormatter) Name() string

Name returns the formatter name

func (*GitHubFormatter) Write

func (f *GitHubFormatter) Write(vars map[string]string, w io.Writer) error

Write writes variables to GITHUB_OUTPUT and GITHUB_ENV files

type GitLabFormatter

type GitLabFormatter struct{}

GitLabFormatter outputs variables for GitLab CI Uses dotenv format for artifacts or echo for job-level variables

func (*GitLabFormatter) Format

func (f *GitLabFormatter) Format(vars map[string]string) string

Format returns dotenv format output

func (*GitLabFormatter) Name

func (f *GitLabFormatter) Name() string

Name returns the formatter name

func (*GitLabFormatter) Write

func (f *GitLabFormatter) Write(vars map[string]string, w io.Writer) error

Write writes the dotenv format to the writer

type JenkinsFormatter

type JenkinsFormatter struct{}

JenkinsFormatter outputs variables in properties file format Can be used with EnvInject plugin or properties file

func (*JenkinsFormatter) Format

func (f *JenkinsFormatter) Format(vars map[string]string) string

Format returns properties file format (KEY=value)

func (*JenkinsFormatter) Name

func (f *JenkinsFormatter) Name() string

Name returns the formatter name

func (*JenkinsFormatter) Write

func (f *JenkinsFormatter) Write(vars map[string]string, w io.Writer) error

Write writes the properties format to the writer

type ShellFormatter

type ShellFormatter struct{}

ShellFormatter outputs shell export statements

func (*ShellFormatter) Format

func (f *ShellFormatter) Format(vars map[string]string) string

Format returns shell export statements

func (*ShellFormatter) Name

func (f *ShellFormatter) Name() string

Name returns the formatter name

func (*ShellFormatter) Write

func (f *ShellFormatter) Write(vars map[string]string, w io.Writer) error

Write writes the shell exports to the writer

type Variables

type Variables struct {
	Version       string // Full version string (e.g., "v1.2.3" or "1.2.3-alpha+build")
	VersionSemver string // SemVer without prefix (e.g., "1.2.3-alpha")
	VersionCore   string // Core version only (e.g., "1.2.3")
	Major         string // Major version
	Minor         string // Minor version
	Patch         string // Patch version
	Revision      string // Revision (4th component, may be empty)
	PreRelease    string // Pre-release identifier (may be empty)
	Metadata      string // Build metadata (may be empty)
	GitSHA        string // Full commit SHA
	GitSHAShort   string // Short commit SHA (7 chars)
	GitBranch     string // Current branch name
	BuildNumber   string // Commits since last tag
	Dirty         string // "true" if uncommitted changes, "false" otherwise
}

Variables defines the standard set of version variables to export

func (*Variables) ToMap

func (v *Variables) ToMap(prefix string) map[string]string

ToMap converts Variables to a map with the given prefix

Jump to

Keyboard shortcuts

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