Need to create a CICD pipeline with yaml using TFVC repository.
See this doc: Two types of repositories the pipelines support.
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.
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
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.
© 2022 - 2024 — McMap. All rights reserved.