Open joker-bai opened 7 months ago
GetBuildFromQueueID函数 已经获取了build内容,可以直接使用
func (j *Jenkins) GetBuildFromQueueID(ctx context.Context, job *Job, queueid int64) (*Build, error) {
task, err := j.GetQueueItem(ctx, queueid)
if err != nil {
return nil, err
}
// Jenkins queue API has about 4.7second quiet period
for task.Raw.Executable.Number == 0 {
time.Sleep(1000 * time.Millisecond)
_, err = task.Poll(ctx)
if err != nil {
return nil, err
}
}
build, err := job.GetBuild(ctx, task.Raw.Executable.Number)
if err != nil {
return nil, err
}
return build, nil
}
通过如下方式执行Jenkins Build,无法拿到具体的Build信息.
gojenkins的版本是v1.1.0 jenkins的版本是2.4.36