Gregory Suvalian
Gregory Suvalian

Reputation: 3842

How do I download artifacts from GitHub during build?

I need as a part of the build process to download contents from external github repository. I set up repository under "services" but I can not find a task which will download artifacts from that repo.

I use TFS 2017 on prem. My repository is already set to Git repo and I need to have one of build steps to pull data from yet another Git repo. How do i do that?

enter image description here

Upvotes: 0

Views: 3464

Answers (1)

Marina Liu
Marina Liu

Reputation: 38136


Build for the same github repo

  • If you want to download artifacts to your local path, you only need to use copy files task in your build definition.

    Get source: select Github and use github token to authoize. If you want CI build, set in Triggers Tab.

    Copy Files: set $(Build.SourcesDirectory) as Source Folder, specify the file you want to download in Contents, set a local path as Target Folder.

    enter image description here

  • If you want to download/publish artifacts to VSTS server or share folder, you can use copy files task and publish build artifacts task in you build defnition.

    Get source: select from github.

    Copy Files: set $(Build.SourcesDirectory) as Source Folder, specify the file you want to download in Contents, set $(build.artifactstagingdirectory) as Target Folder.

    Publish Build Artifacts: set $(build.artifactstagingdirectory) as Path to Publish, select the type you want to publish.

The way to connect github repo for TFS build:

In TFS build definition -> Repository Tab -> select External Git -> click Manage to add an External Git Service Endpoint -> input your github repo URL, username and password -> OK -> Then select the endpoint as connection.


Build for a git repo, and also need to download code from another github repo

You can use Command Line task to clone the github repo to your $(Build.SourcesDirectory) folder.

Settings of command Line task:

Tool: git

Arguments: clone https://github.com/username/repo

enter image description here

Now the code of the github repo is cloned in $(Build.SourcesDirectory)\repo.

Upvotes: 1

Related Questions