Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyPagination[T any](d *ListOptions, slice []T) []T
- 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 ResourceLimit
- type SCMKind
- type Secret
- type SecretStore
- type ServerConfig
- type StatusValue
- type Step
- type StepType
- type Task
- type Team
- type User
- type WebhookEvent
- type WebhookEventList
- type Workflow
Constants ¶
const ( FailureIgnore = "ignore" FailureFail = "fail" )
Different ways to handle failure states.
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 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"` 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"` } // @name Agent
func (*Agent) IsSystemAgent ¶
type Config ¶
type Config struct { ID int64 `json:"-" xorm:"pk autoincr 'config_id'"` RepoID int64 `json:"-" xorm:"UNIQUE(s) 'config_repo_id'"` Hash string `json:"hash" xorm:"UNIQUE(s) 'config_hash'"` Name string `json:"name" xorm:"UNIQUE(s) 'config_name'"` Data []byte `json:"data" xorm:"LONGBLOB 'config_data'"` } // @name Config
Config represents a pipeline configuration.
type Cron ¶
type Cron struct { ID int64 `json:"id" xorm:"pk autoincr"` Name string `json:"name" xorm:"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"` Schedule string `json:"schedule" xorm:"NOT NULL"` // @weekly, 3min, ... Created int64 `json:"created_at" xorm:"created NOT NULL DEFAULT 0"` Branch string `json:"branch"` } // @name Cron
type Environ ¶
Environ represents an environment variable.
type Feed ¶
type Feed struct { RepoID int64 `json:"repo_id" xorm:"feed_repo_id"` ID int64 `json:"id,omitempty" xorm:"feed_pipeline_id"` Number int64 `json:"number,omitempty" xorm:"feed_pipeline_number"` Event string `json:"event,omitempty" xorm:"feed_pipeline_event"` Status string `json:"status,omitempty" xorm:"feed_pipeline_status"` Created int64 `json:"created_at,omitempty" xorm:"feed_pipeline_created"` Started int64 `json:"started_at,omitempty" xorm:"feed_pipeline_started"` Finished int64 `json:"finished_at,omitempty" xorm:"feed_pipeline_finished"` Commit string `json:"commit,omitempty" xorm:"feed_pipeline_commit"` Branch string `json:"branch,omitempty" xorm:"feed_pipeline_branch"` Ref string `json:"ref,omitempty" xorm:"feed_pipeline_ref"` Refspec string `json:"refspec,omitempty" xorm:"feed_pipeline_refspec"` Title string `json:"title,omitempty" xorm:"feed_pipeline_title"` Message string `json:"message,omitempty" xorm:"feed_pipeline_message"` Author string `json:"author,omitempty" xorm:"feed_pipeline_author"` Avatar string `json:"author_avatar,omitempty" xorm:"feed_pipeline_avatar"` Email string `json:"author_email,omitempty" xorm:"feed_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 `xorm:"pk autoincr 'id'"` Type ForgeType `xorm:"VARCHAR(250)"` URL string `xorm:"VARCHAR(500) 'url'"` Client string `xorm:"VARCHAR(250)"` ClientSecret string `xorm:"VARCHAR(250)"` SkipVerify bool `xorm:"bool"` OAuthHost string `xorm:"VARCHAR(250) 'oauth_host'"` // public url for oauth if different from url AdditionalOptions map[string]any `xorm:"json"` }
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"` Line int `json:"line"` Data []byte `json:"data" xorm:"LONGBLOB"` Created int64 `json:"-" xorm:"created"` Type LogEntryType `json:"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 'perm_user_id'"` RepoID int64 `json:"-" xorm:"UNIQUE(s) INDEX NOT NULL 'perm_repo_id'"` Repo *Repo `json:"-" xorm:"-"` Pull bool `json:"pull" xorm:"perm_pull"` Push bool `json:"push" xorm:"perm_push"` Admin bool `json:"admin" xorm:"perm_admin"` Synced int64 `json:"synced" xorm:"perm_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 'pipeline_id'"` RepoID int64 `json:"-" xorm:"UNIQUE(s) INDEX 'pipeline_repo_id'"` Number int64 `json:"number" xorm:"UNIQUE(s) 'pipeline_number'"` Author string `json:"author" xorm:"INDEX 'pipeline_author'"` Parent int64 `json:"parent" xorm:"pipeline_parent"` Event WebhookEvent `json:"event" xorm:"pipeline_event"` Status StatusValue `json:"status" xorm:"INDEX 'pipeline_status'"` Errors []*types.PipelineError `json:"errors" xorm:"json 'pipeline_errors'"` Created int64 `json:"created_at" xorm:"pipeline_created"` Updated int64 `json:"updated_at" xorm:"updated NOT NULL DEFAULT 0 'updated'"` Started int64 `json:"started_at" xorm:"pipeline_started"` Finished int64 `json:"finished_at" xorm:"pipeline_finished"` Deploy string `json:"deploy_to" xorm:"pipeline_deploy"` DeployTask string `json:"deploy_task" xorm:"pipeline_deploy_task"` Commit string `json:"commit" xorm:"pipeline_commit"` Branch string `json:"branch" xorm:"pipeline_branch"` Ref string `json:"ref" xorm:"pipeline_ref"` Refspec string `json:"refspec" xorm:"pipeline_refspec"` Title string `json:"title" xorm:"pipeline_title"` Message string `json:"message" xorm:"TEXT 'pipeline_message'"` Timestamp int64 `json:"timestamp" xorm:"pipeline_timestamp"` Sender string `json:"sender" xorm:"pipeline_sender"` // uses reported user for webhooks and name of cron for cron pipelines Avatar string `json:"author_avatar" xorm:"pipeline_avatar"` Email string `json:"author_email" xorm:"pipeline_email"` ForgeURL string `json:"forge_url" xorm:"pipeline_forge_url"` Reviewer string `json:"reviewed_by" xorm:"pipeline_reviewer"` Reviewed int64 `json:"reviewed_at" xorm:"pipeline_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.
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 'redirection_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 'registry_id'"` RepoID int64 `json:"-" xorm:"UNIQUE(s) INDEX 'registry_repo_id'"` Address string `json:"address" xorm:"UNIQUE(s) INDEX 'registry_addr'"` Username string `json:"username" xorm:"varchar(2000) 'registry_username'"` Password string `json:"password" xorm:"TEXT 'registry_password'"` } // @name Registry
Registry represents a docker registry with credentials.
type Repo ¶
type Repo struct { ID int64 `json:"id,omitempty" xorm:"pk autoincr 'repo_id'"` UserID int64 `json:"-" xorm:"repo_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:"repo_org_id"` Owner string `json:"owner" xorm:"UNIQUE(name) 'repo_owner'"` Name string `json:"name" xorm:"UNIQUE(name) 'repo_name'"` FullName string `json:"full_name" xorm:"UNIQUE 'repo_full_name'"` Avatar string `json:"avatar_url,omitempty" xorm:"varchar(500) 'repo_avatar'"` ForgeURL string `json:"forge_url,omitempty" xorm:"varchar(1000) 'repo_forge_url'"` Clone string `json:"clone_url,omitempty" xorm:"varchar(1000) 'repo_clone'"` CloneSSH string `json:"clone_url_ssh" xorm:"varchar(1000) 'repo_clone_ssh'"` Branch string `json:"default_branch,omitempty" xorm:"varchar(500) 'repo_branch'"` SCMKind SCMKind `json:"scm,omitempty" xorm:"varchar(50) 'repo_scm'"` PREnabled bool `json:"pr_enabled" xorm:"DEFAULT TRUE 'repo_pr_enabled'"` Timeout int64 `json:"timeout,omitempty" xorm:"repo_timeout"` Visibility RepoVisibility `json:"visibility" xorm:"varchar(10) 'repo_visibility'"` IsSCMPrivate bool `json:"private" xorm:"repo_private"` IsTrusted bool `json:"trusted" xorm:"repo_trusted"` IsGated bool `json:"gated" xorm:"repo_gated"` IsActive bool `json:"active" xorm:"repo_active"` AllowPull bool `json:"allow_pr" xorm:"repo_allow_pr"` AllowDeploy bool `json:"allow_deploy" xorm:"repo_allow_deploy"` Config string `json:"config_file" xorm:"varchar(500) 'repo_config_path'"` Hash string `json:"-" xorm:"varchar(500) 'repo_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"` IsTrusted *bool `json:"trusted,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"` } // @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 ResourceLimit ¶
type ResourceLimit struct { MemSwapLimit int64 MemLimit int64 ShmSize int64 CPUQuota int64 CPUSet string }
ResourceLimit is the resource limit to set on pipeline steps.
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 'secret_id'"` OrgID int64 `json:"org_id" xorm:"NOT NULL DEFAULT 0 UNIQUE(s) INDEX 'secret_org_id'"` RepoID int64 `json:"repo_id" xorm:"NOT NULL DEFAULT 0 UNIQUE(s) INDEX 'secret_repo_id'"` Name string `json:"name" xorm:"NOT NULL UNIQUE(s) INDEX 'secret_name'"` Value string `json:"value,omitempty" xorm:"TEXT 'secret_value'"` Images []string `json:"images" xorm:"json 'secret_images'"` Events []WebhookEvent `json:"events" xorm:"json 'secret_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 ¶
ServerConfig represents a key-value pair for storing server configurations.
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 'step_id'"` UUID string `json:"uuid" xorm:"INDEX 'step_uuid'"` PipelineID int64 `json:"pipeline_id" xorm:"UNIQUE(s) INDEX 'step_pipeline_id'"` PID int `json:"pid" xorm:"UNIQUE(s) 'step_pid'"` PPID int `json:"ppid" xorm:"step_ppid"` Name string `json:"name" xorm:"step_name"` State StatusValue `json:"state" xorm:"step_state"` Error string `json:"error,omitempty" xorm:"TEXT 'step_error'"` Failure string `json:"-" xorm:"step_failure"` ExitCode int `json:"exit_code" xorm:"step_exit_code"` Started int64 `json:"start_time,omitempty" xorm:"step_started"` Stopped int64 `json:"end_time,omitempty" xorm:"step_stopped"` Type StepType `json:"type,omitempty" xorm:"step_type"` } // @name Step
Step represents a process in the pipeline.
type Task ¶
type Task struct { ID string `json:"id" xorm:"PK UNIQUE 'task_id'"` Data []byte `json:"data" xorm:"LONGBLOB 'task_data'"` Labels map[string]string `json:"labels" xorm:"json 'task_labels'"` Dependencies []string `json:"dependencies" xorm:"json 'task_dependencies'"` RunOn []string `json:"run_on" xorm:"json 'task_run_on'"` DepStatus map[string]StatusValue `json:"dep_status" xorm:"json 'task_dep_status'"` AgentID int64 `json:"agent_id" xorm:"'agent_id'"` } // @name Task
Task defines scheduled pipeline Task.
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 User ¶
type User struct { // the id for this user. // // required: true ID int64 `json:"id" xorm:"pk autoincr 'user_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 'user_login'"` // Token is the oauth2 token. Token string `json:"-" xorm:"TEXT 'user_token'"` // Secret is the oauth2 token secret. Secret string `json:"-" xorm:"TEXT 'user_secret'"` // Expiry is the token and secret expiration timestamp. Expiry int64 `json:"-" xorm:"user_expiry"` // Email is the email address for this user. // // required: true Email string `json:"email" xorm:" varchar(500) 'user_email'"` // the avatar url for this user. Avatar string `json:"avatar_url" xorm:" varchar(500) 'user_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:"user_admin"` // Hash is a unique token used to sign tokens. Hash string `json:"-" xorm:"UNIQUE varchar(500) 'user_hash'"` // OrgID is the of the user as model.Org. OrgID int64 `json:"org_id" xorm:"user_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 'workflow_id'"` PipelineID int64 `json:"pipeline_id" xorm:"UNIQUE(s) INDEX 'workflow_pipeline_id'"` PID int `json:"pid" xorm:"UNIQUE(s) 'workflow_pid'"` Name string `json:"name" xorm:"workflow_name"` State StatusValue `json:"state" xorm:"workflow_state"` Error string `json:"error,omitempty" xorm:"TEXT 'workflow_error'"` Started int64 `json:"start_time,omitempty" xorm:"workflow_started"` Stopped int64 `json:"end_time,omitempty" xorm:"workflow_stopped"` AgentID int64 `json:"agent_id,omitempty" xorm:"workflow_agent_id"` Platform string `json:"platform,omitempty" xorm:"workflow_platform"` Environ map[string]string `json:"environ,omitempty" xorm:"json 'workflow_environ'"` AxisID int `json:"-" xorm:"workflow_axis_id"` Children []*Step `json:"children,omitempty" xorm:"-"` }
Workflow represents a workflow in the pipeline.