Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Ensure pulling remote repo use token when located in same TFS server
Browse files Browse the repository at this point in the history
  • Loading branch information
fakhrulhilal committed May 4, 2018
1 parent 626929b commit a3a8315
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
6 changes: 5 additions & 1 deletion GitDownloader/GitDownloader.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,14 @@ Function Update-GitRepository {
git clean -fdx
}
}
# get current fetch uri
$remoteUris = git remote -v
$match = [regex]::Match($remoteUris, '^(origin)\s(?<url>.+)\s\(fetch\)\W')
$fetchUri = $match.Groups['url'].Value
Write-Host "Pulling update from branch/tag $BranchTag"
Invoke-VerboseCommand -Command { git config credential.interactive never }
# try to use token provided by TFS server
If (Test-SameTfsServer -Uri $Uri) {
If (Test-SameTfsServer -Uri $fetchUri) {
$AuthHeader = "Authorization: bearer $($Env:SYSTEM_ACCESSTOKEN)"
Invoke-VerboseCommand -Command { git -c http.extraheader="$AuthHeader" pull origin $BranchTag }
}
Expand Down
4 changes: 2 additions & 2 deletions GitDownloader/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "GitDownloader",
"friendlyName": "Git Repository Downloader",
"description": "Download additional git repository from public repository or this TFS",
"helpMarkDown": "This task will download git repository as an addition to default source. Consider this task as workaround where TFS build with git repository can only download 1 repository. This task assumes that git is already installed in %ProgramFiles%\\Git within TFS build agent's machine.",
"helpMarkDown": "[More information](https://github.com/fakhrulhilal/TFSGitDownloader/blob/master/README.md)",
"category": "Utility",
"visibility": [
"Build",
Expand All @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 2,
"Patch": 11
"Patch": 12
},
"instanceNameFormat": "Fetch git: $(Repository)",
"groups": [
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Git Downloader

This task will download git repository as an addition to default source. Consider this task as workaround where TFS build with git repository can only download 1 repository. Then this task will download another git repository required by your TFS build definition. This task assumes that git is already installed in %ProgramFiles%\\Git within TFS build agent's machine.
This task will download git repository as an addition to default source. Consider this task as workaround where TFS build with git repository can only download 1 repository. Then this task will download another git repository required by your TFS build definition. This task assumes that git is already installed in PATH environment variable or %ProgramFiles%\\Git within TFS build agent's machine.

## Parameters

Expand Down
Binary file modified images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 29 additions & 3 deletions vss-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
"manifestVersion": 1,
"id": "GitDownloader",
"name": "Git Repository Downloader",
"version": "0.2.11",
"version": "0.2.12",
"publisher": "fakhrulhilal-maktum",
"targets": [
{
"id": "Microsoft.VisualStudio.Services"
}
],
"description": "Download additional git repository from public repository or this TFS",
"galleryFlags": [
"Public"
],
"categories": [
"Build and release"
],
Expand All @@ -21,7 +24,12 @@
"default": "images/logo.png"
},
"content": {
"details": { "path": "README.md"}
"details": {
"path": "README.md"
},
"license": {
"path": "LICENSE"
}
},
"files": [
{
Expand All @@ -43,5 +51,23 @@
"name": "GitDownloader"
}
}
]
],
"links": {
"learn": {
"uri": "https://github.com/fakhrulhilal/TFSGitDownloader/blob/master/README.md"
},
"repository": {
"uri": "https://github.com/fakhrulhilal/TFSGitDownloader.git"
},
"license": {
"uri": "https://github.com/fakhrulhilal/TFSGitDownloader/blob/master/LICENSE"
},
"issues": {
"uri": "https://github.com/fakhrulhilal/TFSGitDownloader/issues"
}
},
"repository": {
"type": "git",
"uri": "https://github.com/fakhrulhilal/TFSGitDownloader.git"
}
}

0 comments on commit a3a8315

Please sign in to comment.