Powershell to trigger a build in Azure DevOps

前端 未结 2 783
耶瑟儿~
耶瑟儿~ 2021-01-28 08:56

We have just migrated our code from on-site TFS to Azure DevOps.

With TFS, I use a powershell script to build and deploy the application. The deployment part still work

2条回答
  •  爱一瞬间的悲伤
    2021-01-28 09:32

    I ended up doing this and it works:

    Function Queue-Build ($definitionName, $branchName)
    {
        Write-Host "Building $definitionName - $branchName"
        $build = (vsts build queue --project [project_name] --instance [server_name] --definition-name $definitionName --branch $branchName) | Out-String | ConvertFrom-Json
    
        #wait for the build to complete
        while ($build.status -ne "completed") {
            Start-Sleep -s 5
            $build = (vsts build show --id $build.id --instance [server_name] --project [project_name]) | Out-String | ConvertFrom-Json
            #Write-Host $build.status
        }
    }
    
    vsts login --token PAT_created_in_DevOps
    
    $sourceBranch = [branch_name]
    Queue-Build [build_definition_name] $sourceBranch 
    

提交回复
热议问题