Skip to content

list_pipelines not returning the full list #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JerryValentine opened this issue Aug 6, 2019 · 3 comments
Closed

list_pipelines not returning the full list #257

JerryValentine opened this issue Aug 6, 2019 · 3 comments

Comments

@JerryValentine
Copy link

Hi,

I am creating a script that will automatically create repositories and set up all of the governance for me, but I have run into a problem. One of the things that I want is to have a build policy on both the develop and master branches of my repository. In order to do this I need to get the pipeline's id. When I create a new repository I then run the code below to add the yml pipeline file and add the develop branch and then try to get the pipelines id from that.

My problem is every time I try to run list_pipelines sometimes it will provide the list including the pipeline that was just made and other times it does not and no mater how many times I call it.

I have found no way to constantly get this problem to happen, but it seems like the more repositories in a project the more likely it is to happen.

`azurePipelineFile = git_client.get_item(repository_id='ado-template-repository',path='/azure-pipelines.yml',project="CloudServices",scope_path=None,recursion_level=None,include_content_metadata=None,latest_processed_change=None,download=False,version_descriptor=None,include_content=True,resolve_lfs=None)
bumpversionFile = git_client.get_item(repository_id='ado-template-repository',path='/.bumpversion.cfg',project="CloudServices",scope_path=None,recursion_level=None,include_content_metadata=None,latest_processed_change=None,download=False,version_descriptor=None,include_content=True,resolve_lfs=None)

refUpdateMaster = GitRefUpdate(is_locked=None, name="refs/heads/master",new_object_id=None,old_object_id="0000000000000000000000000000000000000000")
refUpdateDevelop = GitRefUpdate(is_locked=None, name="refs/heads/develop",new_object_id=None,old_object_id="0000000000000000000000000000000000000000")
commit = GitCommitRef(_links=None,author=None,change_counts=None,changes=[
{
"changeType": "add",
"item": {
"path": "/azure-pipelines.yml"
},
"newContent": {
"content": azurePipelineFile.content,
"contentType": "rawtext"
}
},
{
"changeType": "add",
"item": {
"path": "/.bumpversion.cfg"
},
"newContent": {
"content": bumpversionFile.content,
"contentType": "rawtext"
}
}
],comment="Initial commit",comment_truncated=None,commit_id=None,committer=None,parents=None,push=None,remote_url=None,statuses=None,url=None,work_items=None)

Push the files to the master branch

push = GitPush(_links=None, date=None, push_correlation_id=None, pushed_by=None, push_id=None, url=None, commits=[commit], ref_updates=[refUpdateMaster], repository=None)
git_client.create_push(push=push,repository_id=newRepo.id,project=projectName)

Push the files to the develop branch

push = GitPush(_links=None, date=None, push_correlation_id=None, pushed_by=None, push_id=None, url=None, commits=[commit], ref_updates=[refUpdateDevelop], repository=None)
git_client.create_push(push=push,repository_id=newRepo.id,project=projectName)
#endregion

time.sleep(5)

Find pipeline id

found = False
while not found:
for pipeline in pipeline_client.list_pipelines(project=projectName, order_by=None, top=None, continuation_token=personal_access_token):
if(pipeline.name == (newRepoName + " CI")):
repoPipeline = pipeline
found = True`

@tedchamb
Copy link
Member

tedchamb commented Aug 7, 2019

You should not send in your pat token as the continuation token. They are two different things. The first call to list_pipelines should not supply a continuation_token at all. Use the order_by parameter to return the most recent pipelines, so the data set includes your pipeline you just created.

In the response there is a header called x-ms-continuationtoken, which should be sent in to subsequent calls, to get further pipelines from the query set. Unfortunately we are not providing access to that header yet through the list_pipelines return value, and that is being tracked by issue: #152, which should be fixed soon.

@JerryValentine
Copy link
Author

Thank you for the response that helps me out a lot. So when you say soon are we talking days, weeks, months?

@tedchamb
Copy link
Member

tedchamb commented Aug 7, 2019

within a week or two, probably sooner. This is a side project, so just need to carve out some time.

@tedchamb tedchamb closed this as completed Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants