Reputation: 1055
Trying to download a second github (private) repo into a build pipeline for azure-devops. But having issues. The MS "github download release" task seems to have a bug related to downloading tags (It completes successfully but downloads 0 files etc). Been trying to do it via bash, via ssh, pat and cant find a way to download a task without need to manual put in either passwords or some sort of intervention is needed.
Does anyone have steps / guide on how to download from a private github with specific tag that involves 0 user interaction?
Upvotes: 0
Views: 983
Reputation: 30383
If your pipeline is Classic UI pipeline. You can add a script task to download from your private github by running the git commands. See below steps:
Classic Pipeline
1, Create variables username
and password
(change the variable type to secret for password) in Variables tab.
if your password or username contain @ replace it with %40
2, Add a powershell task to run below inline git clone commands:
git config --global advice.detachedHead false
git clone -b mytag --depth 1 https://$(username):$(password)@github.com/mygitaccount/myrepo.git -q
Then your private github repo will be downloaded to the folder $(system.defaultworkingdirectory)/myrepo
.
Yaml Pipeline
If you are using Yaml pipeline. Besides of above workaround of running git commands in script tasks, you can also use repository resources and checkout step.
First, you need to create a github service connection(eg. MyPrivateRepoConnection
in below example) to connect to your private github repo with your azure organization.
Then define repository resources and checkout step in your yaml pipeline. See below example:
resources:
repositories:
- repository: privaterepo
type: github
name: myorg/myrepo
ref: refs/tags/mytag
endpoint: MyPrivateRepoConnection
steps:
- checkout: self #checkout the self source code of this pipeline
- checkout: privaterepo #checkout private repo
Upvotes: 2