@@ -1,7 +1,10 @@
|
||||
package fake
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/emicklei/go-restful"
|
||||
"io/ioutil"
|
||||
devopsv1alpha3 "kubesphere.io/kubesphere/pkg/apis/devops/v1alpha3"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/devops"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -12,30 +15,49 @@ type Devops struct {
|
||||
Data map[string]interface{}
|
||||
|
||||
Projects map[string]interface{}
|
||||
|
||||
Pipelines map[string]map[string]*devopsv1alpha3.Pipeline
|
||||
}
|
||||
|
||||
func New(projects ...string) *Devops {
|
||||
d := &Devops{
|
||||
Data: nil,
|
||||
Projects: map[string]interface{}{},
|
||||
Data: nil,
|
||||
Projects: map[string]interface{}{},
|
||||
Pipelines: map[string]map[string]*devopsv1alpha3.Pipeline{},
|
||||
}
|
||||
for _, p := range projects {
|
||||
d.Projects[p] = true
|
||||
}
|
||||
return d
|
||||
}
|
||||
func NewWithPipelines(project string, pipelines ...*devopsv1alpha3.Pipeline) *Devops {
|
||||
d := &Devops{
|
||||
Data: nil,
|
||||
Projects: map[string]interface{}{},
|
||||
Pipelines: map[string]map[string]*devopsv1alpha3.Pipeline{},
|
||||
}
|
||||
|
||||
d.Projects[project] = true
|
||||
d.Pipelines[project] = map[string]*devopsv1alpha3.Pipeline{}
|
||||
for _, f := range pipelines {
|
||||
d.Pipelines[project][f.Name] = f
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *Devops) CreateDevOpsProject(projectId string) (string, error) {
|
||||
if _, ok := d.Projects[projectId]; ok {
|
||||
return projectId, nil
|
||||
}
|
||||
d.Projects[projectId] = true
|
||||
d.Pipelines[projectId] = map[string]*devopsv1alpha3.Pipeline{}
|
||||
return projectId, nil
|
||||
}
|
||||
|
||||
func (d *Devops) DeleteDevOpsProject(projectId string) error {
|
||||
if _, ok := d.Projects[projectId]; ok {
|
||||
delete(d.Projects, projectId)
|
||||
delete(d.Pipelines, projectId)
|
||||
return nil
|
||||
} else {
|
||||
return &devops.ErrorResponse{
|
||||
@@ -276,15 +298,122 @@ func (d *Devops) DeleteProjectMember(membership *devops.ProjectMembership) (*dev
|
||||
}
|
||||
|
||||
// ProjectPipelineOperator
|
||||
func (d *Devops) CreateProjectPipeline(projectId string, pipeline *devops.ProjectPipeline) (string, error) {
|
||||
func (d *Devops) CreateProjectPipeline(projectId string, pipeline *devopsv1alpha3.Pipeline) (string, error) {
|
||||
if _, ok := d.Pipelines[projectId][pipeline.Name]; ok {
|
||||
err := fmt.Errorf("pipeline name [%s] has been used", pipeline.Name)
|
||||
return "", restful.NewError(http.StatusConflict, err.Error())
|
||||
}
|
||||
d.Pipelines[projectId][pipeline.Name] = pipeline
|
||||
return "", nil
|
||||
}
|
||||
func (d *Devops) DeleteProjectPipeline(projectId string, pipelineId string) (string, error) {
|
||||
if _, ok := d.Pipelines[projectId][pipelineId]; !ok {
|
||||
err := &devops.ErrorResponse{
|
||||
Body: []byte{},
|
||||
Response: &http.Response{
|
||||
Status: "404 Not Found",
|
||||
StatusCode: 404,
|
||||
Proto: "HTTP/1.1",
|
||||
ProtoMajor: 1,
|
||||
ProtoMinor: 1,
|
||||
ContentLength: 50,
|
||||
Header: http.Header{
|
||||
"Foo": []string{"Bar"},
|
||||
},
|
||||
Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Request: &http.Request{
|
||||
Method: "",
|
||||
URL: &url.URL{
|
||||
Scheme: "",
|
||||
Opaque: "",
|
||||
User: nil,
|
||||
Host: "",
|
||||
Path: "",
|
||||
RawPath: "",
|
||||
ForceQuery: false,
|
||||
RawQuery: "",
|
||||
Fragment: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
Message: "",
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
delete(d.Pipelines[projectId], pipelineId)
|
||||
return "", nil
|
||||
}
|
||||
func (d *Devops) UpdateProjectPipeline(projectId string, pipeline *devops.ProjectPipeline) (string, error) {
|
||||
func (d *Devops) UpdateProjectPipeline(projectId string, pipeline *devopsv1alpha3.Pipeline) (string, error) {
|
||||
if _, ok := d.Pipelines[projectId][pipeline.Name]; !ok {
|
||||
err := &devops.ErrorResponse{
|
||||
Body: []byte{},
|
||||
Response: &http.Response{
|
||||
Status: "404 Not Found",
|
||||
StatusCode: 404,
|
||||
Proto: "HTTP/1.1",
|
||||
ProtoMajor: 1,
|
||||
ProtoMinor: 1,
|
||||
ContentLength: 50,
|
||||
Header: http.Header{
|
||||
"Foo": []string{"Bar"},
|
||||
},
|
||||
Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Request: &http.Request{
|
||||
Method: "",
|
||||
URL: &url.URL{
|
||||
Scheme: "",
|
||||
Opaque: "",
|
||||
User: nil,
|
||||
Host: "",
|
||||
Path: "",
|
||||
RawPath: "",
|
||||
ForceQuery: false,
|
||||
RawQuery: "",
|
||||
Fragment: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
Message: "",
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
d.Pipelines[projectId][pipeline.Name] = pipeline
|
||||
return "", nil
|
||||
}
|
||||
func (d *Devops) GetProjectPipelineConfig(projectId, pipelineId string) (*devops.ProjectPipeline, error) {
|
||||
return nil, nil
|
||||
func (d *Devops) GetProjectPipelineConfig(projectId, pipelineId string) (*devopsv1alpha3.Pipeline, error) {
|
||||
if _, ok := d.Pipelines[projectId][pipelineId]; !ok {
|
||||
err := &devops.ErrorResponse{
|
||||
Body: []byte{},
|
||||
Response: &http.Response{
|
||||
Status: "404 Not Found",
|
||||
StatusCode: 404,
|
||||
Proto: "HTTP/1.1",
|
||||
ProtoMajor: 1,
|
||||
ProtoMinor: 1,
|
||||
ContentLength: 50,
|
||||
Header: http.Header{
|
||||
"Foo": []string{"Bar"},
|
||||
},
|
||||
Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used
|
||||
Request: &http.Request{
|
||||
Method: "",
|
||||
URL: &url.URL{
|
||||
Scheme: "",
|
||||
Opaque: "",
|
||||
User: nil,
|
||||
Host: "",
|
||||
Path: "",
|
||||
RawPath: "",
|
||||
ForceQuery: false,
|
||||
RawQuery: "",
|
||||
Fragment: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
Message: "",
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return d.Pipelines[projectId][pipelineId], nil
|
||||
}
|
||||
|
||||
@@ -18,3 +18,12 @@ const (
|
||||
GLOBAL_ROLE = "globalRoles"
|
||||
PROJECT_ROLE = "projectRoles"
|
||||
)
|
||||
|
||||
var ParameterTypeMap = map[string]string{
|
||||
"hudson.model.StringParameterDefinition": "string",
|
||||
"hudson.model.ChoiceParameterDefinition": "choice",
|
||||
"hudson.model.TextParameterDefinition": "text",
|
||||
"hudson.model.BooleanParameterDefinition": "boolean",
|
||||
"hudson.model.FileParameterDefinition": "file",
|
||||
"hudson.model.PasswordParameterDefinition": "password",
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package jenkins
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/beevik/etree"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/devops"
|
||||
devopsv1alpha3 "kubesphere.io/kubesphere/pkg/apis/devops/v1alpha3"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -16,7 +16,7 @@ func replaceXmlVersion(config, oldVersion, targetVersion string) string {
|
||||
return output
|
||||
}
|
||||
|
||||
func createPipelineConfigXml(pipeline *devops.NoScmPipeline) (string, error) {
|
||||
func createPipelineConfigXml(pipeline *devopsv1alpha3.NoScmPipeline) (string, error) {
|
||||
doc := etree.NewDocument()
|
||||
xmlString := `<?xml version='1.0' encoding='UTF-8'?>
|
||||
<flow-definition plugin="workflow-job">
|
||||
@@ -82,8 +82,8 @@ func createPipelineConfigXml(pipeline *devops.NoScmPipeline) (string, error) {
|
||||
return replaceXmlVersion(stringXml, "1.0", "1.1"), err
|
||||
}
|
||||
|
||||
func parsePipelineConfigXml(config string) (*devops.NoScmPipeline, error) {
|
||||
pipeline := &devops.NoScmPipeline{}
|
||||
func parsePipelineConfigXml(config string) (*devopsv1alpha3.NoScmPipeline, error) {
|
||||
pipeline := &devopsv1alpha3.NoScmPipeline{}
|
||||
config = replaceXmlVersion(config, "1.1", "1.0")
|
||||
doc := etree.NewDocument()
|
||||
err := doc.ReadFromString(config)
|
||||
@@ -106,14 +106,14 @@ func parsePipelineConfigXml(config string) (*devops.NoScmPipeline, error) {
|
||||
strategy := properties.
|
||||
SelectElement("jenkins.model.BuildDiscarderProperty").
|
||||
SelectElement("strategy")
|
||||
pipeline.Discarder = &devops.DiscarderProperty{
|
||||
pipeline.Discarder = &devopsv1alpha3.DiscarderProperty{
|
||||
DaysToKeep: strategy.SelectElement("daysToKeep").Text(),
|
||||
NumToKeep: strategy.SelectElement("numToKeep").Text(),
|
||||
}
|
||||
}
|
||||
pipeline.Parameters = &devops.Parameters{}
|
||||
|
||||
pipeline.Parameters = getParametersfromEtree(properties)
|
||||
if len(*pipeline.Parameters) == 0 {
|
||||
if len(pipeline.Parameters) == 0 {
|
||||
pipeline.Parameters = nil
|
||||
}
|
||||
|
||||
@@ -122,13 +122,13 @@ func parsePipelineConfigXml(config string) (*devops.NoScmPipeline, error) {
|
||||
"org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty"); triggerProperty != nil {
|
||||
triggers := triggerProperty.SelectElement("triggers")
|
||||
if timerTrigger := triggers.SelectElement("hudson.triggers.TimerTrigger"); timerTrigger != nil {
|
||||
pipeline.TimerTrigger = &devops.TimerTrigger{
|
||||
pipeline.TimerTrigger = &devopsv1alpha3.TimerTrigger{
|
||||
Cron: timerTrigger.SelectElement("spec").Text(),
|
||||
}
|
||||
}
|
||||
}
|
||||
if authToken := flow.SelectElement("authToken"); authToken != nil {
|
||||
pipeline.RemoteTrigger = &devops.RemoteTrigger{
|
||||
pipeline.RemoteTrigger = &devopsv1alpha3.RemoteTrigger{
|
||||
Token: authToken.Text(),
|
||||
}
|
||||
}
|
||||
@@ -140,11 +140,11 @@ func parsePipelineConfigXml(config string) (*devops.NoScmPipeline, error) {
|
||||
return pipeline, nil
|
||||
}
|
||||
|
||||
func appendParametersToEtree(properties *etree.Element, parameters *devops.Parameters) {
|
||||
func appendParametersToEtree(properties *etree.Element, parameters []devopsv1alpha3.Parameter) {
|
||||
parameterDefinitions := properties.CreateElement("hudson.model.ParametersDefinitionProperty").
|
||||
CreateElement("parameterDefinitions")
|
||||
for _, parameter := range *parameters {
|
||||
for className, typeName := range devops.ParameterTypeMap {
|
||||
for _, parameter := range parameters {
|
||||
for className, typeName := range ParameterTypeMap {
|
||||
if typeName == parameter.Type {
|
||||
paramDefine := parameterDefinitions.CreateElement(className)
|
||||
paramDefine.CreateElement("name").SetText(parameter.Name)
|
||||
@@ -169,51 +169,51 @@ func appendParametersToEtree(properties *etree.Element, parameters *devops.Param
|
||||
}
|
||||
}
|
||||
|
||||
func getParametersfromEtree(properties *etree.Element) *devops.Parameters {
|
||||
var parameters devops.Parameters
|
||||
func getParametersfromEtree(properties *etree.Element) []devopsv1alpha3.Parameter {
|
||||
var parameters []devopsv1alpha3.Parameter
|
||||
if parametersProperty := properties.SelectElement("hudson.model.ParametersDefinitionProperty"); parametersProperty != nil {
|
||||
params := parametersProperty.SelectElement("parameterDefinitions").ChildElements()
|
||||
for _, param := range params {
|
||||
switch param.Tag {
|
||||
case "hudson.model.StringParameterDefinition":
|
||||
parameters = append(parameters, &devops.Parameter{
|
||||
parameters = append(parameters, devopsv1alpha3.Parameter{
|
||||
Name: param.SelectElement("name").Text(),
|
||||
Description: param.SelectElement("description").Text(),
|
||||
DefaultValue: param.SelectElement("defaultValue").Text(),
|
||||
Type: devops.ParameterTypeMap["hudson.model.StringParameterDefinition"],
|
||||
Type: ParameterTypeMap["hudson.model.StringParameterDefinition"],
|
||||
})
|
||||
case "hudson.model.BooleanParameterDefinition":
|
||||
parameters = append(parameters, &devops.Parameter{
|
||||
parameters = append(parameters, devopsv1alpha3.Parameter{
|
||||
Name: param.SelectElement("name").Text(),
|
||||
Description: param.SelectElement("description").Text(),
|
||||
DefaultValue: param.SelectElement("defaultValue").Text(),
|
||||
Type: devops.ParameterTypeMap["hudson.model.BooleanParameterDefinition"],
|
||||
Type: ParameterTypeMap["hudson.model.BooleanParameterDefinition"],
|
||||
})
|
||||
case "hudson.model.TextParameterDefinition":
|
||||
parameters = append(parameters, &devops.Parameter{
|
||||
parameters = append(parameters, devopsv1alpha3.Parameter{
|
||||
Name: param.SelectElement("name").Text(),
|
||||
Description: param.SelectElement("description").Text(),
|
||||
DefaultValue: param.SelectElement("defaultValue").Text(),
|
||||
Type: devops.ParameterTypeMap["hudson.model.TextParameterDefinition"],
|
||||
Type: ParameterTypeMap["hudson.model.TextParameterDefinition"],
|
||||
})
|
||||
case "hudson.model.FileParameterDefinition":
|
||||
parameters = append(parameters, &devops.Parameter{
|
||||
parameters = append(parameters, devopsv1alpha3.Parameter{
|
||||
Name: param.SelectElement("name").Text(),
|
||||
Description: param.SelectElement("description").Text(),
|
||||
Type: devops.ParameterTypeMap["hudson.model.FileParameterDefinition"],
|
||||
Type: ParameterTypeMap["hudson.model.FileParameterDefinition"],
|
||||
})
|
||||
case "hudson.model.PasswordParameterDefinition":
|
||||
parameters = append(parameters, &devops.Parameter{
|
||||
parameters = append(parameters, devopsv1alpha3.Parameter{
|
||||
Name: param.SelectElement("name").Text(),
|
||||
Description: param.SelectElement("description").Text(),
|
||||
DefaultValue: param.SelectElement("name").Text(),
|
||||
Type: devops.ParameterTypeMap["hudson.model.PasswordParameterDefinition"],
|
||||
Type: ParameterTypeMap["hudson.model.PasswordParameterDefinition"],
|
||||
})
|
||||
case "hudson.model.ChoiceParameterDefinition":
|
||||
choiceParameter := &devops.Parameter{
|
||||
choiceParameter := devopsv1alpha3.Parameter{
|
||||
Name: param.SelectElement("name").Text(),
|
||||
Description: param.SelectElement("description").Text(),
|
||||
Type: devops.ParameterTypeMap["hudson.model.ChoiceParameterDefinition"],
|
||||
Type: ParameterTypeMap["hudson.model.ChoiceParameterDefinition"],
|
||||
}
|
||||
choices := param.SelectElement("choices").SelectElement("a").SelectElements("string")
|
||||
for _, choice := range choices {
|
||||
@@ -222,7 +222,7 @@ func getParametersfromEtree(properties *etree.Element) *devops.Parameters {
|
||||
choiceParameter.DefaultValue = strings.TrimSpace(choiceParameter.DefaultValue)
|
||||
parameters = append(parameters, choiceParameter)
|
||||
default:
|
||||
parameters = append(parameters, &devops.Parameter{
|
||||
parameters = append(parameters, devopsv1alpha3.Parameter{
|
||||
Name: param.SelectElement("name").Text(),
|
||||
Description: param.SelectElement("description").Text(),
|
||||
DefaultValue: "unknown",
|
||||
@@ -231,10 +231,10 @@ func getParametersfromEtree(properties *etree.Element) *devops.Parameters {
|
||||
}
|
||||
}
|
||||
}
|
||||
return ¶meters
|
||||
return parameters
|
||||
}
|
||||
|
||||
func appendGitSourceToEtree(source *etree.Element, gitSource *devops.GitSource) {
|
||||
func appendGitSourceToEtree(source *etree.Element, gitSource *devopsv1alpha3.GitSource) {
|
||||
source.CreateAttr("class", "jenkins.plugins.git.GitSCMSource")
|
||||
source.CreateAttr("plugin", "git")
|
||||
source.CreateElement("id").SetText(gitSource.ScmId)
|
||||
@@ -274,8 +274,8 @@ func appendGitSourceToEtree(source *etree.Element, gitSource *devops.GitSource)
|
||||
return
|
||||
}
|
||||
|
||||
func getGitSourcefromEtree(source *etree.Element) *devops.GitSource {
|
||||
var gitSource devops.GitSource
|
||||
func getGitSourcefromEtree(source *etree.Element) *devopsv1alpha3.GitSource {
|
||||
var gitSource devopsv1alpha3.GitSource
|
||||
if credential := source.SelectElement("credentialsId"); credential != nil {
|
||||
gitSource.CredentialId = credential.Text()
|
||||
}
|
||||
@@ -292,7 +292,7 @@ func getGitSourcefromEtree(source *etree.Element) *devops.GitSource {
|
||||
"jenkins.plugins.git.traits.CloneOptionTrait"); cloneTrait != nil {
|
||||
if cloneExtension := cloneTrait.SelectElement(
|
||||
"extension"); cloneExtension != nil {
|
||||
gitSource.CloneOption = &devops.GitCloneOption{}
|
||||
gitSource.CloneOption = &devopsv1alpha3.GitCloneOption{}
|
||||
if value, err := strconv.ParseBool(cloneExtension.SelectElement("shallow").Text()); err == nil {
|
||||
gitSource.CloneOption.Shallow = value
|
||||
}
|
||||
@@ -313,8 +313,8 @@ func getGitSourcefromEtree(source *etree.Element) *devops.GitSource {
|
||||
return &gitSource
|
||||
}
|
||||
|
||||
func getGithubSourcefromEtree(source *etree.Element) *devops.GithubSource {
|
||||
var githubSource devops.GithubSource
|
||||
func getGithubSourcefromEtree(source *etree.Element) *devopsv1alpha3.GithubSource {
|
||||
var githubSource devopsv1alpha3.GithubSource
|
||||
if credential := source.SelectElement("credentialsId"); credential != nil {
|
||||
githubSource.CredentialId = credential.Text()
|
||||
}
|
||||
@@ -345,22 +345,22 @@ func getGithubSourcefromEtree(source *etree.Element) *devops.GithubSource {
|
||||
trust := strings.Split(trustClass, "$")
|
||||
switch trust[1] {
|
||||
case "TrustContributors":
|
||||
githubSource.DiscoverPRFromForks = &devops.DiscoverPRFromForks{
|
||||
githubSource.DiscoverPRFromForks = &devopsv1alpha3.DiscoverPRFromForks{
|
||||
Strategy: strategyId,
|
||||
Trust: 1,
|
||||
}
|
||||
case "TrustEveryone":
|
||||
githubSource.DiscoverPRFromForks = &devops.DiscoverPRFromForks{
|
||||
githubSource.DiscoverPRFromForks = &devopsv1alpha3.DiscoverPRFromForks{
|
||||
Strategy: strategyId,
|
||||
Trust: 2,
|
||||
}
|
||||
case "TrustPermission":
|
||||
githubSource.DiscoverPRFromForks = &devops.DiscoverPRFromForks{
|
||||
githubSource.DiscoverPRFromForks = &devopsv1alpha3.DiscoverPRFromForks{
|
||||
Strategy: strategyId,
|
||||
Trust: 3,
|
||||
}
|
||||
case "TrustNobody":
|
||||
githubSource.DiscoverPRFromForks = &devops.DiscoverPRFromForks{
|
||||
githubSource.DiscoverPRFromForks = &devopsv1alpha3.DiscoverPRFromForks{
|
||||
Strategy: strategyId,
|
||||
Trust: 4,
|
||||
}
|
||||
@@ -369,7 +369,7 @@ func getGithubSourcefromEtree(source *etree.Element) *devops.GithubSource {
|
||||
"jenkins.plugins.git.traits.CloneOptionTrait"); cloneTrait != nil {
|
||||
if cloneExtension := cloneTrait.SelectElement(
|
||||
"extension"); cloneExtension != nil {
|
||||
githubSource.CloneOption = &devops.GitCloneOption{}
|
||||
githubSource.CloneOption = &devopsv1alpha3.GitCloneOption{}
|
||||
if value, err := strconv.ParseBool(cloneExtension.SelectElement("shallow").Text()); err == nil {
|
||||
githubSource.CloneOption.Shallow = value
|
||||
}
|
||||
@@ -392,7 +392,7 @@ func getGithubSourcefromEtree(source *etree.Element) *devops.GithubSource {
|
||||
return &githubSource
|
||||
}
|
||||
|
||||
func appendGithubSourceToEtree(source *etree.Element, githubSource *devops.GithubSource) {
|
||||
func appendGithubSourceToEtree(source *etree.Element, githubSource *devopsv1alpha3.GithubSource) {
|
||||
source.CreateAttr("class", "org.jenkinsci.plugins.github_branch_source.GitHubSCMSource")
|
||||
source.CreateAttr("plugin", "github-branch-source")
|
||||
source.CreateElement("id").SetText(githubSource.ScmId)
|
||||
@@ -455,8 +455,8 @@ func appendGithubSourceToEtree(source *etree.Element, githubSource *devops.Githu
|
||||
return
|
||||
}
|
||||
|
||||
func getBitbucketServerSourceFromEtree(source *etree.Element) *devops.BitbucketServerSource {
|
||||
var s devops.BitbucketServerSource
|
||||
func getBitbucketServerSourceFromEtree(source *etree.Element) *devopsv1alpha3.BitbucketServerSource {
|
||||
var s devopsv1alpha3.BitbucketServerSource
|
||||
if credential := source.SelectElement("credentialsId"); credential != nil {
|
||||
s.CredentialId = credential.Text()
|
||||
}
|
||||
@@ -487,17 +487,17 @@ func getBitbucketServerSourceFromEtree(source *etree.Element) *devops.BitbucketS
|
||||
trust := strings.Split(trustClass, "$")
|
||||
switch trust[1] {
|
||||
case "TrustEveryone":
|
||||
s.DiscoverPRFromForks = &devops.DiscoverPRFromForks{
|
||||
s.DiscoverPRFromForks = &devopsv1alpha3.DiscoverPRFromForks{
|
||||
Strategy: strategyId,
|
||||
Trust: 1,
|
||||
}
|
||||
case "TrustTeamForks":
|
||||
s.DiscoverPRFromForks = &devops.DiscoverPRFromForks{
|
||||
s.DiscoverPRFromForks = &devopsv1alpha3.DiscoverPRFromForks{
|
||||
Strategy: strategyId,
|
||||
Trust: 2,
|
||||
}
|
||||
case "TrustNobody":
|
||||
s.DiscoverPRFromForks = &devops.DiscoverPRFromForks{
|
||||
s.DiscoverPRFromForks = &devopsv1alpha3.DiscoverPRFromForks{
|
||||
Strategy: strategyId,
|
||||
Trust: 3,
|
||||
}
|
||||
@@ -506,7 +506,7 @@ func getBitbucketServerSourceFromEtree(source *etree.Element) *devops.BitbucketS
|
||||
"jenkins.plugins.git.traits.CloneOptionTrait"); cloneTrait != nil {
|
||||
if cloneExtension := cloneTrait.SelectElement(
|
||||
"extension"); cloneExtension != nil {
|
||||
s.CloneOption = &devops.GitCloneOption{}
|
||||
s.CloneOption = &devopsv1alpha3.GitCloneOption{}
|
||||
if value, err := strconv.ParseBool(cloneExtension.SelectElement("shallow").Text()); err == nil {
|
||||
s.CloneOption.Shallow = value
|
||||
}
|
||||
@@ -529,7 +529,7 @@ func getBitbucketServerSourceFromEtree(source *etree.Element) *devops.BitbucketS
|
||||
return &s
|
||||
}
|
||||
|
||||
func appendBitbucketServerSourceToEtree(source *etree.Element, s *devops.BitbucketServerSource) {
|
||||
func appendBitbucketServerSourceToEtree(source *etree.Element, s *devopsv1alpha3.BitbucketServerSource) {
|
||||
source.CreateAttr("class", "com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource")
|
||||
source.CreateAttr("plugin", "cloudbees-bitbucket-branch-source")
|
||||
source.CreateElement("id").SetText(s.ScmId)
|
||||
@@ -590,8 +590,8 @@ func appendBitbucketServerSourceToEtree(source *etree.Element, s *devops.Bitbuck
|
||||
return
|
||||
}
|
||||
|
||||
func getSvnSourcefromEtree(source *etree.Element) *devops.SvnSource {
|
||||
var s devops.SvnSource
|
||||
func getSvnSourcefromEtree(source *etree.Element) *devopsv1alpha3.SvnSource {
|
||||
var s devopsv1alpha3.SvnSource
|
||||
if remote := source.SelectElement("remoteBase"); remote != nil {
|
||||
s.Remote = remote.Text()
|
||||
}
|
||||
@@ -610,7 +610,7 @@ func getSvnSourcefromEtree(source *etree.Element) *devops.SvnSource {
|
||||
return &s
|
||||
}
|
||||
|
||||
func appendSvnSourceToEtree(source *etree.Element, s *devops.SvnSource) {
|
||||
func appendSvnSourceToEtree(source *etree.Element, s *devopsv1alpha3.SvnSource) {
|
||||
source.CreateAttr("class", "jenkins.scm.impl.subversion.SubversionSCMSource")
|
||||
source.CreateAttr("plugin", "subversion")
|
||||
source.CreateElement("id").SetText(s.ScmId)
|
||||
@@ -629,8 +629,8 @@ func appendSvnSourceToEtree(source *etree.Element, s *devops.SvnSource) {
|
||||
return
|
||||
}
|
||||
|
||||
func getSingleSvnSourceFromEtree(source *etree.Element) *devops.SingleSvnSource {
|
||||
var s devops.SingleSvnSource
|
||||
func getSingleSvnSourceFromEtree(source *etree.Element) *devopsv1alpha3.SingleSvnSource {
|
||||
var s devopsv1alpha3.SingleSvnSource
|
||||
if scm := source.SelectElement("scm"); scm != nil {
|
||||
if locations := scm.SelectElement("locations"); locations != nil {
|
||||
if moduleLocations := locations.SelectElement("hudson.scm.SubversionSCM_-ModuleLocation"); moduleLocations != nil {
|
||||
@@ -646,7 +646,7 @@ func getSingleSvnSourceFromEtree(source *etree.Element) *devops.SingleSvnSource
|
||||
return &s
|
||||
}
|
||||
|
||||
func appendSingleSvnSourceToEtree(source *etree.Element, s *devops.SingleSvnSource) {
|
||||
func appendSingleSvnSourceToEtree(source *etree.Element, s *devopsv1alpha3.SingleSvnSource) {
|
||||
|
||||
source.CreateAttr("class", "jenkins.scm.impl.SingleSCMSource")
|
||||
source.CreateAttr("plugin", "scm-api")
|
||||
@@ -682,7 +682,7 @@ func appendSingleSvnSourceToEtree(source *etree.Element, s *devops.SingleSvnSour
|
||||
return
|
||||
}
|
||||
|
||||
func appendMultiBranchJobTriggerToEtree(properties *etree.Element, s *devops.MultiBranchJobTrigger) {
|
||||
func appendMultiBranchJobTriggerToEtree(properties *etree.Element, s *devopsv1alpha3.MultiBranchJobTrigger) {
|
||||
triggerProperty := properties.CreateElement("org.jenkinsci.plugins.workflow.multibranch.PipelineTriggerProperty")
|
||||
triggerProperty.CreateAttr("plugin", "multibranch-action-triggers")
|
||||
triggerProperty.CreateElement("createActionJobsToTrigger").SetText(s.CreateActionJobsToTrigger)
|
||||
@@ -690,8 +690,8 @@ func appendMultiBranchJobTriggerToEtree(properties *etree.Element, s *devops.Mul
|
||||
return
|
||||
}
|
||||
|
||||
func getMultiBranchJobTriggerfromEtree(properties *etree.Element) *devops.MultiBranchJobTrigger {
|
||||
var s devops.MultiBranchJobTrigger
|
||||
func getMultiBranchJobTriggerfromEtree(properties *etree.Element) *devopsv1alpha3.MultiBranchJobTrigger {
|
||||
var s devopsv1alpha3.MultiBranchJobTrigger
|
||||
triggerProperty := properties.SelectElement("org.jenkinsci.plugins.workflow.multibranch.PipelineTriggerProperty")
|
||||
if triggerProperty != nil {
|
||||
s.CreateActionJobsToTrigger = triggerProperty.SelectElement("createActionJobsToTrigger").Text()
|
||||
@@ -699,7 +699,7 @@ func getMultiBranchJobTriggerfromEtree(properties *etree.Element) *devops.MultiB
|
||||
}
|
||||
return &s
|
||||
}
|
||||
func createMultiBranchPipelineConfigXml(projectName string, pipeline *devops.MultiBranchPipeline) (string, error) {
|
||||
func createMultiBranchPipelineConfigXml(projectName string, pipeline *devopsv1alpha3.MultiBranchPipeline) (string, error) {
|
||||
doc := etree.NewDocument()
|
||||
xmlString := `
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
@@ -802,8 +802,8 @@ func createMultiBranchPipelineConfigXml(projectName string, pipeline *devops.Mul
|
||||
return replaceXmlVersion(stringXml, "1.0", "1.1"), err
|
||||
}
|
||||
|
||||
func parseMultiBranchPipelineConfigXml(config string) (*devops.MultiBranchPipeline, error) {
|
||||
pipeline := &devops.MultiBranchPipeline{}
|
||||
func parseMultiBranchPipelineConfigXml(config string) (*devopsv1alpha3.MultiBranchPipeline, error) {
|
||||
pipeline := &devopsv1alpha3.MultiBranchPipeline{}
|
||||
config = replaceXmlVersion(config, "1.1", "1.0")
|
||||
doc := etree.NewDocument()
|
||||
err := doc.ReadFromString(config)
|
||||
@@ -823,7 +823,7 @@ func parseMultiBranchPipelineConfigXml(config string) (*devops.MultiBranchPipeli
|
||||
pipeline.Description = project.SelectElement("description").Text()
|
||||
|
||||
if discarder := project.SelectElement("orphanedItemStrategy"); discarder != nil {
|
||||
pipeline.Discarder = &devops.DiscarderProperty{
|
||||
pipeline.Discarder = &devopsv1alpha3.DiscarderProperty{
|
||||
DaysToKeep: discarder.SelectElement("daysToKeep").Text(),
|
||||
NumToKeep: discarder.SelectElement("numToKeep").Text(),
|
||||
}
|
||||
@@ -831,7 +831,7 @@ func parseMultiBranchPipelineConfigXml(config string) (*devops.MultiBranchPipeli
|
||||
if triggers := project.SelectElement("triggers"); triggers != nil {
|
||||
if timerTrigger := triggers.SelectElement(
|
||||
"com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger"); timerTrigger != nil {
|
||||
pipeline.TimerTrigger = &devops.TimerTrigger{
|
||||
pipeline.TimerTrigger = &devopsv1alpha3.TimerTrigger{
|
||||
Interval: timerTrigger.SelectElement("interval").Text(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package jenkins
|
||||
|
||||
import (
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/devops"
|
||||
devopsv1alpha3 "kubesphere.io/kubesphere/pkg/apis/devops/v1alpha3"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_NoScmPipelineConfig(t *testing.T) {
|
||||
inputs := []*devops.NoScmPipeline{
|
||||
inputs := []*devopsv1alpha3.NoScmPipeline{
|
||||
{
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
@@ -42,12 +42,12 @@ func Test_NoScmPipelineConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_NoScmPipelineConfig_Discarder(t *testing.T) {
|
||||
inputs := []*devops.NoScmPipeline{
|
||||
inputs := []*devopsv1alpha3.NoScmPipeline{
|
||||
{
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
Jenkinsfile: "node{echo 'hello'}",
|
||||
Discarder: &devops.DiscarderProperty{
|
||||
Discarder: &devopsv1alpha3.DiscarderProperty{
|
||||
DaysToKeep: "3", NumToKeep: "5",
|
||||
},
|
||||
},
|
||||
@@ -55,7 +55,7 @@ func Test_NoScmPipelineConfig_Discarder(t *testing.T) {
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
Jenkinsfile: "node{echo 'hello'}",
|
||||
Discarder: &devops.DiscarderProperty{
|
||||
Discarder: &devopsv1alpha3.DiscarderProperty{
|
||||
DaysToKeep: "3", NumToKeep: "",
|
||||
},
|
||||
},
|
||||
@@ -63,7 +63,7 @@ func Test_NoScmPipelineConfig_Discarder(t *testing.T) {
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
Jenkinsfile: "node{echo 'hello'}",
|
||||
Discarder: &devops.DiscarderProperty{
|
||||
Discarder: &devopsv1alpha3.DiscarderProperty{
|
||||
DaysToKeep: "", NumToKeep: "21321",
|
||||
},
|
||||
},
|
||||
@@ -71,7 +71,7 @@ func Test_NoScmPipelineConfig_Discarder(t *testing.T) {
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
Jenkinsfile: "node{echo 'hello'}",
|
||||
Discarder: &devops.DiscarderProperty{
|
||||
Discarder: &devopsv1alpha3.DiscarderProperty{
|
||||
DaysToKeep: "", NumToKeep: "",
|
||||
},
|
||||
},
|
||||
@@ -93,13 +93,13 @@ func Test_NoScmPipelineConfig_Discarder(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_NoScmPipelineConfig_Param(t *testing.T) {
|
||||
inputs := []*devops.NoScmPipeline{
|
||||
inputs := []*devopsv1alpha3.NoScmPipeline{
|
||||
{
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
Jenkinsfile: "node{echo 'hello'}",
|
||||
Parameters: &devops.Parameters{
|
||||
&devops.Parameter{
|
||||
Parameters: []devopsv1alpha3.Parameter{
|
||||
{
|
||||
Name: "d",
|
||||
DefaultValue: "a\nb",
|
||||
Type: "choice",
|
||||
@@ -111,26 +111,26 @@ func Test_NoScmPipelineConfig_Param(t *testing.T) {
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
Jenkinsfile: "node{echo 'hello'}",
|
||||
Parameters: &devops.Parameters{
|
||||
&devops.Parameter{
|
||||
Parameters: []devopsv1alpha3.Parameter{
|
||||
{
|
||||
Name: "a",
|
||||
DefaultValue: "abc",
|
||||
Type: "string",
|
||||
Description: "fortest",
|
||||
},
|
||||
&devops.Parameter{
|
||||
{
|
||||
Name: "b",
|
||||
DefaultValue: "false",
|
||||
Type: "boolean",
|
||||
Description: "fortest",
|
||||
},
|
||||
&devops.Parameter{
|
||||
{
|
||||
Name: "c",
|
||||
DefaultValue: "password \n aaa",
|
||||
Type: "text",
|
||||
Description: "fortest",
|
||||
},
|
||||
&devops.Parameter{
|
||||
{
|
||||
Name: "d",
|
||||
DefaultValue: "a\nb",
|
||||
Type: "choice",
|
||||
@@ -156,12 +156,12 @@ func Test_NoScmPipelineConfig_Param(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_NoScmPipelineConfig_Trigger(t *testing.T) {
|
||||
inputs := []*devops.NoScmPipeline{
|
||||
inputs := []*devopsv1alpha3.NoScmPipeline{
|
||||
{
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
Jenkinsfile: "node{echo 'hello'}",
|
||||
TimerTrigger: &devops.TimerTrigger{
|
||||
TimerTrigger: &devopsv1alpha3.TimerTrigger{
|
||||
Cron: "1 1 1 * * *",
|
||||
},
|
||||
},
|
||||
@@ -170,7 +170,7 @@ func Test_NoScmPipelineConfig_Trigger(t *testing.T) {
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
Jenkinsfile: "node{echo 'hello'}",
|
||||
RemoteTrigger: &devops.RemoteTrigger{
|
||||
RemoteTrigger: &devopsv1alpha3.RemoteTrigger{
|
||||
Token: "abc",
|
||||
},
|
||||
},
|
||||
@@ -178,10 +178,10 @@ func Test_NoScmPipelineConfig_Trigger(t *testing.T) {
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
Jenkinsfile: "node{echo 'hello'}",
|
||||
TimerTrigger: &devops.TimerTrigger{
|
||||
TimerTrigger: &devopsv1alpha3.TimerTrigger{
|
||||
Cron: "1 1 1 * * *",
|
||||
},
|
||||
RemoteTrigger: &devops.RemoteTrigger{
|
||||
RemoteTrigger: &devopsv1alpha3.RemoteTrigger{
|
||||
Token: "abc",
|
||||
},
|
||||
},
|
||||
@@ -205,34 +205,34 @@ func Test_NoScmPipelineConfig_Trigger(t *testing.T) {
|
||||
|
||||
func Test_MultiBranchPipelineConfig(t *testing.T) {
|
||||
|
||||
inputs := []*devops.MultiBranchPipeline{
|
||||
inputs := []*devopsv1alpha3.MultiBranchPipeline{
|
||||
{
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "git",
|
||||
GitSource: &devops.GitSource{},
|
||||
GitSource: &devopsv1alpha3.GitSource{},
|
||||
},
|
||||
{
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "github",
|
||||
GitHubSource: &devops.GithubSource{},
|
||||
GitHubSource: &devopsv1alpha3.GithubSource{},
|
||||
},
|
||||
{
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "single_svn",
|
||||
SingleSvnSource: &devops.SingleSvnSource{},
|
||||
SingleSvnSource: &devopsv1alpha3.SingleSvnSource{},
|
||||
},
|
||||
{
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "svn",
|
||||
SvnSource: &devops.SvnSource{},
|
||||
SvnSource: &devopsv1alpha3.SvnSource{},
|
||||
},
|
||||
}
|
||||
for _, input := range inputs {
|
||||
@@ -253,17 +253,17 @@ func Test_MultiBranchPipelineConfig(t *testing.T) {
|
||||
|
||||
func Test_MultiBranchPipelineConfig_Discarder(t *testing.T) {
|
||||
|
||||
inputs := []*devops.MultiBranchPipeline{
|
||||
inputs := []*devopsv1alpha3.MultiBranchPipeline{
|
||||
{
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "git",
|
||||
Discarder: &devops.DiscarderProperty{
|
||||
Discarder: &devopsv1alpha3.DiscarderProperty{
|
||||
DaysToKeep: "1",
|
||||
NumToKeep: "2",
|
||||
},
|
||||
GitSource: &devops.GitSource{},
|
||||
GitSource: &devopsv1alpha3.GitSource{},
|
||||
},
|
||||
}
|
||||
for _, input := range inputs {
|
||||
@@ -283,16 +283,16 @@ func Test_MultiBranchPipelineConfig_Discarder(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_MultiBranchPipelineConfig_TimerTrigger(t *testing.T) {
|
||||
inputs := []*devops.MultiBranchPipeline{
|
||||
inputs := []*devopsv1alpha3.MultiBranchPipeline{
|
||||
{
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "git",
|
||||
TimerTrigger: &devops.TimerTrigger{
|
||||
TimerTrigger: &devopsv1alpha3.TimerTrigger{
|
||||
Interval: "12345566",
|
||||
},
|
||||
GitSource: &devops.GitSource{},
|
||||
GitSource: &devopsv1alpha3.GitSource{},
|
||||
},
|
||||
}
|
||||
for _, input := range inputs {
|
||||
@@ -313,16 +313,16 @@ func Test_MultiBranchPipelineConfig_TimerTrigger(t *testing.T) {
|
||||
|
||||
func Test_MultiBranchPipelineConfig_Source(t *testing.T) {
|
||||
|
||||
inputs := []*devops.MultiBranchPipeline{
|
||||
inputs := []*devopsv1alpha3.MultiBranchPipeline{
|
||||
{
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "git",
|
||||
TimerTrigger: &devops.TimerTrigger{
|
||||
TimerTrigger: &devopsv1alpha3.TimerTrigger{
|
||||
Interval: "12345566",
|
||||
},
|
||||
GitSource: &devops.GitSource{
|
||||
GitSource: &devopsv1alpha3.GitSource{
|
||||
Url: "https://github.com/kubesphere/devops",
|
||||
CredentialId: "git",
|
||||
DiscoverBranches: true,
|
||||
@@ -333,17 +333,17 @@ func Test_MultiBranchPipelineConfig_Source(t *testing.T) {
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "github",
|
||||
TimerTrigger: &devops.TimerTrigger{
|
||||
TimerTrigger: &devopsv1alpha3.TimerTrigger{
|
||||
Interval: "12345566",
|
||||
},
|
||||
GitHubSource: &devops.GithubSource{
|
||||
GitHubSource: &devopsv1alpha3.GithubSource{
|
||||
Owner: "kubesphere",
|
||||
Repo: "devops",
|
||||
CredentialId: "github",
|
||||
ApiUri: "https://api.github.com",
|
||||
DiscoverBranches: 1,
|
||||
DiscoverPRFromOrigin: 2,
|
||||
DiscoverPRFromForks: &devops.DiscoverPRFromForks{
|
||||
DiscoverPRFromForks: &devopsv1alpha3.DiscoverPRFromForks{
|
||||
Strategy: 1,
|
||||
Trust: 1,
|
||||
},
|
||||
@@ -354,17 +354,17 @@ func Test_MultiBranchPipelineConfig_Source(t *testing.T) {
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "bitbucket_server",
|
||||
TimerTrigger: &devops.TimerTrigger{
|
||||
TimerTrigger: &devopsv1alpha3.TimerTrigger{
|
||||
Interval: "12345566",
|
||||
},
|
||||
BitbucketServerSource: &devops.BitbucketServerSource{
|
||||
BitbucketServerSource: &devopsv1alpha3.BitbucketServerSource{
|
||||
Owner: "kubesphere",
|
||||
Repo: "devops",
|
||||
CredentialId: "github",
|
||||
ApiUri: "https://api.github.com",
|
||||
DiscoverBranches: 1,
|
||||
DiscoverPRFromOrigin: 2,
|
||||
DiscoverPRFromForks: &devops.DiscoverPRFromForks{
|
||||
DiscoverPRFromForks: &devopsv1alpha3.DiscoverPRFromForks{
|
||||
Strategy: 1,
|
||||
Trust: 1,
|
||||
},
|
||||
@@ -376,10 +376,10 @@ func Test_MultiBranchPipelineConfig_Source(t *testing.T) {
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "svn",
|
||||
TimerTrigger: &devops.TimerTrigger{
|
||||
TimerTrigger: &devopsv1alpha3.TimerTrigger{
|
||||
Interval: "12345566",
|
||||
},
|
||||
SvnSource: &devops.SvnSource{
|
||||
SvnSource: &devopsv1alpha3.SvnSource{
|
||||
Remote: "https://api.svn.com/bcd",
|
||||
CredentialId: "svn",
|
||||
Excludes: "truck",
|
||||
@@ -391,10 +391,10 @@ func Test_MultiBranchPipelineConfig_Source(t *testing.T) {
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "single_svn",
|
||||
TimerTrigger: &devops.TimerTrigger{
|
||||
TimerTrigger: &devopsv1alpha3.TimerTrigger{
|
||||
Interval: "12345566",
|
||||
},
|
||||
SingleSvnSource: &devops.SingleSvnSource{
|
||||
SingleSvnSource: &devopsv1alpha3.SingleSvnSource{
|
||||
Remote: "https://api.svn.com/bcd",
|
||||
CredentialId: "svn",
|
||||
},
|
||||
@@ -419,17 +419,17 @@ func Test_MultiBranchPipelineConfig_Source(t *testing.T) {
|
||||
|
||||
func Test_MultiBranchPipelineCloneConfig(t *testing.T) {
|
||||
|
||||
inputs := []*devops.MultiBranchPipeline{
|
||||
inputs := []*devopsv1alpha3.MultiBranchPipeline{
|
||||
{
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "git",
|
||||
GitSource: &devops.GitSource{
|
||||
GitSource: &devopsv1alpha3.GitSource{
|
||||
Url: "https://github.com/kubesphere/devops",
|
||||
CredentialId: "git",
|
||||
DiscoverBranches: true,
|
||||
CloneOption: &devops.GitCloneOption{
|
||||
CloneOption: &devopsv1alpha3.GitCloneOption{
|
||||
Shallow: false,
|
||||
Depth: 3,
|
||||
Timeout: 20,
|
||||
@@ -441,18 +441,18 @@ func Test_MultiBranchPipelineCloneConfig(t *testing.T) {
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "github",
|
||||
GitHubSource: &devops.GithubSource{
|
||||
GitHubSource: &devopsv1alpha3.GithubSource{
|
||||
Owner: "kubesphere",
|
||||
Repo: "devops",
|
||||
CredentialId: "github",
|
||||
ApiUri: "https://api.github.com",
|
||||
DiscoverBranches: 1,
|
||||
DiscoverPRFromOrigin: 2,
|
||||
DiscoverPRFromForks: &devops.DiscoverPRFromForks{
|
||||
DiscoverPRFromForks: &devopsv1alpha3.DiscoverPRFromForks{
|
||||
Strategy: 1,
|
||||
Trust: 1,
|
||||
},
|
||||
CloneOption: &devops.GitCloneOption{
|
||||
CloneOption: &devopsv1alpha3.GitCloneOption{
|
||||
Shallow: false,
|
||||
Depth: 3,
|
||||
Timeout: 20,
|
||||
@@ -480,13 +480,13 @@ func Test_MultiBranchPipelineCloneConfig(t *testing.T) {
|
||||
|
||||
func Test_MultiBranchPipelineRegexFilter(t *testing.T) {
|
||||
|
||||
inputs := []*devops.MultiBranchPipeline{
|
||||
inputs := []*devopsv1alpha3.MultiBranchPipeline{
|
||||
{
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "git",
|
||||
GitSource: &devops.GitSource{
|
||||
GitSource: &devopsv1alpha3.GitSource{
|
||||
Url: "https://github.com/kubesphere/devops",
|
||||
CredentialId: "git",
|
||||
DiscoverBranches: true,
|
||||
@@ -498,14 +498,14 @@ func Test_MultiBranchPipelineRegexFilter(t *testing.T) {
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "github",
|
||||
GitHubSource: &devops.GithubSource{
|
||||
GitHubSource: &devopsv1alpha3.GithubSource{
|
||||
Owner: "kubesphere",
|
||||
Repo: "devops",
|
||||
CredentialId: "github",
|
||||
ApiUri: "https://api.github.com",
|
||||
DiscoverBranches: 1,
|
||||
DiscoverPRFromOrigin: 2,
|
||||
DiscoverPRFromForks: &devops.DiscoverPRFromForks{
|
||||
DiscoverPRFromForks: &devopsv1alpha3.DiscoverPRFromForks{
|
||||
Strategy: 1,
|
||||
Trust: 1,
|
||||
},
|
||||
@@ -533,26 +533,26 @@ func Test_MultiBranchPipelineRegexFilter(t *testing.T) {
|
||||
|
||||
func Test_MultiBranchPipelineMultibranchTrigger(t *testing.T) {
|
||||
|
||||
inputs := []*devops.MultiBranchPipeline{
|
||||
inputs := []*devopsv1alpha3.MultiBranchPipeline{
|
||||
{
|
||||
Name: "",
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "github",
|
||||
GitHubSource: &devops.GithubSource{
|
||||
GitHubSource: &devopsv1alpha3.GithubSource{
|
||||
Owner: "kubesphere",
|
||||
Repo: "devops",
|
||||
CredentialId: "github",
|
||||
ApiUri: "https://api.github.com",
|
||||
DiscoverBranches: 1,
|
||||
DiscoverPRFromOrigin: 2,
|
||||
DiscoverPRFromForks: &devops.DiscoverPRFromForks{
|
||||
DiscoverPRFromForks: &devopsv1alpha3.DiscoverPRFromForks{
|
||||
Strategy: 1,
|
||||
Trust: 1,
|
||||
},
|
||||
RegexFilter: ".*",
|
||||
},
|
||||
MultiBranchJobTrigger: &devops.MultiBranchJobTrigger{
|
||||
MultiBranchJobTrigger: &devopsv1alpha3.MultiBranchJobTrigger{
|
||||
CreateActionJobsToTrigger: "abc",
|
||||
DeleteActionJobsToTrigger: "ddd",
|
||||
},
|
||||
@@ -562,20 +562,20 @@ func Test_MultiBranchPipelineMultibranchTrigger(t *testing.T) {
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "github",
|
||||
GitHubSource: &devops.GithubSource{
|
||||
GitHubSource: &devopsv1alpha3.GithubSource{
|
||||
Owner: "kubesphere",
|
||||
Repo: "devops",
|
||||
CredentialId: "github",
|
||||
ApiUri: "https://api.github.com",
|
||||
DiscoverBranches: 1,
|
||||
DiscoverPRFromOrigin: 2,
|
||||
DiscoverPRFromForks: &devops.DiscoverPRFromForks{
|
||||
DiscoverPRFromForks: &devopsv1alpha3.DiscoverPRFromForks{
|
||||
Strategy: 1,
|
||||
Trust: 1,
|
||||
},
|
||||
RegexFilter: ".*",
|
||||
},
|
||||
MultiBranchJobTrigger: &devops.MultiBranchJobTrigger{
|
||||
MultiBranchJobTrigger: &devopsv1alpha3.MultiBranchJobTrigger{
|
||||
CreateActionJobsToTrigger: "abc",
|
||||
},
|
||||
},
|
||||
@@ -584,20 +584,20 @@ func Test_MultiBranchPipelineMultibranchTrigger(t *testing.T) {
|
||||
Description: "for test",
|
||||
ScriptPath: "Jenkinsfile",
|
||||
SourceType: "github",
|
||||
GitHubSource: &devops.GithubSource{
|
||||
GitHubSource: &devopsv1alpha3.GithubSource{
|
||||
Owner: "kubesphere",
|
||||
Repo: "devops",
|
||||
CredentialId: "github",
|
||||
ApiUri: "https://api.github.com",
|
||||
DiscoverBranches: 1,
|
||||
DiscoverPRFromOrigin: 2,
|
||||
DiscoverPRFromForks: &devops.DiscoverPRFromForks{
|
||||
DiscoverPRFromForks: &devopsv1alpha3.DiscoverPRFromForks{
|
||||
Strategy: 1,
|
||||
Trust: 1,
|
||||
},
|
||||
RegexFilter: ".*",
|
||||
},
|
||||
MultiBranchJobTrigger: &devops.MultiBranchJobTrigger{
|
||||
MultiBranchJobTrigger: &devopsv1alpha3.MultiBranchJobTrigger{
|
||||
DeleteActionJobsToTrigger: "ddd",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -4,20 +4,21 @@ import (
|
||||
"fmt"
|
||||
"github.com/emicklei/go-restful"
|
||||
"k8s.io/klog"
|
||||
devopsv1alpha3 "kubesphere.io/kubesphere/pkg/apis/devops/v1alpha3"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/devops"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (j *Jenkins) CreateProjectPipeline(projectId string, pipeline *devops.ProjectPipeline) (string, error) {
|
||||
switch pipeline.Type {
|
||||
case devops.NoScmPipelineType:
|
||||
func (j *Jenkins) CreateProjectPipeline(projectId string, pipeline *devopsv1alpha3.Pipeline) (string, error) {
|
||||
switch pipeline.Spec.Type {
|
||||
case devopsv1alpha3.NoScmPipelineType:
|
||||
|
||||
config, err := createPipelineConfigXml(pipeline.Pipeline)
|
||||
config, err := createPipelineConfigXml(pipeline.Spec.Pipeline)
|
||||
if err != nil {
|
||||
return "", restful.NewError(http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
job, err := j.GetJob(pipeline.Pipeline.Name, projectId)
|
||||
job, err := j.GetJob(pipeline.Name, projectId)
|
||||
if job != nil {
|
||||
err := fmt.Errorf("job name [%s] has been used", job.GetName())
|
||||
return "", restful.NewError(http.StatusConflict, err.Error())
|
||||
@@ -27,19 +28,19 @@ func (j *Jenkins) CreateProjectPipeline(projectId string, pipeline *devops.Proje
|
||||
return "", restful.NewError(devops.GetDevOpsStatusCode(err), err.Error())
|
||||
}
|
||||
|
||||
_, err = j.CreateJobInFolder(config, pipeline.Pipeline.Name, projectId)
|
||||
_, err = j.CreateJobInFolder(config, pipeline.Name, projectId)
|
||||
if err != nil {
|
||||
return "", restful.NewError(devops.GetDevOpsStatusCode(err), err.Error())
|
||||
}
|
||||
|
||||
return pipeline.Pipeline.Name, nil
|
||||
case devops.MultiBranchPipelineType:
|
||||
config, err := createMultiBranchPipelineConfigXml(projectId, pipeline.MultiBranchPipeline)
|
||||
return pipeline.Name, nil
|
||||
case devopsv1alpha3.MultiBranchPipelineType:
|
||||
config, err := createMultiBranchPipelineConfigXml(projectId, pipeline.Spec.MultiBranchPipeline)
|
||||
if err != nil {
|
||||
return "", restful.NewError(http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
job, err := j.GetJob(pipeline.MultiBranchPipeline.Name, projectId)
|
||||
job, err := j.GetJob(pipeline.Name, projectId)
|
||||
if job != nil {
|
||||
err := fmt.Errorf("job name [%s] has been used", job.GetName())
|
||||
return "", restful.NewError(http.StatusConflict, err.Error())
|
||||
@@ -49,12 +50,12 @@ func (j *Jenkins) CreateProjectPipeline(projectId string, pipeline *devops.Proje
|
||||
return "", restful.NewError(devops.GetDevOpsStatusCode(err), err.Error())
|
||||
}
|
||||
|
||||
_, err = j.CreateJobInFolder(config, pipeline.MultiBranchPipeline.Name, projectId)
|
||||
_, err = j.CreateJobInFolder(config, pipeline.Name, projectId)
|
||||
if err != nil {
|
||||
return "", restful.NewError(devops.GetDevOpsStatusCode(err), err.Error())
|
||||
}
|
||||
|
||||
return pipeline.MultiBranchPipeline.Name, nil
|
||||
return pipeline.Name, nil
|
||||
|
||||
default:
|
||||
err := fmt.Errorf("error unsupport job type")
|
||||
@@ -71,16 +72,16 @@ func (j *Jenkins) DeleteProjectPipeline(projectId string, pipelineId string) (st
|
||||
return pipelineId, nil
|
||||
|
||||
}
|
||||
func (j *Jenkins) UpdateProjectPipeline(projectId string, pipeline *devops.ProjectPipeline) (string, error) {
|
||||
switch pipeline.Type {
|
||||
case devops.NoScmPipelineType:
|
||||
func (j *Jenkins) UpdateProjectPipeline(projectId string, pipeline *devopsv1alpha3.Pipeline) (string, error) {
|
||||
switch pipeline.Spec.Type {
|
||||
case devopsv1alpha3.NoScmPipelineType:
|
||||
|
||||
config, err := createPipelineConfigXml(pipeline.Pipeline)
|
||||
config, err := createPipelineConfigXml(pipeline.Spec.Pipeline)
|
||||
if err != nil {
|
||||
return "", restful.NewError(http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
job, err := j.GetJob(pipeline.Pipeline.Name, projectId)
|
||||
job, err := j.GetJob(pipeline.Name, projectId)
|
||||
|
||||
if err != nil {
|
||||
return "", restful.NewError(devops.GetDevOpsStatusCode(err), err.Error())
|
||||
@@ -91,17 +92,17 @@ func (j *Jenkins) UpdateProjectPipeline(projectId string, pipeline *devops.Proje
|
||||
return "", restful.NewError(devops.GetDevOpsStatusCode(err), err.Error())
|
||||
}
|
||||
|
||||
return pipeline.Pipeline.Name, nil
|
||||
case devops.MultiBranchPipelineType:
|
||||
return pipeline.Name, nil
|
||||
case devopsv1alpha3.MultiBranchPipelineType:
|
||||
|
||||
config, err := createMultiBranchPipelineConfigXml(projectId, pipeline.MultiBranchPipeline)
|
||||
config, err := createMultiBranchPipelineConfigXml(projectId, pipeline.Spec.MultiBranchPipeline)
|
||||
if err != nil {
|
||||
klog.Errorf("%+v", err)
|
||||
|
||||
return "", restful.NewError(http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
job, err := j.GetJob(pipeline.MultiBranchPipeline.Name, projectId)
|
||||
job, err := j.GetJob(pipeline.Spec.MultiBranchPipeline.Name, projectId)
|
||||
|
||||
if err != nil {
|
||||
return "", restful.NewError(devops.GetDevOpsStatusCode(err), err.Error())
|
||||
@@ -113,7 +114,7 @@ func (j *Jenkins) UpdateProjectPipeline(projectId string, pipeline *devops.Proje
|
||||
return "", restful.NewError(devops.GetDevOpsStatusCode(err), err.Error())
|
||||
}
|
||||
|
||||
return pipeline.MultiBranchPipeline.Name, nil
|
||||
return pipeline.Name, nil
|
||||
|
||||
default:
|
||||
err := fmt.Errorf("error unsupport job type")
|
||||
@@ -122,7 +123,7 @@ func (j *Jenkins) UpdateProjectPipeline(projectId string, pipeline *devops.Proje
|
||||
}
|
||||
}
|
||||
|
||||
func (j *Jenkins) GetProjectPipelineConfig(projectId, pipelineId string) (*devops.ProjectPipeline, error) {
|
||||
func (j *Jenkins) GetProjectPipelineConfig(projectId, pipelineId string) (*devopsv1alpha3.Pipeline, error) {
|
||||
job, err := j.GetJob(pipelineId, projectId)
|
||||
if err != nil {
|
||||
klog.Errorf("%+v", err)
|
||||
@@ -139,9 +140,11 @@ func (j *Jenkins) GetProjectPipelineConfig(projectId, pipelineId string) (*devop
|
||||
return nil, restful.NewError(devops.GetDevOpsStatusCode(err), err.Error())
|
||||
}
|
||||
pipeline.Name = pipelineId
|
||||
return &devops.ProjectPipeline{
|
||||
Type: devops.NoScmPipelineType,
|
||||
Pipeline: pipeline,
|
||||
return &devopsv1alpha3.Pipeline{
|
||||
Spec: devopsv1alpha3.PipelineSpec{
|
||||
Type: devopsv1alpha3.NoScmPipelineType,
|
||||
Pipeline: pipeline,
|
||||
},
|
||||
}, nil
|
||||
|
||||
case "org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject":
|
||||
@@ -154,9 +157,11 @@ func (j *Jenkins) GetProjectPipelineConfig(projectId, pipelineId string) (*devop
|
||||
return nil, restful.NewError(devops.GetDevOpsStatusCode(err), err.Error())
|
||||
}
|
||||
pipeline.Name = pipelineId
|
||||
return &devops.ProjectPipeline{
|
||||
Type: devops.MultiBranchPipelineType,
|
||||
MultiBranchPipeline: pipeline,
|
||||
return &devopsv1alpha3.Pipeline{
|
||||
Spec: devopsv1alpha3.PipelineSpec{
|
||||
Type: devopsv1alpha3.MultiBranchPipelineType,
|
||||
MultiBranchPipeline: pipeline,
|
||||
},
|
||||
}, nil
|
||||
default:
|
||||
klog.Errorf("%+v", err)
|
||||
|
||||
@@ -1,144 +1,10 @@
|
||||
package devops
|
||||
|
||||
const (
|
||||
NoScmPipelineType = "pipeline"
|
||||
MultiBranchPipelineType = "multi-branch-pipeline"
|
||||
)
|
||||
|
||||
type Parameters []*Parameter
|
||||
|
||||
var ParameterTypeMap = map[string]string{
|
||||
"hudson.model.StringParameterDefinition": "string",
|
||||
"hudson.model.ChoiceParameterDefinition": "choice",
|
||||
"hudson.model.TextParameterDefinition": "text",
|
||||
"hudson.model.BooleanParameterDefinition": "boolean",
|
||||
"hudson.model.FileParameterDefinition": "file",
|
||||
"hudson.model.PasswordParameterDefinition": "password",
|
||||
}
|
||||
|
||||
type ProjectPipeline struct {
|
||||
Type string `json:"type" description:"type of devops pipeline, in scm or no scm"`
|
||||
Pipeline *NoScmPipeline `json:"pipeline,omitempty" description:"no scm pipeline structs"`
|
||||
MultiBranchPipeline *MultiBranchPipeline `json:"multi_branch_pipeline,omitempty" description:"in scm pipeline structs"`
|
||||
}
|
||||
|
||||
type NoScmPipeline struct {
|
||||
Name string `json:"name" description:"name of pipeline"`
|
||||
Description string `json:"descriptio,omitempty" description:"description of pipeline"`
|
||||
Discarder *DiscarderProperty `json:"discarder,omitempty" description:"Discarder of pipeline, managing when to drop a pipeline"`
|
||||
Parameters *Parameters `json:"parameters,omitempty" description:"Parameters define of pipeline,user could pass param when run pipeline"`
|
||||
DisableConcurrent bool `json:"disable_concurrent,omitempty" mapstructure:"disable_concurrent" description:"Whether to prohibit the pipeline from running in parallel"`
|
||||
TimerTrigger *TimerTrigger `json:"timer_trigger,omitempty" mapstructure:"timer_trigger" description:"Timer to trigger pipeline run"`
|
||||
RemoteTrigger *RemoteTrigger `json:"remote_trigger,omitempty" mapstructure:"remote_trigger" description:"Remote api define to trigger pipeline run"`
|
||||
Jenkinsfile string `json:"jenkinsfile,omitempty" description:"Jenkinsfile's content'"`
|
||||
}
|
||||
|
||||
type MultiBranchPipeline struct {
|
||||
Name string `json:"name" description:"name of pipeline"`
|
||||
Description string `json:"descriptio,omitempty" description:"description of pipeline"`
|
||||
Discarder *DiscarderProperty `json:"discarder,omitempty" description:"Discarder of pipeline, managing when to drop a pipeline"`
|
||||
TimerTrigger *TimerTrigger `json:"timer_trigger,omitempty" mapstructure:"timer_trigger" description:"Timer to trigger pipeline run"`
|
||||
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"`
|
||||
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"`
|
||||
ScriptPath string `json:"script_path" mapstructure:"script_path" description:"script path in scm"`
|
||||
MultiBranchJobTrigger *MultiBranchJobTrigger `json:"multibranch_job_trigger,omitempty" mapstructure:"multibranch_job_trigger" description:"Pipeline tasks that need to be triggered when branch creation/deletion"`
|
||||
}
|
||||
|
||||
type GitSource struct {
|
||||
ScmId string `json:"scm_id,omitempty" description:"uid of scm"`
|
||||
Url string `json:"url,omitempty" mapstructure:"url" description:"url of git source"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access git source"`
|
||||
DiscoverBranches bool `json:"discover_branches,omitempty" mapstructure:"discover_branches" description:"Whether to discover a branch"`
|
||||
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 GithubSource struct {
|
||||
ScmId string `json:"scm_id,omitempty" description:"uid of scm"`
|
||||
Owner string `json:"owner,omitempty" mapstructure:"owner" description:"owner of github repo"`
|
||||
Repo string `json:"repo,omitempty" mapstructure:"repo" description:"repo name of github repo"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access github source"`
|
||||
ApiUri string `json:"api_uri,omitempty" mapstructure:"api_uri" description:"The api url can specify the location of the github 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"`
|
||||
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 MultiBranchJobTrigger struct {
|
||||
CreateActionJobsToTrigger string `json:"create_action_job_to_trigger,omitempty" description:"pipeline name to trigger"`
|
||||
DeleteActionJobsToTrigger string `json:"delete_action_job_to_trigger,omitempty" description:"pipeline name to trigger"`
|
||||
}
|
||||
|
||||
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"`
|
||||
Repo string `json:"repo,omitempty" mapstructure:"repo" description:"repo name of github repo"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access github source"`
|
||||
ApiUri string `json:"api_uri,omitempty" mapstructure:"api_uri" description:"The api url can specify the location of the github 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"`
|
||||
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 GitCloneOption struct {
|
||||
Shallow bool `json:"shallow,omitempty" mapstructure:"shallow" description:"Whether to use git shallow clone"`
|
||||
Timeout int `json:"timeout,omitempty" mapstructure:"timeout" description:"git clone timeout mins"`
|
||||
Depth int `json:"depth,omitempty" mapstructure:"depth" description:"git clone depth"`
|
||||
}
|
||||
|
||||
type SvnSource struct {
|
||||
ScmId string `json:"scm_id,omitempty" description:"uid of scm"`
|
||||
Remote string `json:"remote,omitempty" description:"remote address url"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access svn source"`
|
||||
Includes string `json:"includes,omitempty" description:"branches to run pipeline"`
|
||||
Excludes string `json:"excludes,omitempty" description:"branches do not run pipeline"`
|
||||
}
|
||||
type SingleSvnSource struct {
|
||||
ScmId string `json:"scm_id,omitempty" description:"uid of scm"`
|
||||
Remote string `json:"remote,omitempty" description:"remote address url"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access svn source"`
|
||||
}
|
||||
|
||||
type DiscoverPRFromForks struct {
|
||||
Strategy int `json:"strategy,omitempty" mapstructure:"strategy" description:"github discover strategy"`
|
||||
Trust int `json:"trust,omitempty" mapstructure:"trust" description:"trust user type"`
|
||||
}
|
||||
|
||||
type DiscarderProperty struct {
|
||||
DaysToKeep string `json:"days_to_keep,omitempty" mapstructure:"days_to_keep" description:"days to keep pipeline"`
|
||||
NumToKeep string `json:"num_to_keep,omitempty" mapstructure:"num_to_keep" description:"nums to keep pipeline"`
|
||||
}
|
||||
|
||||
type Parameter struct {
|
||||
Name string `json:"name" description:"name of param"`
|
||||
DefaultValue string `json:"default_value,omitempty" mapstructure:"default_value" description:"default value of param"`
|
||||
Type string `json:"type" description:"type of param"`
|
||||
Description string `json:"description,omitempty" description:"description of pipeline"`
|
||||
}
|
||||
|
||||
type TimerTrigger struct {
|
||||
// user in no scm job
|
||||
Cron string `json:"cron,omitempty" description:"jenkins cron script"`
|
||||
|
||||
// use in multi-branch job
|
||||
Interval string `json:"interval,omitempty" description:"interval ms"`
|
||||
}
|
||||
|
||||
type RemoteTrigger struct {
|
||||
Token string `json:"token,omitempty" description:"remote trigger token"`
|
||||
}
|
||||
import "kubesphere.io/kubesphere/pkg/apis/devops/v1alpha3"
|
||||
|
||||
type ProjectPipelineOperator interface {
|
||||
CreateProjectPipeline(projectId string, pipeline *ProjectPipeline) (string, error)
|
||||
CreateProjectPipeline(projectId string, pipeline *v1alpha3.Pipeline) (string, error)
|
||||
DeleteProjectPipeline(projectId string, pipelineId string) (string, error)
|
||||
UpdateProjectPipeline(projectId string, pipeline *ProjectPipeline) (string, error)
|
||||
GetProjectPipelineConfig(projectId, pipelineId string) (*ProjectPipeline, error)
|
||||
UpdateProjectPipeline(projectId string, pipeline *v1alpha3.Pipeline) (string, error)
|
||||
GetProjectPipelineConfig(projectId, pipelineId string) (*v1alpha3.Pipeline, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user