Merge branch 'master' into devops2

# Conflicts:
#	pkg/apis/devops/v1alpha2/register.go
This commit is contained in:
runzexia
2019-04-28 11:23:54 +08:00
6 changed files with 1289 additions and 211 deletions

View File

@@ -39,15 +39,9 @@ func init() {
func GetPipeline(projectName, pipelineName string, req *http.Request) (*Pipeline, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+GetPipelineUrl, projectName, pipelineName)
log.Infof("Jenkins-url: " + baseUrl)
resBody, err := jenkinsClient(baseUrl, req)
if err != nil {
log.Error(err)
return nil, err
}
var res = new(Pipeline)
err = json.Unmarshal(resBody, &res)
err := jenkinsClient(baseUrl, req, res)
if err != nil {
log.Error(err)
return nil, err
@@ -59,15 +53,9 @@ func GetPipeline(projectName, pipelineName string, req *http.Request) (*Pipeline
func SearchPipelines(req *http.Request) ([]interface{}, error) {
baseUrl := JenkinsUrl + SearchPipelineUrl + req.URL.RawQuery
log.Infof("Jenkins-url: " + baseUrl)
resBody, err := jenkinsClient(baseUrl, req)
if err != nil {
log.Error(err)
return nil, err
}
var res []interface{}
err = json.Unmarshal(resBody, &res)
err := jenkinsClient(baseUrl, req, &res)
if err != nil {
log.Error(err)
return nil, err
@@ -79,15 +67,9 @@ func SearchPipelines(req *http.Request) ([]interface{}, error) {
func SearchPipelineRuns(projectName, pipelineName string, req *http.Request) ([]interface{}, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+SearchPipelineRunUrl+req.URL.RawQuery, projectName, pipelineName)
log.Infof("Jenkins-url: " + baseUrl)
resBody, err := jenkinsClient(baseUrl, req)
if err != nil {
log.Error(err)
return nil, err
}
var res []interface{}
err = json.Unmarshal(resBody, &res)
err := jenkinsClient(baseUrl, req, &res)
if err != nil {
log.Error(err)
return nil, err
@@ -96,18 +78,12 @@ func SearchPipelineRuns(projectName, pipelineName string, req *http.Request) ([]
return res, err
}
func GetPipelineRun(projectName, pipelineName, branchName, runId string, req *http.Request) (*Pipeline, error) {
func GetPipelineRun(projectName, pipelineName, branchName, runId string, req *http.Request) (*PipelineRun, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+GetPipelineRunUrl, projectName, pipelineName, branchName, runId)
log.Infof("Jenkins-url: " + baseUrl)
var res = new(PipelineRun)
resBody, err := jenkinsClient(baseUrl, req)
if err != nil {
log.Error(err)
return nil, err
}
var res = new(Pipeline)
err = json.Unmarshal(resBody, &res)
err := jenkinsClient(baseUrl, req, res)
if err != nil {
log.Error(err)
return nil, err
@@ -119,15 +95,9 @@ func GetPipelineRun(projectName, pipelineName, branchName, runId string, req *ht
func GetPipelineRunNodes(projectName, pipelineName, branchName, runId string, req *http.Request) ([]interface{}, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+GetPipelineRunNodesUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
log.Infof("Jenkins-url: " + baseUrl)
resBody, err := jenkinsClient(baseUrl, req)
if err != nil {
log.Error(err)
return nil, err
}
var res []interface{}
err = json.Unmarshal(resBody, &res)
err := jenkinsClient(baseUrl, req, &res)
if err != nil {
log.Error(err)
return nil, err
@@ -136,11 +106,11 @@ func GetPipelineRunNodes(projectName, pipelineName, branchName, runId string, re
return res, err
}
func GetStepLog(projectName, pipelineName, branchName, runId, nodeId, stepId string, req *http.Request) ([]byte, error) {
func GetStepLog(projectName, pipelineName, branchName, runId, stepId, nodeId string, req *http.Request) ([]byte, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+GetStepLogUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId, nodeId, stepId)
log.Infof("Jenkins-url: " + baseUrl)
resBody, err := jenkinsClient(baseUrl, req)
resBody, err := Client(baseUrl, req)
if err != nil {
log.Error(err)
return nil, err
@@ -153,7 +123,7 @@ func Validate(scmId string, req *http.Request) ([]byte, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+ValidateUrl, scmId)
log.Infof("Jenkins-url: " + baseUrl)
resBody, err := jenkinsClient(baseUrl, req)
resBody, err := Client(baseUrl, req)
if err != nil {
log.Error(err)
return nil, err
@@ -162,18 +132,12 @@ func Validate(scmId string, req *http.Request) ([]byte, error) {
return resBody, err
}
func GetOrgSCM(scmId string, req *http.Request) ([]interface{}, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+GetOrgSCMUrl+req.URL.RawQuery, scmId)
func GetSCMOrg(scmId string, req *http.Request) ([]interface{}, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+GetSCMOrgUrl+req.URL.RawQuery, scmId)
log.Infof("Jenkins-url: " + baseUrl)
resBody, err := jenkinsClient(baseUrl, req)
if err != nil {
log.Error(err)
return nil, err
}
var res []interface{}
err = json.Unmarshal(resBody, &res)
err := jenkinsClient(baseUrl, req, &res)
if err != nil {
log.Error(err)
return nil, err
@@ -182,8 +146,189 @@ func GetOrgSCM(scmId string, req *http.Request) ([]interface{}, error) {
return res, err
}
// create jenkins request
func jenkinsClient(baseUrl string, req *http.Request) ([]byte, error) {
func GetOrgRepo(scmId, organizationId string, req *http.Request) (*OrgRepo, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+GetOrgRepoUrl+req.URL.RawQuery, scmId, organizationId)
log.Infof("Jenkins-url: " + baseUrl)
var res = new(OrgRepo)
err := jenkinsClient(baseUrl, req, res)
if err != nil {
log.Error(err)
return nil, err
}
return res, err
}
func StopPipeline(projectName, pipelineName, branchName, runId string, req *http.Request) (*StopPipe, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+StopPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
log.Infof("Jenkins-url: " + baseUrl)
var res = new(StopPipe)
err := jenkinsClient(baseUrl, req, res)
if err != nil {
log.Error(err)
return nil, err
}
return res, err
}
func ReplayPipeline(projectName, pipelineName, branchName, runId string, req *http.Request) (*ReplayPipe, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+ReplayPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
log.Infof("Jenkins-url: " + baseUrl)
var res = new(ReplayPipe)
err := jenkinsClient(baseUrl, req, res)
if err != nil {
log.Error(err)
return nil, err
}
return res, err
}
func GetRunLog(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+GetRunLogUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
log.Infof("Jenkins-url: " + baseUrl)
resBody, err := Client(baseUrl, req)
if err != nil {
log.Error(err)
return nil, err
}
return resBody, err
}
func GetArtifacts(projectName, pipelineName, branchName, runId string, req *http.Request) ([]interface{}, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+GetArtifactsUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
log.Infof("Jenkins-url: " + baseUrl)
var res []interface{}
err := jenkinsClient(baseUrl, req, &res)
if err != nil {
log.Error(err)
return nil, err
}
return res, err
}
func GetPipeBranch(projectName, pipelineName string, req *http.Request) ([]interface{}, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+GetPipeBranchUrl+req.URL.RawQuery, projectName, pipelineName)
log.Infof("Jenkins-url: " + baseUrl)
var res []interface{}
err := jenkinsClient(baseUrl, req, &res)
if err != nil {
log.Error(err)
return nil, err
}
return res, err
}
func CheckPipeline(projectName, pipelineName, branchName, runId, nodeId, stepId string, req *http.Request) ([]byte, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+CheckPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId, nodeId, stepId)
log.Infof("Jenkins-url: " + baseUrl)
resBody, err := Client(baseUrl, req)
if err != nil {
log.Error(err)
return nil, err
}
return resBody, err
}
func GetConsoleLog(projectName, pipelineName string, req *http.Request) ([]byte, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+GetConsoleLogUrl+req.URL.RawQuery, projectName, pipelineName)
log.Infof("Jenkins-url: " + baseUrl)
resBody, err := Client(baseUrl, req)
if err != nil {
log.Error(err)
return nil, err
}
return resBody, err
}
func ScanBranch(projectName, pipelineName string, req *http.Request) ([]byte, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+ScanBranchUrl+req.URL.RawQuery, projectName, pipelineName)
log.Infof("Jenkins-url: " + baseUrl)
resBody, err := Client(baseUrl, req)
if err != nil {
log.Error(err)
return nil, err
}
return resBody, err
}
func RunPipeline(projectName, pipelineName, branchName string, req *http.Request) (*QueuedBlueRun, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+RunPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName)
log.Infof("Jenkins-url: " + baseUrl)
var res = new(QueuedBlueRun)
err := jenkinsClient(baseUrl, req, res)
if err != nil {
log.Error(err)
return nil, err
}
return res, err
}
func GetStepsStatus(projectName, pipelineName, branchName, runId, nodeId string, req *http.Request) (*NodeStatus, error) {
baseUrl := fmt.Sprintf(JenkinsUrl+GetStepsStatusUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId, nodeId)
log.Infof("Jenkins-url: " + baseUrl)
var res = new(NodeStatus)
err := jenkinsClient(baseUrl, req, res)
if err != nil {
log.Error(err)
return nil, err
}
return res, err
}
func GetCrumb(req *http.Request) (*Crumb, error) {
baseUrl := fmt.Sprintf(JenkinsUrl + GetCrumbUrl)
log.Infof("Jenkins-url: " + baseUrl)
var res = new(Crumb)
err := jenkinsClient(baseUrl, req, res)
if err != nil {
log.Error(err)
return nil, err
}
return res, err
}
// jenkins request and parse response
func jenkinsClient(baseUrl string, req *http.Request, res interface{}) error {
resBody, err := Client(baseUrl, req)
if err != nil {
log.Error(err)
return err
}
err = json.Unmarshal(resBody, res)
if err != nil {
log.Error(err)
return err
}
return nil
}
// create request
func Client(baseUrl string, req *http.Request) ([]byte, error) {
newReqUrl, err := url.Parse(baseUrl)
if err != nil {
log.Error(err)
@@ -210,11 +355,8 @@ func jenkinsClient(baseUrl string, req *http.Request) ([]byte, error) {
log.Info(string(resBody))
if resp.StatusCode >= http.StatusBadRequest {
jkerr := new(JkError)
err = json.Unmarshal(resBody, jkerr)
if err != nil {
log.Error(err)
return nil, err
}
jkerr.Code = resp.StatusCode
jkerr.Message = http.StatusText(resp.StatusCode)
return nil, jkerr
}

View File

@@ -18,15 +18,8 @@
package devops
type JkError struct {
Message string `json:"message"`
Code int `json:"code"`
Errors []Errors `json:"errors"`
}
type Errors struct {
Message string `json:"message"`
Code string `json:"code"`
Field string `json:"field"`
Code int `json:"code"`
}
func (err *JkError) Error() string {

View File

@@ -17,148 +17,715 @@
*/
package devops
// GetPipeline & SearchPipelines
type Pipeline struct {
Class string `json:"_class,omitempty"`
Links Links `json:"_links,omitempty"`
Actions []interface{} `json:"actions,omitempty"`
DisplayName string `json:"displayName,omitempty"`
FullDisplayName string `json:"fullDisplayName,omitempty"`
FullName string `json:"fullName,omitempty"`
Name interface{} `json:"name,omitempty"`
Organization string `json:"organization,omitempty"`
Parameters interface{} `json:"parameters,omitempty"`
Permissions Permissions `json:"permissions,omitempty"`
EstimatedDurationInMillis int `json:"estimatedDurationInMillis,omitempty"`
NumberOfFolders int `json:"numberOfFolders,omitempty"`
NumberOfPipelines int `json:"numberOfPipelines,omitempty"`
PipelineFolderNames []interface{} `json:"pipelineFolderNames,omitempty"`
WeatherScore int `json:"weatherScore,omitempty"`
BranchNames []string `json:"branchNames,omitempty"`
NumberOfFailingBranches int `json:"numberOfFailingBranches,omitempty"`
NumberOfFailingPullRequests int `json:"numberOfFailingPullRequests,omitempty"`
NumberOfSuccessfulBranches int `json:"numberOfSuccessfulBranches,omitempty"`
NumberOfSuccessfulPullRequests int `json:"numberOfSuccessfulPullRequests,omitempty"`
ScmSource ScmSource `json:"scmSource,omitempty"`
TotalNumberOfBranches int `json:"totalNumberOfBranches,omitempty"`
TotalNumberOfPullRequests int `json:"totalNumberOfPullRequests,omitempty"`
ArtifactsZipFile interface{} `json:"artifactsZipFile,omitempty"`
CauseOfBlockage interface{} `json:"causeOfBlockage,omitempty"`
Causes []Causes `json:"causes,omitempty"`
ChangeSet []interface{} `json:"changeSet,omitempty"`
Description interface{} `json:"description,omitempty"`
DurationInMillis int `json:"durationInMillis,omitempty"`
EnQueueTime string `json:"enQueueTime,omitempty"`
EndTime string `json:"endTime,omitempty"`
ID string `json:"id,omitempty"`
Pipeline string `json:"pipeline,omitempty"`
Replayable bool `json:"replayable,omitempty"`
Result string `json:"result,omitempty"`
RunSummary string `json:"runSummary,omitempty"`
StartTime string `json:"startTime,omitempty"`
State string `json:"state,omitempty"`
Type string `json:"type,omitempty"`
Branch Branch `json:"branch,omitempty"`
CommitID string `json:"commitId,omitempty"`
CommitURL interface{} `json:"commitUrl,omitempty"`
PullRequest interface{} `json:"pullRequest,omitempty"`
}
type Self struct {
Class string `json:"_class,omitempty"`
Href string `json:"href,omitempty"`
}
type Scm struct {
Class string `json:"_class,omitempty"`
Href string `json:"href,omitempty"`
}
type Branches struct {
Class string `json:"_class,omitempty"`
Href string `json:"href,omitempty"`
}
type Actions struct {
Class string `json:"_class,omitempty"`
Href string `json:"href,omitempty"`
}
type Runs struct {
Class string `json:"_class,omitempty"`
Href string `json:"href,omitempty"`
}
type Trends struct {
Class string `json:"_class,omitempty"`
Href string `json:"href,omitempty"`
}
type Queue struct {
Class string `json:"_class,omitempty"`
Href string `json:"href,omitempty"`
}
type Links struct {
Self Self `json:"self,omitempty"`
Scm Scm `json:"scm,omitempty"`
Branches Branches `json:"branches,omitempty"`
Actions Actions `json:"actions,omitempty"`
Runs Runs `json:"runs,omitempty"`
Trends Trends `json:"trends,omitempty"`
Queue Queue `json:"queue,omitempty"`
PrevRun PrevRun `json:"prevRun"`
Parent Parent `json:"parent"`
Tests Tests `json:"tests"`
Nodes Nodes `json:"nodes"`
Log Log `json:"log"`
BlueTestSummary BlueTestSummary `json:"blueTestSummary"`
Steps Steps `json:"steps"`
Artifacts Artifacts `json:"artifacts"`
}
type Permissions struct {
Create bool `json:"create,omitempty"`
Configure bool `json:"configure,omitempty"`
Read bool `json:"read,omitempty"`
Start bool `json:"start,omitempty"`
Stop bool `json:"stop,omitempty"`
}
type ScmSource struct {
Class string `json:"_class,omitempty"`
APIURL interface{} `json:"apiUrl,omitempty"`
ID string `json:"id,omitempty"`
}
type PrevRun struct {
Class string `json:"_class"`
Href string `json:"href"`
Links struct {
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
Scm struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"scm"`
Branches struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"branches"`
Actions struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"actions"`
Runs struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"runs"`
Trends struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"trends"`
Queue struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"queue"`
} `json:"_links"`
Actions []interface{} `json:"actions"`
Disabled interface{} `json:"disabled"`
DisplayName string `json:"displayName"`
FullDisplayName string `json:"fullDisplayName"`
FullName string `json:"fullName"`
Name string `json:"name"`
Organization string `json:"organization"`
Parameters interface{} `json:"parameters"`
Permissions struct {
Create bool `json:"create"`
Configure bool `json:"configure"`
Read bool `json:"read"`
Start bool `json:"start"`
Stop bool `json:"stop"`
} `json:"permissions"`
EstimatedDurationInMillis int `json:"estimatedDurationInMillis"`
NumberOfFolders int `json:"numberOfFolders"`
NumberOfPipelines int `json:"numberOfPipelines"`
PipelineFolderNames []interface{} `json:"pipelineFolderNames"`
WeatherScore int `json:"weatherScore"`
BranchNames []string `json:"branchNames"`
NumberOfFailingBranches int `json:"numberOfFailingBranches"`
NumberOfFailingPullRequests int `json:"numberOfFailingPullRequests"`
NumberOfSuccessfulBranches int `json:"numberOfSuccessfulBranches"`
NumberOfSuccessfulPullRequests int `json:"numberOfSuccessfulPullRequests"`
ScmSource struct {
Class string `json:"_class"`
APIURL interface{} `json:"apiUrl"`
ID string `json:"id"`
} `json:"scmSource"`
TotalNumberOfBranches int `json:"totalNumberOfBranches"`
TotalNumberOfPullRequests int `json:"totalNumberOfPullRequests"`
}
type Parent struct {
// GetPipelineRun & SearchPipelineRuns
type PipelineRun struct {
Class string `json:"_class"`
Href string `json:"href"`
Links struct {
PrevRun struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"prevRun"`
Parent struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"parent"`
Tests struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"tests"`
Nodes struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"nodes"`
Log struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"log"`
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
BlueTestSummary struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"blueTestSummary"`
Actions struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"actions"`
Steps struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"steps"`
Artifacts struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"artifacts"`
NextRun struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"nextRun"`
} `json:"_links"`
Actions []interface{} `json:"actions"`
ArtifactsZipFile interface{} `json:"artifactsZipFile"`
CauseOfBlockage interface{} `json:"causeOfBlockage"`
Causes []struct {
Class string `json:"_class"`
ShortDescription string `json:"shortDescription"`
UserID string `json:"userId"`
UserName string `json:"userName"`
} `json:"causes"`
ChangeSet []interface{} `json:"changeSet"`
Description interface{} `json:"description"`
DurationInMillis int `json:"durationInMillis"`
EnQueueTime string `json:"enQueueTime"`
EndTime string `json:"endTime"`
EstimatedDurationInMillis int `json:"estimatedDurationInMillis"`
ID string `json:"id"`
Name interface{} `json:"name"`
Organization string `json:"organization"`
Pipeline string `json:"pipeline"`
Replayable bool `json:"replayable"`
Result string `json:"result"`
RunSummary string `json:"runSummary"`
StartTime string `json:"startTime"`
State string `json:"state"`
Type string `json:"type"`
Branch struct {
IsPrimary bool `json:"isPrimary"`
Issues []interface{} `json:"issues"`
URL string `json:"url"`
} `json:"branch"`
CommitID string `json:"commitId"`
CommitURL interface{} `json:"commitUrl"`
PullRequest interface{} `json:"pullRequest"`
}
type Tests struct {
// GetPipelineRunNodes
type Nodes []struct {
Class string `json:"_class"`
Href string `json:"href"`
Links struct {
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
Actions struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"actions"`
Steps struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"steps"`
} `json:"_links"`
Actions []interface{} `json:"actions"`
DisplayDescription interface{} `json:"displayDescription"`
DisplayName string `json:"displayName"`
DurationInMillis int `json:"durationInMillis"`
ID string `json:"id"`
Input interface{} `json:"input"`
Result string `json:"result"`
StartTime string `json:"startTime"`
State string `json:"state"`
Type string `json:"type"`
CauseOfBlockage interface{} `json:"causeOfBlockage"`
Edges []struct {
Class string `json:"_class"`
ID string `json:"id"`
Type string `json:"type"`
} `json:"edges"`
FirstParent interface{} `json:"firstParent"`
Restartable bool `json:"restartable"`
Steps []struct {
Class string `json:"_class"`
Links struct {
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
Actions struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"actions"`
} `json:"_links"`
Actions []struct {
Class string `json:"_class"`
Links struct {
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
URLName string `json:"urlName"`
} `json:"actions"`
DisplayDescription interface{} `json:"displayDescription"`
DisplayName string `json:"displayName"`
DurationInMillis int `json:"durationInMillis"`
ID string `json:"id"`
Input interface{} `json:"input"`
Result string `json:"result"`
StartTime string `json:"startTime"`
State string `json:"state"`
Type string `json:"type"`
} `json:"steps"`
}
type Nodes struct {
// Validate
type Validates struct {
CredentialID string `json:"credentialId,omitempty"`
}
// GetSCMOrg
type SCMOrg struct {
Class string `json:"_class"`
Href string `json:"href"`
Links struct {
Repositories struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"repositories"`
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
Avatar string `json:"avatar"`
JenkinsOrganizationPipeline bool `json:"jenkinsOrganizationPipeline"`
Name string `json:"name"`
}
type Log struct {
// GetOrgRepo
type OrgRepo struct {
Class string `json:"_class"`
Href string `json:"href"`
Links struct {
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
Repositories struct {
Class string `json:"_class"`
Links struct {
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
Items []struct {
Class string `json:"_class"`
Links struct {
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
DefaultBranch string `json:"defaultBranch"`
Description string `json:"description"`
Name string `json:"name"`
Permissions struct {
Admin bool `json:"admin"`
Push bool `json:"push"`
Pull bool `json:"pull"`
} `json:"permissions"`
Private bool `json:"private"`
FullName string `json:"fullName"`
} `json:"items"`
LastPage interface{} `json:"lastPage"`
NextPage interface{} `json:"nextPage"`
PageSize int `json:"pageSize"`
} `json:"repositories"`
}
type BlueTestSummary struct {
// StopPipeline
type StopPipe struct {
Class string `json:"_class"`
Href string `json:"href"`
Links struct {
Parent struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"parent"`
Tests struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"tests"`
Nodes struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"nodes"`
Log struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"log"`
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
BlueTestSummary struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"blueTestSummary"`
Actions struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"actions"`
Steps struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"steps"`
Artifacts struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"artifacts"`
} `json:"_links"`
Actions []interface{} `json:"actions"`
ArtifactsZipFile interface{} `json:"artifactsZipFile"`
CauseOfBlockage interface{} `json:"causeOfBlockage"`
Causes []struct {
Class string `json:"_class"`
ShortDescription string `json:"shortDescription"`
} `json:"causes"`
ChangeSet []interface{} `json:"changeSet"`
Description interface{} `json:"description"`
DurationInMillis int `json:"durationInMillis"`
EnQueueTime string `json:"enQueueTime"`
EndTime string `json:"endTime"`
EstimatedDurationInMillis int `json:"estimatedDurationInMillis"`
ID string `json:"id"`
Name interface{} `json:"name"`
Organization string `json:"organization"`
Pipeline string `json:"pipeline"`
Replayable bool `json:"replayable"`
Result string `json:"result"`
RunSummary string `json:"runSummary"`
StartTime string `json:"startTime"`
State string `json:"state"`
Type string `json:"type"`
Branch struct {
IsPrimary bool `json:"isPrimary"`
Issues []interface{} `json:"issues"`
URL string `json:"url"`
} `json:"branch"`
CommitID string `json:"commitId"`
CommitURL interface{} `json:"commitUrl"`
PullRequest interface{} `json:"pullRequest"`
}
type Steps struct {
// ReplayPipeline
type ReplayPipe struct {
Class string `json:"_class"`
Href string `json:"href"`
Links struct {
Parent struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"parent"`
Tests struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"tests"`
Log struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"log"`
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
BlueTestSummary struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"blueTestSummary"`
Actions struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"actions"`
Artifacts struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"artifacts"`
} `json:"_links"`
Actions []interface{} `json:"actions"`
ArtifactsZipFile interface{} `json:"artifactsZipFile"`
CauseOfBlockage string `json:"causeOfBlockage"`
Causes []struct {
Class string `json:"_class"`
ShortDescription string `json:"shortDescription"`
UserID string `json:"userId,omitempty"`
UserName string `json:"userName,omitempty"`
} `json:"causes"`
ChangeSet []interface{} `json:"changeSet"`
Description interface{} `json:"description"`
DurationInMillis interface{} `json:"durationInMillis"`
EnQueueTime interface{} `json:"enQueueTime"`
EndTime interface{} `json:"endTime"`
EstimatedDurationInMillis interface{} `json:"estimatedDurationInMillis"`
ID string `json:"id"`
Name interface{} `json:"name"`
Organization string `json:"organization"`
Pipeline string `json:"pipeline"`
Replayable bool `json:"replayable"`
Result string `json:"result"`
RunSummary interface{} `json:"runSummary"`
StartTime interface{} `json:"startTime"`
State string `json:"state"`
Type string `json:"type"`
QueueID string `json:"queueId"`
}
// GetArtifacts
type Artifacts struct {
Class string `json:"_class"`
Href string `json:"href"`
Links struct {
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
Downloadable bool `json:"downloadable"`
ID string `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
Size int `json:"size"`
URL string `json:"url"` // The url for Download artifacts
}
type Causes struct {
Class string `json:"_class"`
ShortDescription string `json:"shortDescription"`
UserID string `json:"userId,omitempty"`
UserName string `json:"userName,omitempty"`
// GetPipeBranch
type PipeBranch struct {
Class string `json:"_class"`
Links struct {
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
Scm struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"scm"`
Actions struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"actions"`
Runs struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"runs"`
Trends struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"trends"`
Queue struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"queue"`
} `json:"_links"`
Actions []interface{} `json:"actions"`
Disabled bool `json:"disabled"`
DisplayName string `json:"displayName"`
EstimatedDurationInMillis int `json:"estimatedDurationInMillis"`
FullDisplayName string `json:"fullDisplayName"`
FullName string `json:"fullName"`
LatestRun struct {
Class string `json:"_class"`
Links struct {
PrevRun struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"prevRun"`
Parent struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"parent"`
Tests struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"tests"`
Log struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"log"`
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
BlueTestSummary struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"blueTestSummary"`
Actions struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"actions"`
Artifacts struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"artifacts"`
} `json:"_links"`
Actions []interface{} `json:"actions"`
ArtifactsZipFile string `json:"artifactsZipFile"`
CauseOfBlockage interface{} `json:"causeOfBlockage"`
Causes []struct {
Class string `json:"_class"`
ShortDescription string `json:"shortDescription"`
} `json:"causes"`
ChangeSet []interface{} `json:"changeSet"`
Description interface{} `json:"description"`
DurationInMillis int `json:"durationInMillis"`
EnQueueTime string `json:"enQueueTime"`
EndTime string `json:"endTime"`
EstimatedDurationInMillis int `json:"estimatedDurationInMillis"`
ID string `json:"id"`
Name interface{} `json:"name"`
Organization string `json:"organization"`
Pipeline string `json:"pipeline"`
Replayable bool `json:"replayable"`
Result string `json:"result"`
RunSummary string `json:"runSummary"`
StartTime string `json:"startTime"`
State string `json:"state"`
Type string `json:"type"`
} `json:"latestRun"`
Name string `json:"name"`
Organization string `json:"organization"`
Parameters []struct {
Class string `json:"_class"`
DefaultParameterValue struct {
Class string `json:"_class"`
Name string `json:"name"`
Value string `json:"value"`
} `json:"defaultParameterValue"`
Description string `json:"description"`
Name string `json:"name"`
Type string `json:"type"`
} `json:"parameters"`
Permissions struct {
Create bool `json:"create"`
Configure bool `json:"configure"`
Read bool `json:"read"`
Start bool `json:"start"`
Stop bool `json:"stop"`
} `json:"permissions"`
WeatherScore int `json:"weatherScore"`
Branch struct {
IsPrimary bool `json:"isPrimary"`
Issues []interface{} `json:"issues"`
URL string `json:"url"`
} `json:"branch"`
}
type Branch struct {
IsPrimary bool `json:"isPrimary"`
Issues []interface{} `json:"issues"`
URL string `json:"url"`
// RunPipeline
type RunPayload struct {
Parameters []struct {
Name string `json:"name"`
Value string `json:"value"`
} `json:"parameters"`
}
type QueuedBlueRun struct {
Class string `json:"_class"`
Links struct {
Parent struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"parent"`
Tests struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"tests"`
Log struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"log"`
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
BlueTestSummary struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"blueTestSummary"`
Actions struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"actions"`
Artifacts struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"artifacts"`
} `json:"_links"`
Actions []interface{} `json:"actions"`
ArtifactsZipFile interface{} `json:"artifactsZipFile"`
CauseOfBlockage string `json:"causeOfBlockage"`
Causes []struct {
Class string `json:"_class"`
ShortDescription string `json:"shortDescription"`
UserID string `json:"userId"`
UserName string `json:"userName"`
} `json:"causes"`
ChangeSet []interface{} `json:"changeSet"`
Description interface{} `json:"description"`
DurationInMillis interface{} `json:"durationInMillis"`
EnQueueTime interface{} `json:"enQueueTime"`
EndTime interface{} `json:"endTime"`
EstimatedDurationInMillis interface{} `json:"estimatedDurationInMillis"`
ID string `json:"id"`
Name interface{} `json:"name"`
Organization string `json:"organization"`
Pipeline string `json:"pipeline"`
Replayable bool `json:"replayable"`
Result string `json:"result"`
RunSummary interface{} `json:"runSummary"`
StartTime interface{} `json:"startTime"`
State string `json:"state"`
Type string `json:"type"`
QueueID string `json:"queueId"`
}
// GetNodeStatus
type NodeStatus []struct {
Class string `json:"_class"`
Links struct {
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
Actions struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"actions"`
Steps struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"steps"`
} `json:"_links"`
Actions []interface{} `json:"actions"`
DisplayDescription interface{} `json:"displayDescription"`
DisplayName string `json:"displayName"`
DurationInMillis int `json:"durationInMillis"`
ID string `json:"id"`
Input interface{} `json:"input"`
Result string `json:"result"`
StartTime string `json:"startTime"`
State string `json:"state"`
Type string `json:"type"`
CauseOfBlockage interface{} `json:"causeOfBlockage"`
Edges []struct {
Class string `json:"_class"`
ID string `json:"id"`
Type string `json:"type"`
} `json:"edges"`
FirstParent interface{} `json:"firstParent"`
Restartable bool `json:"restartable"`
Steps []struct {
Class string `json:"_class"`
Links struct {
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
Actions struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"actions"`
} `json:"_links"`
Actions []struct {
Class string `json:"_class"`
Links struct {
Self struct {
Class string `json:"_class"`
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
URLName string `json:"urlName"`
} `json:"actions"`
DisplayDescription interface{} `json:"displayDescription"`
DisplayName string `json:"displayName"`
DurationInMillis int `json:"durationInMillis"`
ID string `json:"id"`
Input interface{} `json:"input"`
Result string `json:"result"`
StartTime string `json:"startTime"`
State string `json:"state"`
Type string `json:"type"`
} `json:"steps"`
}
// CheckPipeline
type CheckPlayload struct {
ID string `json:"id"`
Parameters []struct {
Name string `json:"name"`
Value string `json:"value"`
} `json:"parameters"`
}
// Getcrumb
type Crumb struct {
Class string `json:"_class"`
Crumb string `json:"crumb"`
CrumbRequestField string `json:"crumbRequestField"`
}

View File

@@ -26,5 +26,17 @@ const (
GetPipelineRunNodesUrl = "/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/%s/nodes/?"
GetStepLogUrl = "/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/%s/nodes/%s/steps/%s/log/?"
ValidateUrl = "/blue/rest/organizations/jenkins/scm/%s/validate"
GetOrgSCMUrl = "/blue/rest/organizations/jenkins/scm/%s/organizations/?"
GetSCMOrgUrl = "/blue/rest/organizations/jenkins/scm/%s/organizations/?"
GetOrgRepoUrl = "/blue/rest/organizations/jenkins/scm/%s/organizations/%s/repositories/?"
StopPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/stop/?"
ReplayPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/replay/"
GetRunLogUrl = "/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/%s/log/?"
GetArtifactsUrl = "/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/%s/artifacts/?"
GetPipeBranchUrl = "/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/?"
GetConsoleLogUrl = "/job/%s/job/%s/indexing/consoleText"
ScanBranchUrl = "/job/%s/job/%s/build?"
RunPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/"
GetStepsStatusUrl = "/blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/%s/nodes/%s/steps/?"
CheckPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/nodes/%s/steps/%s/"
GetCrumbUrl = "/crumbIssuer/api/json/"
)