Add Filtering, HealthCheck, Better Tests (#350)
feat: add filtering when choosing merge requests (#346) feat: Add healthcheck (#345) refactor: Move to gomock (#349) feat: Makes the remote of the plugin configurable (#348) This is a #MINOR release.
This commit is contained in:
committed by
GitHub
parent
aa5d3c1f52
commit
4ae623cd65
@@ -30,7 +30,7 @@ type GetPipelineAndJobsResponse struct {
|
||||
pipelineHandler fetches information about the current pipeline, and retriggers a pipeline run. For more detailed information
|
||||
about a given job in a pipeline, see the jobHandler function
|
||||
*/
|
||||
func (a *api) pipelineHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func (a *Api) pipelineHandler(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
a.GetPipelineAndJobs(w, r)
|
||||
@@ -44,22 +44,23 @@ func (a *api) pipelineHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
/* Gets the latest pipeline for a given commit, returns an error if there is no pipeline */
|
||||
func (a *api) GetLastPipeline(commit string) (*gitlab.PipelineInfo, error) {
|
||||
func (a *Api) GetLastPipeline(commit string) (*gitlab.PipelineInfo, error) {
|
||||
|
||||
l := &gitlab.ListProjectPipelinesOptions{
|
||||
SHA: gitlab.Ptr(commit),
|
||||
Sort: gitlab.Ptr("desc"),
|
||||
}
|
||||
|
||||
l.Page = 1
|
||||
l.PerPage = 1
|
||||
|
||||
pipes, _, err := a.client.ListProjectPipelines(a.projectInfo.ProjectId, l)
|
||||
pipes, res, err := a.client.ListProjectPipelines(a.projectInfo.ProjectId, l)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if res.StatusCode >= 300 {
|
||||
return nil, errors.New("Could not get pipelines")
|
||||
}
|
||||
|
||||
if len(pipes) == 0 {
|
||||
return nil, errors.New("No pipeline running or available for commit " + commit)
|
||||
}
|
||||
@@ -68,13 +69,12 @@ func (a *api) GetLastPipeline(commit string) (*gitlab.PipelineInfo, error) {
|
||||
}
|
||||
|
||||
/* Gets the latest pipeline and job information for the current branch */
|
||||
func (a *api) GetPipelineAndJobs(w http.ResponseWriter, r *http.Request) {
|
||||
func (a *Api) GetPipelineAndJobs(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
commit, err := a.gitInfo.GetLatestCommitOnRemote(a)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
handleError(w, err, "Error getting commit on remote branch", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func (a *api) GetPipelineAndJobs(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *api) RetriggerPipeline(w http.ResponseWriter, r *http.Request) {
|
||||
func (a *Api) RetriggerPipeline(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
id := strings.TrimPrefix(r.URL.Path, "/pipeline/trigger/")
|
||||
|
||||
Reference in New Issue
Block a user