This should be a stupid simple thing to do... Simply need to use a powershell task to download a .js file from an azure repository using the powershell task tell the azure agent server to run a command to import the .js into a mongodb load file.
This is new to me but I did some looking into how. What I came up with.
#Download to local path from Azure Repository
$organization = "HappyBalloons"
$project = "99RedBalloons"
$repository = "BagofBalloons"
$path = "/api/red2/front-end-happy/_Mike99Balloon.js"
$version = "99main"
$pat = "$(System.AccessToken)"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($pat)"))
$url = "https://dev.azure.com/repositoryURL"
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method Get
# Download File
$response.content | Set-Content -Path "$(System.DefaultWorkingDirectory)/downloaded-files/_Mike99Balloon.js" -Force
#FilePath
$FilePath = "$(System.DefaultWorkingDirectory)/downloaded-files/_Mike99Balloon.js"
do I really need a project PAT? or is there a better way I can't see (forest for the trees kinda thing)
$pat = "$(System.AccessToken)"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($pat)"))
so I updated the
$pat = "$(System.AccessToken)" to be "$env:System_AccessToken"
Seems to work now. or at least doesn't choke on it.
If you're using Release pipelines, you can include a repository as an artifact, and then those files will be automatically downloaded onto the agent for the stages you configure it to be included on.