azure-devops-cli-extension icon indicating copy to clipboard operation
azure-devops-cli-extension copied to clipboard

Cannot create a pipeline with yaml file from another Project

Open jwikman opened this issue 5 years ago • 5 comments

Cannot create a pipeline with yaml file from a repo in another Project

Command Name az pipelines create Extension Name: azure-devops. Version: 0.18.0.

Errors:

request failed: Operation returned a 404 status code.

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Create Azure DevOps Project1 and Project2
  • Create repository Repo1 in Project1
  • Add a yaml pipeline definition in Repo1
  • run az pipelines create to create a pipeline in Project2 with yaml pipeline from Project1/Repo1. Use the git clone url as repository parameter
    • Note that argument values have been replaced by {}
    • az pipelines create --name {} --org {} --project {} --repository {} --yml-path {} --branch {} --output {} --skip-first-run {} --debug

The 404 error seems to come from a http GET to list repos, and it tries to list Repo1 in Project2 hence the 404 (file not found) error: GET https://dev.azure.com/[org]/[Project2]/_apis/git/repositories/[Repo1]

Expected Behavior

The pipeline should be created in Project2, but the yaml pipeline definition will stay in Repo1 in Project1. This is now only possible in the UI. Since I'm using the git clone url of the repo, all needed info is provided.

Environment Summary

Windows-10-10.0.18362-SP0
Python 3.6.6
Installer: MSI

azure-cli 2.7.0

Extensions:
azure-devops 0.18.0

jwikman avatar Jun 16 '20 14:06 jwikman

Hi,

I've the same issue. How can I do a workaround to that?

Best regards,

jarpsimoes avatar Sep 03 '20 09:09 jarpsimoes

@jarpsimoes I worked around this by using DevOps API for this instead: https://docs.microsoft.com/en-us/rest/api/azure/devops/build/definitions/create?view=azure-devops-rest-5.1

jwikman avatar Sep 03 '20 09:09 jwikman

I've gotten this problem when using a tfsgit repository type where the repository URL had a space in it. I fixed it by renaming the URL such that it doesn't have a space.

From "Repos":

  1. Click the "v" drop down button (your project name) at the top of the screen.
  2. Select "Manage Repositories"
  3. Find your repository
  4. Click "Rename" button and rename it without the space

tkellogg avatar Jan 09 '21 01:01 tkellogg

@jwikman How did you manage to use the API you linked to create a pipeline based on a YAML definition? I do not see any parts of the body to do so. There is also https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/pipelines/create?view=azure-devops-rest-6.1, but doc seems broken as body is inconsistent and I was not successful either. Also tried to snif it from the UI, but as you said it is using neither of the documented APIs for it.

ggirard07 avatar Apr 23 '21 01:04 ggirard07

Hi, can confirm that this issue is still present.

WimSchmitz avatar Jun 15 '24 21:06 WimSchmitz