tasks/buildserver.tasks.ps1
$IsRunningOnBuildServer = $false $IsAzureDevOps = $false $IsGitHubActions = $false # Controls the format of the version number used as the build server's build number $GitVersionComponentForBuildNumber = "SemVer" $SendPhaseCompletionMessagesToBuildServer = $true # Synopsis: Identifies which, if any, CI server/platform is running the current build task DetectBuildServer { if ($env:TF_BUILD) { $script:IsRunningOnBuildServer = $true $script:IsAzureDevOps = $true Write-Build White "Azure Pipelines detected" } elseif ($env:GITHUB_ACTIONS) { $script:IsRunningOnBuildServer = $true $script:IsGitHubActions = $true Write-Build White "GitHub Actions detected" } } task SetBuildServerBuildNumber -If {$IsRunningOnBuildServer} { if ($IsAzureDevOps) { Write-Host "Setting Azure Pipelines build number: $($GitVersion[$GitVersionComponentForBuildNumber])" Write-Host "##vso[build.updatebuildnumber]$($GitVersion[$GitVersionComponentForBuildNumber])" } } # These tasks will send a message to the build server to indicate that the phase has # completed successfully, which will be displayed in the build summary screen. # (i.e. visible without having to drill into the logs) task sendCompileOkMessageToBuildServer -If {$SendPhaseCompletionMessagesToBuildServer -and $IsRunningOnBuildServer} -After Build { if ($IsGitHubActions) { Write-Host ("::notice title=Compile OK::Compile phase completed successfully") } elseif ($IsAzureDevOps) { # TODO: Determine whether any of the available options make the message suitably visible in the build summary } } task sendAnalysisOkMessageToBuildServer -If {$SendPhaseCompletionMessagesToBuildServer -and $IsRunningOnBuildServer} -After Analysis { if ($IsGitHubActions) { Write-Host ("::notice title=Analysis OK::Analysis phase completed successfully") } elseif ($IsAzureDevOps) { # TODO: Determine whether any of the available options make the message suitably visible in the build summary } } task sendTestOkMessageToBuildServer -If {$SendPhaseCompletionMessagesToBuildServer -and $IsRunningOnBuildServer} -After Test { if ($IsGitHubActions) { Write-Host ("::notice title=Test OK::Test phase completed successfully") } elseif ($IsAzureDevOps) { # TODO: Determine whether any of the available options make the message suitably visible in the build summary } } task sendPackageOkMessageToBuildServer -If {$SendPhaseCompletionMessagesToBuildServer -and $IsRunningOnBuildServer} -After Package { if ($IsGitHubActions) { Write-Host ("::notice title=Package OK::Package phase completed successfully") } elseif ($IsAzureDevOps) { # TODO: Determine whether any of the available options make the message suitably visible in the build summary } } task sendPublishOkMessageToBuildServer -If {$SendPhaseCompletionMessagesToBuildServer -and $IsRunningOnBuildServer} -After Publish { if ($IsGitHubActions) { Write-Host ("::notice title=Publish OK::Publish phase completed successfully") } elseif ($IsAzureDevOps) { # TODO: Determine whether any of the available options make the message suitably visible in the build summary } } |