How can I create build pipeline with Yaml using TFVC?
Asked Answered
M

3

9

Need to create a CICD pipeline with yaml using TFVC repository.

Microcosm answered 4/9, 2019 at 15:34 Comment(0)
H
9

See this doc: Two types of repositories the pipelines support.

enter image description here

Until now, YAML only supports repositories of git type, and we haven't expanded the feature and YAML grammar to support YAML for TFVC repository.

The only workaround is to migrate your repository from TFVC to Git, but I cannot be sure whether it is feasible for you to migrate, especially if your repository is a bit old. If repos are a little old, migration will make it lose much history including old commits and builds.

On our official suggestion forum, there are many users that have the same demand as you: Make YAML support TFVC. You can vote and comment with your demand there. Our Product Group team and corresponding PMs will review these suggestions and consider take it into the development plan to bring a more flexible experience for the user.

He answered 5/9, 2019 at 2:52 Comment(0)
P
4

Not sure if that fits your needs: You can also run your pipeline from a git repo and download the tf vc sources via powershell task and REST (see Azure pipeline build bring TFVC project references into git build) .

For CI trigger:

  • create a classic pipeline and configure the TFVC trigger appropriatly
  • Trigger your yaml pipeline via REST e. g. in powershell:
      $createReleaseBody = 
      @"
      {
            "definition": {
                "id": $YamlPipelineId
            },
            "sourceBranch": "$branch",
            "requestedFor": "$authorId",
            "parameters": "{ tfvcChangesetId: $(BUILD.SOURCEVERSION), YamlTriggerBuildId: $(Build.BuildId) }",
      }
      "@
    
      $triggeredBuild = Invoke-RestMethod -Uri "https://*******.com/tfs/*****/_apis/build/builds?api-version=6.0" -Method post -Headers $AzureDevOpsAuthenicationHeader -Body $createReleaseBody -ContentType 'application/json'
    
      

YAML pipeline:

  • Create a git repo that holds only the pipeline's code (i. e. *.yml files)
  • Create for each branch you have in TFS a branch in git (the pipeline will be triggered with that branch using the powershell snippet above)
  • Add variables (in webui) according to parameters in request body above
  • Download the TFVC sources with the given $(tfvcChangesetId)
  • In my case the TFVC download task was not powerful enough to handle our complex mappings. Thus I use a lengthy powershell script that works with tf.exe directly.

Experiences after two years:

  • The trigger mechanism (classic + REST) is bullit proof and works fine
  • Developing new features in the yaml pipeline is easy and works well
  • Only downside: Merge efforts for our 10+ branches is annoying

Hints:

  • Tag the classic build with "success", "failed", "canceled" depending on the result of your yaml pipeline
  • Add a markdown build summary to your YAML build that contains details about the TFVC checkin
  • Modify the displayed branch in your classic pipeline to make it more intuitive
Polite answered 19/2, 2021 at 9:0 Comment(1)
This strategy works really well as an initial step for the TFVC to GIT migration, at least for the azure pipelines part, and especially good for convincing managers of companies which cannot endure such breaking changes all at once. Huge legacy repositories with delicate software development process tools connected to a TFVC repository with several branches cannot be migrated all at once: the task is quite risky and too expensive for most companies. And that is why TFVC still exist in many companies.Perjure
B
3

YAML pipelines are only supported with GIT repositories, although this is not well documented by Microsoft. You will not be able to use YAML to build your pipelines in TFVC. While its not a option for everyone, you could look into converting your TFVC project into a GIT repository.

Azure DevOps TFVC to GIT Conversion

Broody answered 4/9, 2019 at 22:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.