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 ¶
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
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
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 ¶
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
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
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
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
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