Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyPagination[T any](d *ListOptions, slice []T) []T
- func GenerateNewAgentToken() string
- func IsThereRunningStage(workflows []*Workflow) bool
- func ParseRepo(str string) (user, repo string, err error)
- type Agent
- type Commit
- type Config
- type Cron
- type Environ
- type Event
- type EventType
- type Feed
- type Forge
- type ForgeRemoteID
- type ForgeType
- type ListOptions
- type LogEntry
- type LogEntryType
- type Netrc
- type Org
- type OrgPerm
- type Perm
- type Pipeline
- type PipelineConfig
- type PipelineFilter
- type PipelineOptions
- type PullRequest
- type Redirection
- type Registry
- type Repo
- type RepoPatch
- type RepoVisibility
- type SCMKind
- type Secret
- type SecretStore
- type ServerConfig
- type StatusValue
- type Step
- type StepType
- type Task
- type Team
- type TrustedConfiguration
- type TrustedConfigurationPatch
- type User
- type WebhookEvent
- type WebhookEventList
- type Workflow
Constants ¶
const ( FailureIgnore = "ignore" FailureFail = "fail" )
Different ways to handle failure states.
const (
IDNotSet = -1
)
Variables ¶
var ( ErrSecretNameInvalid = errors.New("invalid secret name") ErrSecretImageInvalid = errors.New("invalid secret image") ErrSecretValueInvalid = errors.New("invalid secret value") ErrSecretEventInvalid = errors.New("invalid secret event") )
var ErrInvalidWebhookEvent = errors.New("invalid webhook event")
Functions ¶
func ApplyPagination ¶
func ApplyPagination[T any](d *ListOptions, slice []T) []T
func GenerateNewAgentToken ¶ added in v2.7.3
func GenerateNewAgentToken() string
func IsThereRunningStage ¶
IsThereRunningStage determine if it contains workflows running or pending to run. TODO: return false based on depends_on (https://github.com/woodpecker-ci/woodpecker/pull/730#discussion_r795681697)
Types ¶
type Agent ¶
type Agent struct { ID int64 `json:"id" xorm:"pk autoincr 'id'"` Created int64 `json:"created" xorm:"created"` Updated int64 `json:"updated" xorm:"updated"` Name string `json:"name" xorm:"name"` OwnerID int64 `json:"owner_id" xorm:"'owner_id'"` Token string `json:"token" xorm:"token"` LastContact int64 `json:"last_contact" xorm:"last_contact"` LastWork int64 `json:"last_work" xorm:"last_work"` // last time the agent did something, this value is used to determine if the agent is still doing work used by the autoscaler Platform string `json:"platform" xorm:"VARCHAR(100) 'platform'"` Backend string `json:"backend" xorm:"VARCHAR(100) 'backend'"` Capacity int32 `json:"capacity" xorm:"capacity"` Version string `json:"version" xorm:"'version'"` NoSchedule bool `json:"no_schedule" xorm:"no_schedule"` CustomLabels map[string]string `json:"custom_labels" xorm:"JSON 'custom_labels'"` // OrgID is counted as unset if set to -1, this is done to ensure a new(Agent) still enforce the OrgID check by default OrgID int64 `json:"org_id" xorm:"INDEX 'org_id'"` } // @name Agent
func (*Agent) CanAccessRepo ¶ added in v2.7.3
func (*Agent) GetServerLabels ¶ added in v2.7.3
func (*Agent) IsSystemAgent ¶
type Config ¶
type Config struct { ID int64 `json:"-" xorm:"pk autoincr 'id'"` RepoID int64 `json:"-" xorm:"UNIQUE(s) 'repo_id'"` Hash string `json:"hash" xorm:"UNIQUE(s) 'hash'"` Name string `json:"name" xorm:"UNIQUE(s) 'name'"` Data []byte `json:"data" xorm:"LONGBLOB 'data'"` } // @name Config
Config represents a pipeline configuration.
type Cron ¶
type Cron struct { ID int64 `json:"id" xorm:"pk autoincr 'id'"` Name string `json:"name" xorm:"name UNIQUE(s) INDEX"` RepoID int64 `json:"repo_id" xorm:"repo_id UNIQUE(s) INDEX"` CreatorID int64 `json:"creator_id" xorm:"creator_id INDEX"` NextExec int64 `json:"next_exec" xorm:"next_exec"` Schedule string `json:"schedule" xorm:"schedule NOT NULL"` // @weekly, 3min, ... Created int64 `json:"created" xorm:"created NOT NULL DEFAULT 0"` Branch string `json:"branch" xorm:"branch"` } // @name Cron
type Environ ¶
Environ represents an environment variable.
type Feed ¶
type Feed struct { RepoID int64 `json:"repo_id" xorm:"repo_id"` ID int64 `json:"id,omitempty" xorm:"pipeline_id"` Number int64 `json:"number,omitempty" xorm:"pipeline_number"` Event string `json:"event,omitempty" xorm:"pipeline_event"` Status string `json:"status,omitempty" xorm:"pipeline_status"` Created int64 `json:"created,omitempty" xorm:"pipeline_created"` Started int64 `json:"started,omitempty" xorm:"pipeline_started"` Finished int64 `json:"finished,omitempty" xorm:"pipeline_finished"` Commit string `json:"commit,omitempty" xorm:"pipeline_commit"` Branch string `json:"branch,omitempty" xorm:"pipeline_branch"` Ref string `json:"ref,omitempty" xorm:"pipeline_ref"` Refspec string `json:"refspec,omitempty" xorm:"pipeline_refspec"` Title string `json:"title,omitempty" xorm:"pipeline_title"` Message string `json:"message,omitempty" xorm:"pipeline_message"` Author string `json:"author,omitempty" xorm:"pipeline_author"` Avatar string `json:"author_avatar,omitempty" xorm:"pipeline_avatar"` Email string `json:"author_email,omitempty" xorm:"pipeline_email"` } // @name Feed
Feed represents an item in the user's feed or timeline.
type Forge ¶ added in v2.5.0
type Forge struct { ID int64 `json:"id" xorm:"pk autoincr 'id'"` Type ForgeType `json:"type" xorm:"VARCHAR(250)"` URL string `json:"url" xorm:"VARCHAR(500) 'url'"` Client string `json:"client,omitempty" xorm:"VARCHAR(250)"` ClientSecret string `json:"-" xorm:"VARCHAR(250)"` // do not expose client secret SkipVerify bool `json:"skip_verify,omitempty" xorm:"bool"` OAuthHost string `json:"oauth_host,omitempty" xorm:"VARCHAR(250) 'oauth_host'"` // public url for oauth if different from url AdditionalOptions map[string]any `json:"additional_options,omitempty" xorm:"json"` } // @name Forge
func (*Forge) PublicCopy ¶ added in v2.7.0
PublicCopy returns a copy of the forge without sensitive information and technical details.
type ForgeRemoteID ¶
type ForgeRemoteID string
func (ForgeRemoteID) IsValid ¶
func (r ForgeRemoteID) IsValid() bool
type ListOptions ¶
type LogEntry ¶
type LogEntry struct { ID int64 `json:"id" xorm:"pk autoincr 'id'"` StepID int64 `json:"step_id" xorm:"INDEX 'step_id'"` Time int64 `json:"time" xorm:"'time'"` Line int `json:"line" xorm:"'line'"` Data []byte `json:"data" xorm:"LONGBLOB"` Created int64 `json:"-" xorm:"created"` Type LogEntryType `json:"type" xorm:"'type'"` } // @name LogEntry
type LogEntryType ¶
type LogEntryType int // @name LogEntryType
LogEntryType identifies the type of line in the logs.
const ( LogEntryStdout LogEntryType = iota LogEntryStderr LogEntryExitCode LogEntryMetadata LogEntryProgress )
type Org ¶
type Org struct { ID int64 `json:"id,omitempty" xorm:"pk autoincr 'id'"` ForgeID int64 `json:"forge_id,omitempty" xorm:"forge_id"` Name string `json:"name" xorm:"UNIQUE 'name'"` IsUser bool `json:"is_user" xorm:"is_user"` // if name lookup has to check for membership or not Private bool `json:"-" xorm:"private"` } // @name Org
Org represents an organization.
type Perm ¶
type Perm struct { UserID int64 `json:"-" xorm:"UNIQUE(s) INDEX NOT NULL 'user_id'"` RepoID int64 `json:"-" xorm:"UNIQUE(s) INDEX NOT NULL 'repo_id'"` Repo *Repo `json:"-" xorm:"-"` Pull bool `json:"pull" xorm:"pull"` Push bool `json:"push" xorm:"push"` Admin bool `json:"admin" xorm:"admin"` Synced int64 `json:"synced" xorm:"synced"` Created int64 `json:"created" xorm:"created"` Updated int64 `json:"updated" xorm:"updated"` } // @name Perm
Perm defines a repository permission for an individual user.
type Pipeline ¶
type Pipeline struct { ID int64 `json:"id" xorm:"pk autoincr 'id'"` RepoID int64 `json:"-" xorm:"UNIQUE(s) INDEX 'repo_id'"` Number int64 `json:"number" xorm:"UNIQUE(s) 'number'"` Author string `json:"author" xorm:"INDEX 'author'"` Parent int64 `json:"parent" xorm:"parent"` Event WebhookEvent `json:"event" xorm:"event"` Status StatusValue `json:"status" xorm:"INDEX 'status'"` Errors []*types.PipelineError `json:"errors" xorm:"json 'errors'"` Created int64 `json:"created" xorm:"'created' NOT NULL DEFAULT 0 created"` Updated int64 `json:"updated" xorm:"'updated' NOT NULL DEFAULT 0 updated"` Started int64 `json:"started" xorm:"started"` Finished int64 `json:"finished" xorm:"finished"` DeployTo string `json:"deploy_to" xorm:"deploy"` DeployTask string `json:"deploy_task" xorm:"deploy_task"` Commit string `json:"commit" xorm:"commit"` Branch string `json:"branch" xorm:"branch"` Ref string `json:"ref" xorm:"ref"` Refspec string `json:"refspec" xorm:"refspec"` Title string `json:"title" xorm:"title"` Message string `json:"message" xorm:"TEXT 'message'"` Timestamp int64 `json:"timestamp" xorm:"'timestamp'"` Sender string `json:"sender" xorm:"sender"` // uses reported user for webhooks and name of cron for cron pipelines Avatar string `json:"author_avatar" xorm:"avatar"` Email string `json:"author_email" xorm:"email"` ForgeURL string `json:"forge_url" xorm:"forge_url"` Reviewer string `json:"reviewed_by" xorm:"reviewer"` Reviewed int64 `json:"reviewed" xorm:"reviewed"` Workflows []*Workflow `json:"workflows,omitempty" xorm:"-"` ChangedFiles []string `json:"changed_files,omitempty" xorm:"LONGTEXT 'changed_files'"` AdditionalVariables map[string]string `json:"variables,omitempty" xorm:"json 'additional_variables'"` PullRequestLabels []string `json:"pr_labels,omitempty" xorm:"json 'pr_labels'"` IsPrerelease bool `json:"is_prerelease,omitempty" xorm:"is_prerelease"` } // @name Pipeline
func (Pipeline) IsMultiPipeline ¶
IsMultiPipeline checks if step list contain more than one parent step.
type PipelineConfig ¶
type PipelineConfig struct { ConfigID int64 `json:"-" xorm:"UNIQUE(s) NOT NULL 'config_id'"` PipelineID int64 `json:"-" xorm:"UNIQUE(s) NOT NULL 'pipeline_id'"` }
PipelineConfig is the n:n relation between Pipeline and Config.
func (PipelineConfig) TableName ¶ added in v2.7.0
func (PipelineConfig) TableName() string
type PipelineFilter ¶ added in v2.5.0
type PipelineOptions ¶
type PullRequest ¶
type PullRequest struct { Index ForgeRemoteID `json:"index"` Title string `json:"title"` } // @name PullRequest
type Redirection ¶
type Redirection struct { ID int64 `xorm:"pk autoincr 'id'"` RepoID int64 `xorm:"'repo_id'"` FullName string `xorm:"UNIQUE INDEX 'repo_full_name'"` }
func (Redirection) TableName ¶
func (r Redirection) TableName() string
type Registry ¶
type Registry struct { ID int64 `json:"id" xorm:"pk autoincr 'id'"` OrgID int64 `json:"org_id" xorm:"NOT NULL DEFAULT 0 UNIQUE(s) INDEX 'org_id'"` RepoID int64 `json:"repo_id" xorm:"NOT NULL DEFAULT 0 UNIQUE(s) INDEX 'repo_id'"` Address string `json:"address" xorm:"NOT NULL UNIQUE(s) INDEX 'address'"` Username string `json:"username" xorm:"varchar(2000) 'username'"` Password string `json:"password" xorm:"TEXT 'password'"` ReadOnly bool `json:"readonly" xorm:"-"` } // @name Registry
Registry represents a docker registry with credentials.
func (Registry) IsOrganization ¶ added in v2.7.0
Organization registry.
func (Registry) IsRepository ¶ added in v2.7.0
Repository registry.
type Repo ¶
type Repo struct { ID int64 `json:"id,omitempty" xorm:"pk autoincr 'id'"` UserID int64 `json:"-" xorm:"INDEX 'user_id'"` ForgeID int64 `json:"forge_id,omitempty" xorm:"forge_id"` // ForgeRemoteID is the unique identifier for the repository on the forge. ForgeRemoteID ForgeRemoteID `json:"forge_remote_id" xorm:"forge_remote_id"` OrgID int64 `json:"org_id" xorm:"INDEX 'org_id'"` Owner string `json:"owner" xorm:"UNIQUE(name) 'owner'"` Name string `json:"name" xorm:"UNIQUE(name) 'name'"` FullName string `json:"full_name" xorm:"UNIQUE 'full_name'"` Avatar string `json:"avatar_url,omitempty" xorm:"varchar(500) 'avatar'"` ForgeURL string `json:"forge_url,omitempty" xorm:"varchar(1000) 'forge_url'"` Clone string `json:"clone_url,omitempty" xorm:"varchar(1000) 'clone'"` CloneSSH string `json:"clone_url_ssh" xorm:"varchar(1000) 'clone_ssh'"` Branch string `json:"default_branch,omitempty" xorm:"varchar(500) 'branch'"` SCMKind SCMKind `json:"scm,omitempty" xorm:"varchar(50) 'scm'"` PREnabled bool `json:"pr_enabled" xorm:"DEFAULT TRUE 'pr_enabled'"` Timeout int64 `json:"timeout,omitempty" xorm:"timeout"` Visibility RepoVisibility `json:"visibility" xorm:"varchar(10) 'visibility'"` IsSCMPrivate bool `json:"private" xorm:"private"` Trusted TrustedConfiguration `json:"trusted" xorm:"json 'trusted'"` IsGated bool `json:"gated" xorm:"gated"` IsActive bool `json:"active" xorm:"active"` AllowPull bool `json:"allow_pr" xorm:"allow_pr"` AllowDeploy bool `json:"allow_deploy" xorm:"allow_deploy"` Config string `json:"config_file" xorm:"varchar(500) 'config_path'"` Hash string `json:"-" xorm:"varchar(500) 'hash'"` Perm *Perm `json:"-" xorm:"-"` CancelPreviousPipelineEvents []WebhookEvent `json:"cancel_previous_pipeline_events" xorm:"json 'cancel_previous_pipeline_events'"` NetrcOnlyTrusted bool `json:"netrc_only_trusted" xorm:"NOT NULL DEFAULT true 'netrc_only_trusted'"` } // @name Repo
Repo represents a repository.
func (*Repo) ResetVisibility ¶
func (r *Repo) ResetVisibility()
type RepoPatch ¶
type RepoPatch struct { Config *string `json:"config_file,omitempty"` IsGated *bool `json:"gated,omitempty"` Timeout *int64 `json:"timeout,omitempty"` Visibility *string `json:"visibility,omitempty"` AllowPull *bool `json:"allow_pr,omitempty"` AllowDeploy *bool `json:"allow_deploy,omitempty"` CancelPreviousPipelineEvents *[]WebhookEvent `json:"cancel_previous_pipeline_events"` NetrcOnlyTrusted *bool `json:"netrc_only_trusted"` Trusted *TrustedConfigurationPatch `json:"trusted"` } // @name RepoPatch
RepoPatch represents a repository patch object.
type RepoVisibility ¶
type RepoVisibility string // @name RepoVisibility
RepoVisibility represent to what state a repo in woodpecker is visible to others.
const ( VisibilityPublic RepoVisibility = "public" VisibilityPrivate RepoVisibility = "private" VisibilityInternal RepoVisibility = "internal" )
type SCMKind ¶
type SCMKind string // @name SCMKind
SCMKind represent different version control systems.
type Secret ¶
type Secret struct { ID int64 `json:"id" xorm:"pk autoincr 'id'"` OrgID int64 `json:"org_id" xorm:"NOT NULL DEFAULT 0 UNIQUE(s) INDEX 'org_id'"` RepoID int64 `json:"repo_id" xorm:"NOT NULL DEFAULT 0 UNIQUE(s) INDEX 'repo_id'"` Name string `json:"name" xorm:"NOT NULL UNIQUE(s) INDEX 'name'"` Value string `json:"value,omitempty" xorm:"TEXT 'value'"` Images []string `json:"images" xorm:"json 'images'"` Events []WebhookEvent `json:"events" xorm:"json 'events'"` } // @name Secret
Secret represents a secret variable, such as a password or token.
func (*Secret) BeforeInsert ¶
func (s *Secret) BeforeInsert()
BeforeInsert will sort events before inserted into database.
type SecretStore ¶
type SecretStore interface { SecretFind(*Repo, string) (*Secret, error) SecretList(*Repo, bool, *ListOptions) ([]*Secret, error) SecretCreate(*Secret) error SecretUpdate(*Secret) error SecretDelete(*Secret) error OrgSecretFind(int64, string) (*Secret, error) OrgSecretList(int64, *ListOptions) ([]*Secret, error) GlobalSecretFind(string) (*Secret, error) GlobalSecretList(*ListOptions) ([]*Secret, error) SecretListAll() ([]*Secret, error) }
SecretStore persists secret information to storage.
type ServerConfig ¶
type ServerConfig struct { Key string `json:"key" xorm:"pk 'key'"` Value string `json:"value" xorm:"value"` }
ServerConfig represents a key-value pair for storing server configurations.
func (ServerConfig) TableName ¶ added in v2.7.0
func (ServerConfig) TableName() string
TableName return database table name for xorm.
type StatusValue ¶
type StatusValue string // @name StatusValue
StatusValue represent pipeline states woodpecker know.
const ( StatusSkipped StatusValue = "skipped" // skipped as another step failed StatusPending StatusValue = "pending" // pending to be executed StatusRunning StatusValue = "running" // currently running StatusSuccess StatusValue = "success" // successfully finished StatusFailure StatusValue = "failure" // failed to finish (exit code != 0) StatusKilled StatusValue = "killed" // killed by user StatusError StatusValue = "error" // error with the config / while parsing / some other system problem StatusBlocked StatusValue = "blocked" // waiting for approval StatusDeclined StatusValue = "declined" // blocked and declined StatusCreated StatusValue = "created" // created / internal use only )
func PipelineStatus ¶
func PipelineStatus(workflows []*Workflow) StatusValue
PipelineStatus determine pipeline status based on corresponding workflow list.
func WorkflowStatus ¶
func WorkflowStatus(steps []*Step) StatusValue
WorkflowStatus determine workflow status based on corresponding step list.
type Step ¶
type Step struct { ID int64 `json:"id" xorm:"pk autoincr 'id'"` UUID string `json:"uuid" xorm:"INDEX 'uuid'"` PipelineID int64 `json:"pipeline_id" xorm:"UNIQUE(s) INDEX 'pipeline_id'"` PID int `json:"pid" xorm:"UNIQUE(s) 'pid'"` PPID int `json:"ppid" xorm:"ppid"` Name string `json:"name" xorm:"name"` State StatusValue `json:"state" xorm:"state"` Error string `json:"error,omitempty" xorm:"TEXT 'error'"` Failure string `json:"-" xorm:"failure"` ExitCode int `json:"exit_code" xorm:"exit_code"` Started int64 `json:"started,omitempty" xorm:"started"` Finished int64 `json:"finished,omitempty" xorm:"finished"` Type StepType `json:"type,omitempty" xorm:"type"` } // @name Step
Step represents a process in the pipeline.
type Task ¶
type Task struct { ID string `json:"id" xorm:"PK UNIQUE 'id'"` Data []byte `json:"-" xorm:"LONGBLOB 'data'"` Labels map[string]string `json:"labels" xorm:"json 'labels'"` Dependencies []string `json:"dependencies" xorm:"json 'dependencies'"` RunOn []string `json:"run_on" xorm:"json 'run_on'"` DepStatus map[string]StatusValue `json:"dep_status" xorm:"json 'dependencies_status'"` AgentID int64 `json:"agent_id" xorm:"'agent_id'"` } // @name Task
Task defines scheduled pipeline Task.
func (*Task) ApplyLabelsFromRepo ¶ added in v2.7.3
type Team ¶
type Team struct { // Login is the username for this team. Login string `json:"login"` // the avatar url for this team. Avatar string `json:"avatar_url"` }
Team represents a team or organization in the forge.
type TrustedConfiguration ¶ added in v2.7.3
type TrustedConfigurationPatch ¶ added in v2.7.3
type User ¶
type User struct { // the id for this user. // // required: true ID int64 `json:"id" xorm:"pk autoincr 'id'"` ForgeID int64 `json:"forge_id,omitempty" xorm:"forge_id"` ForgeRemoteID ForgeRemoteID `json:"-" xorm:"forge_remote_id"` // Login is the username for this user. // // required: true Login string `json:"login" xorm:"UNIQUE 'login'"` // Token is the oauth2 token. Token string `json:"-" xorm:"TEXT 'token'"` // Secret is the oauth2 token secret. Secret string `json:"-" xorm:"TEXT 'secret'"` // Expiry is the token and secret expiration timestamp. Expiry int64 `json:"-" xorm:"expiry"` // Email is the email address for this user. // // required: true Email string `json:"email" xorm:" varchar(500) 'email'"` // the avatar url for this user. Avatar string `json:"avatar_url" xorm:" varchar(500) 'avatar'"` // Admin indicates the user is a system administrator. // // NOTE: If the username is part of the WOODPECKER_ADMIN // environment variable, this value will be set to true on login. Admin bool `json:"admin,omitempty" xorm:"admin"` // Hash is a unique token used to sign tokens. Hash string `json:"-" xorm:"UNIQUE varchar(500) 'hash'"` // OrgID is the of the user as model.Org. OrgID int64 `json:"org_id" xorm:"org_id"` } // @name User
User represents a registered user.
type WebhookEvent ¶
type WebhookEvent string // @name WebhookEvent
const ( EventPush WebhookEvent = "push" EventPull WebhookEvent = "pull_request" EventPullClosed WebhookEvent = "pull_request_closed" EventTag WebhookEvent = "tag" EventRelease WebhookEvent = "release" EventDeploy WebhookEvent = "deployment" EventCron WebhookEvent = "cron" EventManual WebhookEvent = "manual" )
func (WebhookEvent) Validate ¶ added in v2.3.0
func (s WebhookEvent) Validate() error
type WebhookEventList ¶
type WebhookEventList []WebhookEvent
func (WebhookEventList) Len ¶
func (wel WebhookEventList) Len() int
func (WebhookEventList) Less ¶
func (wel WebhookEventList) Less(i, j int) bool
func (WebhookEventList) Swap ¶
func (wel WebhookEventList) Swap(i, j int)
type Workflow ¶
type Workflow struct { ID int64 `json:"id" xorm:"pk autoincr 'id'"` PipelineID int64 `json:"pipeline_id" xorm:"UNIQUE(s) INDEX 'pipeline_id'"` PID int `json:"pid" xorm:"UNIQUE(s) 'pid'"` Name string `json:"name" xorm:"name"` State StatusValue `json:"state" xorm:"state"` Error string `json:"error,omitempty" xorm:"TEXT 'error'"` Started int64 `json:"started,omitempty" xorm:"started"` Finished int64 `json:"finished,omitempty" xorm:"finished"` AgentID int64 `json:"agent_id,omitempty" xorm:"agent_id"` Platform string `json:"platform,omitempty" xorm:"platform"` Environ map[string]string `json:"environ,omitempty" xorm:"json 'environ'"` AxisID int `json:"-" xorm:"axis_id"` Children []*Step `json:"children,omitempty" xorm:"-"` }
Workflow represents a workflow in the pipeline.