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 (
|
2023-12-08 07:15:08 +00:00
|
|
|
"go.woodpecker-ci.org/woodpecker/v2/pipeline/errors"
|
2023-11-03 10:44:03 +00:00
|
|
|
)
|
|
|
|
|
2022-10-18 01:24:12 +00:00
|
|
|
type Pipeline struct {
|
2023-11-03 10:44:03 +00:00
|
|
|
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 []*errors.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"`
|
|
|
|
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"`
|
2023-11-14 16:12:12 +00:00
|
|
|
ForgeURL string `json:"forge_url" xorm:"pipeline_forge_url"`
|
2023-11-03 10:44:03 +00:00
|
|
|
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'"`
|
2023-06-03 19:38:36 +00:00
|
|
|
} // @name Pipeline
|
2015-09-30 01:21:17 +00:00
|
|
|
|
2021-11-13 19:18:06 +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
|
|
|
|
2023-06-27 16:01:18 +00:00
|
|
|
// IsMultiPipeline checks if step list contain more than one parent step
|
|
|
|
func (p Pipeline) IsMultiPipeline() bool {
|
|
|
|
return len(p.Workflows) > 1
|
|
|
|
}
|
|
|
|
|
2022-10-18 01:24:12 +00:00
|
|
|
type UpdatePipelineStore interface {
|
|
|
|
UpdatePipeline(*Pipeline) error
|
2022-06-16 13:35:58 +00:00
|
|
|
}
|
2022-09-27 09:05:00 +00:00
|
|
|
|
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
|