2021-11-13 19:18:06 +00:00
|
|
|
// Copyright 2021 Woodpecker Authors
|
2018-02-19 22:24:10 +00:00
|
|
|
// Copyright 2018 Drone.IO Inc.
|
2018-03-21 13:02:17 +00:00
|
|
|
//
|
2018-02-19 22:24:10 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
2018-03-21 13:02:17 +00:00
|
|
|
//
|
2018-02-19 22:24:10 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2018-03-21 13:02:17 +00:00
|
|
|
//
|
2018-02-19 22:24:10 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2015-09-30 01:21:17 +00:00
|
|
|
package model
|
|
|
|
|
2023-11-03 10:44:03 +00:00
|
|
|
import (
|
2024-04-15 08:04:21 +00:00
|
|
|
"go.woodpecker-ci.org/woodpecker/v2/pipeline/errors/types"
|
2023-11-03 10:44:03 +00:00
|
|
|
)
|
|
|
|
|
2022-10-18 01:24:12 +00:00
|
|
|
type Pipeline struct {
|
2024-06-27 07:32:06 +00:00
|
|
|
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_at" xorm:"'created' NOT NULL DEFAULT 0 created"` // TODO change JSON field to "created" in 3.0
|
|
|
|
Updated int64 `json:"updated_at" xorm:"'updated' NOT NULL DEFAULT 0 updated"` // TODO change JSON field to "updated" in 3.0
|
|
|
|
Started int64 `json:"started_at" xorm:"started"` // TODO change JSON field to "started" in 3.0
|
|
|
|
Finished int64 `json:"finished_at" xorm:"finished"` // TODO change JSON field to "finished" in 3.0
|
|
|
|
Deploy 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_at" xorm:"reviewed"` // TODO change JSON field to "reviewed" in 3.0
|
2024-04-15 08:04:21 +00:00
|
|
|
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'"`
|
2024-06-27 07:32:06 +00:00
|
|
|
IsPrerelease bool `json:"is_prerelease,omitempty" xorm:"is_prerelease"`
|
2023-06-03 19:38:36 +00:00
|
|
|
} // @name Pipeline
|
2015-09-30 01:21:17 +00:00
|
|
|
|
2024-05-13 20:58:21 +00:00
|
|
|
// TableName return database table name for xorm.
|
2022-10-18 01:24:12 +00:00
|
|
|
func (Pipeline) TableName() string {
|
|
|
|
return "pipelines"
|
2015-09-30 01:21:17 +00:00
|
|
|
}
|
2022-06-16 13:35:58 +00:00
|
|
|
|
2024-06-27 07:32:06 +00:00
|
|
|
type PipelineFilter struct {
|
|
|
|
Before int64
|
|
|
|
After int64
|
|
|
|
}
|
|
|
|
|
2024-05-13 20:58:21 +00:00
|
|
|
// IsMultiPipeline checks if step list contain more than one parent step.
|
2023-06-27 16:01:18 +00:00
|
|
|
func (p Pipeline) IsMultiPipeline() bool {
|
|
|
|
return len(p.Workflows) > 1
|
|
|
|
}
|
|
|
|
|
2022-10-18 01:24:12 +00:00
|
|
|
type PipelineOptions struct {
|
2022-09-27 09:05:00 +00:00
|
|
|
Branch string `json:"branch"`
|
|
|
|
Variables map[string]string `json:"variables"`
|
2023-06-03 19:38:36 +00:00
|
|
|
} // @name PipelineOptions
|