@@ -78,6 +78,21 @@ export interface MergeRequestPipeline {
7878 status : PipelineStatus ;
7979}
8080
81+ export enum PipelineJobStatus {
82+ Manual = 'manual' ,
83+ Failed = 'failed' ,
84+ Canceled = 'canceled' ,
85+ Pending = 'pending' ,
86+ Started = 'started' ,
87+ Running = 'running' ,
88+ }
89+
90+ export interface PipelineJob {
91+ id : number ;
92+ allow_failure : boolean ;
93+ status : PipelineJobStatus ;
94+ }
95+
8196export interface MergeRequestInfo extends MergeRequest {
8297 sha : string ;
8398 diff_refs : {
@@ -137,6 +152,10 @@ export class GitlabApi {
137152 return this . sendRequestWithMultiResponse ( `/api/v4/projects/${ projectId } /merge_requests/${ mergeRequestIid } /pipelines` , RequestMethod . Get ) ;
138153 }
139154
155+ public async getPipelineJobs ( projectId : number , pipelineId : number ) : Promise < PipelineJob [ ] > {
156+ return this . sendRequestWithMultiResponse ( `/api/v4/projects/${ projectId } /pipelines/${ pipelineId } /jobs` , RequestMethod . Get ) ;
157+ }
158+
140159 public async getMergeRequestApprovals ( projectId : number , mergeRequestIid : number ) : Promise < MergeRequestApprovals > {
141160 return this . sendRequestWithSingleResponse ( `/api/v4/projects/${ projectId } /merge_requests/${ mergeRequestIid } /approvals` , RequestMethod . Get ) ;
142161 }
@@ -168,6 +187,11 @@ export class GitlabApi {
168187 this . validateResponseStatus ( response ) ;
169188 }
170189
190+ public async runJob ( projectId : number , jobId : number ) : Promise < void > {
191+ const response = await this . sendRawRequest ( `/api/v4/projects/${ projectId } /jobs/${ jobId } /play` , RequestMethod . Post ) ;
192+ this . validateResponseStatus ( response ) ;
193+ }
194+
171195 private async sendRequestWithSingleResponse ( url : string , method : RequestMethod , body ?: ParsedUrlQueryInput ) : Promise < any > {
172196 const response = await this . sendRawRequest ( url , method , body ) ;
173197 this . validateResponseStatus ( response ) ;
0 commit comments