'How can I get the git source code used for a TFS 2018 build during one specific TFS 2018 Release environment?

Objective: A TFS (2018) release with an environment that downloads the source code used for the build (using commit hash I would assume) and zips it up before copying it to a file share.

Current Setup: We are using TFS 2018 server (on premises) and I currently have a build process setup that zips up all of the source code and uploads it as an artifact for the build. The repo is over 2gb and this is a long process to both zip it and then to upload it. Additionally, our release that utilizes this build has more than one environment and all of the environments are forced (as far as I can tell) to then download this artifact even though it's not needed for most of them. I would like the build to just do the build and upload the build output as its artifact and only create the zip of the source when deploying to one specific environment. The source code does not need to be the whole git repo, only the source of the commit from which the build was generated.

Note: All of this is done on a local server with no external connections to the internet though I would not think that will any impact on the solution for this situation.



Solution 1:[1]

You could make Artifacts empty in a release definition, and add tasks in the environment you want to download source code to clone repo, zip it and copy it. Please refer the screenshot below:

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cece Dong - MSFT