Im trying to get list of all the pipelines and all the jobs from Gitlab that ran in a day using graphql API, Here is the query I have
我正在尝试使用GraphQL API从GitLab获取在一天内运行的所有管道和所有作业的列表,以下是我的查询
query = """
query($projectPath: ID!, $pipelineCursor: String, $jobCursor: String) {
project(fullPath: $projectPath) {
pipelines(updatedAfter:"2023-09-06T00:00:00Z",updatedBefore:"2023-09-06T23:59:59Z",status:SUCCESS,first: 100,after: $pipelineCursor,source:"pipeline") {
pageInfo{
hasNextPage
endCursor
}
count
nodes {
jobs(first: 100, after: $jobCursor) {
pageInfo {
hasNextPage
endCursor
}
nodes {
id
status
name
}
}
id
createdAt
startedAt
updatedAt
project {
id
webUrl
}
ref
status
createdAt
startedAt
updatedAt
duration
queuedDuration
user {
username
}
configSource
}
}
}
}
"""
response = requests.post(
api_url,
json={
"query": query,
"variables": {
"projectPath": project_path,
"pipelineCursor": pipeline_cursor,
"jobCursor": job_cursor,
}
},
headers=headers
)
Im able to get list of all the pipelines but only getting 100 jobs per pipeline. Can anyone please take a look at my query and suggest me what needs to be changed.
我能够得到所有管道的列表,但每个管道只得到100个工作。任何人都可以看看我的查询,并建议我需要改变什么。
Note: pipelineCursor loop is working as expected but jobCursor is not looping through all the pages
注意:PipelineCursor循环按预期工作,但jobCursor没有循环遍历所有页面
更多回答
优秀答案推荐
You have limited jobs to 100 with:
您的工作限制为100个,具有:
jobs(first: 100, after: $jobCursor) {
This is a paginated query so you'll have to run it multiple times to get the remaining jobs. Or you could increase the value of first
.
这是一个分页查询,因此您必须多次运行它才能获得剩余的作业。或者您可以增加First的值。
更多回答
我是一名优秀的程序员,十分优秀!