Add gitlab multi-branch pipeline support

Signed-off-by: rick <rick@jenkins-zh.cn>
This commit is contained in:
rick
2020-11-19 15:23:01 +08:00
parent 75e0cf27e4
commit 3293948b33
9 changed files with 650 additions and 21 deletions

View File

@@ -81,6 +81,15 @@ const (
MultiBranchPipelineType = "multi-branch-pipeline"
)
const (
SourceType_SVN = "svn"
SourceType_Git = "git"
SourceType_SingleSVN = "single_svn"
SourceType_Gitlab = "gitlab"
SourceType_Github = "github"
SourceType_Bitbucket = "bitbucket_server"
)
type NoScmPipeline struct {
Name string `json:"name" description:"name of pipeline"`
Description string `json:"description,omitempty" description:"description of pipeline"`
@@ -100,6 +109,7 @@ type MultiBranchPipeline struct {
SourceType string `json:"source_type" description:"type of scm, such as github/git/svn"`
GitSource *GitSource `json:"git_source,omitempty" description:"git scm define"`
GitHubSource *GithubSource `json:"github_source,omitempty" description:"github scm define"`
GitlabSource *GitlabSource `json:"gitlab_source,omitempty" description:"gitlab scm define"`
SvnSource *SvnSource `json:"svn_source,omitempty" description:"multi branch svn scm define"`
SingleSvnSource *SingleSvnSource `json:"single_svn_source,omitempty" description:"single branch svn scm define"`
BitbucketServerSource *BitbucketServerSource `json:"bitbucket_server_source,omitempty" description:"bitbucket server scm defile"`
@@ -132,6 +142,21 @@ type GithubSource struct {
RegexFilter string `json:"regex_filter,omitempty" mapstructure:"regex_filter" description:"Regex used to match the name of the branch that needs to be run"`
}
type GitlabSource struct {
ScmId string `json:"scm_id,omitempty" description:"uid of scm"`
Owner string `json:"owner,omitempty" mapstructure:"owner" description:"owner of gitlab repo"`
Repo string `json:"repo,omitempty" mapstructure:"repo" description:"repo name of gitlab repo"`
ServerName string `json:"server_name,omitempty" description:"the name of gitlab server which was configured in jenkins"`
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access gitlab source"`
ApiUri string `json:"api_uri,omitempty" mapstructure:"api_uri" description:"The api url can specify the location of the gitlab apiserver.For private cloud configuration"`
DiscoverBranches int `json:"discover_branches,omitempty" mapstructure:"discover_branches" description:"Discover branch configuration"`
DiscoverPRFromOrigin int `json:"discover_pr_from_origin,omitempty" mapstructure:"discover_pr_from_origin" description:"Discover origin PR configuration"`
DiscoverPRFromForks *DiscoverPRFromForks `json:"discover_pr_from_forks,omitempty" mapstructure:"discover_pr_from_forks" description:"Discover fork PR configuration"`
DiscoverTags bool `json:"discover_tags,omitempty" mapstructure:"discover_tags" description:"Discover tags configuration"`
CloneOption *GitCloneOption `json:"git_clone_option,omitempty" mapstructure:"git_clone_option" description:"advavced git clone options"`
RegexFilter string `json:"regex_filter,omitempty" mapstructure:"regex_filter" description:"Regex used to match the name of the branch that needs to be run"`
}
type BitbucketServerSource struct {
ScmId string `json:"scm_id,omitempty" description:"uid of scm"`
Owner string `json:"owner,omitempty" mapstructure:"owner" description:"owner of github repo"`

View File

@@ -228,6 +228,31 @@ func (in *GithubSource) DeepCopy() *GithubSource {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GitlabSource) DeepCopyInto(out *GitlabSource) {
*out = *in
if in.DiscoverPRFromForks != nil {
in, out := &in.DiscoverPRFromForks, &out.DiscoverPRFromForks
*out = new(DiscoverPRFromForks)
**out = **in
}
if in.CloneOption != nil {
in, out := &in.CloneOption, &out.CloneOption
*out = new(GitCloneOption)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitlabSource.
func (in *GitlabSource) DeepCopy() *GitlabSource {
if in == nil {
return nil
}
out := new(GitlabSource)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MultiBranchJobTrigger) DeepCopyInto(out *MultiBranchJobTrigger) {
*out = *in
@@ -266,6 +291,11 @@ func (in *MultiBranchPipeline) DeepCopyInto(out *MultiBranchPipeline) {
*out = new(GithubSource)
(*in).DeepCopyInto(*out)
}
if in.GitlabSource != nil {
in, out := &in.GitlabSource, &out.GitlabSource
*out = new(GitlabSource)
(*in).DeepCopyInto(*out)
}
if in.SvnSource != nil {
in, out := &in.SvnSource, &out.SvnSource
*out = new(SvnSource)