build.go 4.0 KB
Newer Older
R
runzexia 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
package devops

const (
	LastBuild             = "lastBuild"
	LastCompletedBuild    = "lastCompletedBuild"
	LastFailedBuild       = "lastFailedBuild"
	LastStableBuild       = "lastStableBuild"
	LastSuccessfulBuild   = "lastSuccessfulBuild"
	LastUnstableBuild     = "lastUnstableBuild"
	LastUnsuccessfulBuild = "lastUnsuccessfulBuild"
	FirstBuild            = "firstBuild"
)

type GeneralParameter struct {
	Name  string
	Value string
}

type Branch struct {
	SHA1 string `json:",omitempty"`
	Name string `json:",omitempty"`
}

type BuildRevision struct {
	SHA1   string   `json:"SHA1,omitempty"`
	Branch []Branch `json:"Branch,omitempty"`
}

type Builds struct {
	BuildNumber int64         `json:"buildNumber"`
	BuildResult interface{}   `json:"buildResult"`
	Marked      BuildRevision `json:"marked"`
	Revision    BuildRevision `json:"revision"`
}

type Culprit struct {
	AbsoluteUrl string
	FullName    string
}

type GeneralAction struct {
	Parameters         []GeneralParameter       `json:"parameters,omitempty"`
	Causes             []map[string]interface{} `json:"causes,omitempty"`
	BuildsByBranchName map[string]Builds        `json:"buildsByBranchName,omitempty"`
	LastBuiltRevision  *BuildRevision           `json:"lastBuiltRevision,omitempty"`
	RemoteUrls         []string                 `json:"remoteUrls,omitempty"`
	ScmName            string                   `json:"scmName,omitempty"`
	Subdir             interface{}              `json:"subdir,omitempty"`
	ClassName          string                   `json:"_class,omitempty"`
	SonarTaskId        string                   `json:"ceTaskId,omitempty"`
	SonarServerUrl     string                   `json:"serverUrl,omitempty"`
	SonarDashboardUrl  string                   `json:"sonarqubeDashboardUrl,omitempty"`
	TotalCount         int64                    `json:",omitempty"`
	UrlName            string                   `json:",omitempty"`
}

type Build struct {
	Actions   []GeneralAction
	Artifacts []struct {
		DisplayPath  string `json:"displayPath"`
		FileName     string `json:"fileName"`
		RelativePath string `json:"relativePath"`
	} `json:"artifacts"`
	Building  bool   `json:"building"`
	BuiltOn   string `json:"builtOn"`
	ChangeSet struct {
		Items []struct {
			AffectedPaths []string `json:"affectedPaths"`
			Author        struct {
				AbsoluteUrl string `json:"absoluteUrl"`
				FullName    string `json:"fullName"`
			} `json:"author"`
			Comment  string `json:"comment"`
			CommitID string `json:"commitId"`
			Date     string `json:"date"`
			ID       string `json:"id"`
			Msg      string `json:"msg"`
			Paths    []struct {
				EditType string `json:"editType"`
				File     string `json:"file"`
			} `json:"paths"`
			Timestamp int64 `json:"timestamp"`
		} `json:"items"`
		Kind      string `json:"kind"`
		Revisions []struct {
			Module   string
			Revision int
		} `json:"revision"`
	} `json:"changeSet"`
	Culprits          []Culprit   `json:"culprits"`
	Description       interface{} `json:"description"`
	Duration          int64       `json:"duration"`
	EstimatedDuration int64       `json:"estimatedDuration"`
	Executor          interface{} `json:"executor"`
	FullDisplayName   string      `json:"fullDisplayName"`
	ID                string      `json:"id"`
	KeepLog           bool        `json:"keepLog"`
	Number            int64       `json:"number"`
	QueueID           int64       `json:"queueId"`
	Result            string      `json:"result"`
	Timestamp         int64       `json:"timestamp"`
	URL               string      `json:"url"`
	Runs              []struct {
		Number int64
		URL    string
	} `json:"runs"`
}

type BuildGetter interface {
	// GetProjectPipelineBuildByType get the last build of the pipeline, status can specify the status of the last build.
	GetProjectPipelineBuildByType(projectId, pipelineId string, status string) (*Build, error)

	// GetMultiBranchPipelineBuildByType get the last build of the pipeline, status can specify the status of the last build.
	GetMultiBranchPipelineBuildByType(projectId, pipelineId, branch string, status string) (*Build, error)
}