我正在尝试获取具有特定状态(成功)的作业的作业日志。我已经决定使用递归,但是在一定时间之后,我一直达到一个读取超时值:
//Trigger pipelines
await axios.post(`https://gitlab.com/api/v4/projects/${PROJECT_ID_CREATE}/trigger/pipeline?token=${CREATE_TOKEN}&ref=terraform-v1-mirror`)
.then(async (gitlabPOSTRequest) => {
pipelineId = gitlabPOSTRequest.data.id
console.log(`pipeline_id = ${pipelineId}`)
}, (error) => {
console.log(error)
}
)
let config = {
method: 'GET',
url: `https://gitlab.com/api/v4/projects/${PROJECT_ID_CREATE}/pipelines/${pipelineId}/jobs?scope[]=success`,
headers: {
"PRIVATE-TOKEN": PRIVATE_TOKEN
}
}
//Get Job Id
await axios(config)
.then(async (gitlabGETRequest) => {
for (let gitLabResponse in gitlabGETRequest){
if(JSON.stringify(gitLabResponse.data.name)=='apply'){
jobId = JSON.stringify(gitLabResponse.data.id)
}else {
await axios(config)
}
}
console.log(`Job id : ${JSON.stringify(gitlabGETRequest.data[2].id)}`)
}, (error) => {
console.log(error)
}
)
我这样做对吗?是几个GET请求让GitLab服务器恼火吗?
只需使用范围参数,如:
curl--header“private-token:
来源:DOC