We have captured here typical use cases of Pull Request Integration:
Table of Contents |
---|
Note |
---|
The Target branch must have builds already reported to Sealights, otherwise the prConfig command will fail. |
...
In the sample script below, if required, please update lines 1 to 4 and 25-26 before executing it.
Info |
---|
Lines 8-9, 22-23 and 26-27 contain the |
Code Block | ||
---|---|---|
| ||
$sldomain="mycompany.sealights.co" $slagenttoken="$(AgentToken.Sandbox)" $APP_NAME="MyApplication" $APP_NAMESPACE="CalculatorServer.Controllers" [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Write-Output "Download the Sealights DotNet agent version set in settings..." $agentversion = ((iwr -Uri https://$($sldomain)/api/v2/agents/dotnet/recommended -Headers @{'Accept' = 'application/json'; 'Authorization' = "Bearer $($slagenttoken)"}).Content ` | ConvertFrom-Json | Select-Object agent).agent.version iwr -OutFile sealights-dotnet-agent.zip -Uri http://agents.sealights.co/SL.DotNet/SL.DotNet-$($agentversion).zip Expand-Archive .\sealights-dotnet-agent.zip -DestinationPath SL.DotNet -Force Write-Output "Sealights agent version used is: $(Get-Content .\SL.DotNet\version.txt)" #Retrieve the same name of target branch as reported in Sealights Dashboard by removing the uncecessary prefix $PR_TARGET_BRANCH="$(System.PullRequest.TargetBranch)".Replace("refs/heads/","") #Retrieve the last Commit Hash from the PR branch and not the one from the ADO local Merge (via git log history) $PR_LAST_COMMIT=$(git log -2 --format=%H).Split(" ")[1] $PR_NUMBER="$(System.PullRequest.PullRequestId)" $REPO_URL="$(System.PullRequest.SourceRepositoryURI)" Write-Output "`n*** Create PR BSID ***" .\SL.DotNet\x64\SL.DotNet.exe prConfig --appName $APP_NAME --pullRequestNumber $PR_NUMBER --targetBranch $PR_TARGET_BRANCH --latestCommit $PR_LAST_COMMIT --repositoryUrl $REPO_URL ` --includeNamespace $APP_NAMESPACE --buildSessionIdFile $(Build.ArtifactStagingDirectory)\SealightsBuildSessionId.txt --token $($slagenttoken) --logEnabled true --logAppendConsole true --ignoreCertificateErrors true $SOLUTION_DIR="$(Build.Repository.LocalPath)\src" $SOURCE_DIR="$(Build.Repository.LocalPath)" Write-Output "`n*** Prepare for MSBuild ***" .\SL.DotNet\x64\SL.DotNet.exe prepareForMsBuild --buildSessionIdFile $(Build.ArtifactStagingDirectory)\SealightsBuildSessionId.txt --workspacePath $(Build.Repository.LocalPath)\src$SOLUTION_DIR ` --baseDir $(Build.Repository.LocalPath)$SOURCE_DIR --ignoreGeneratedCode true --debugMode true --logEnabled true --logAppendConsole true --ignoreCertificateErrors true --token $($slagenttoken) --scm git --scmProvider vsts |