Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build-consumers.yml for Azure Pipelines #2592

Open
wants to merge 17 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 134 additions & 71 deletions azure-pipelines/pull-request-validation/build-consumers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
# Variable: 'skipConsumerValidationLabel' PR label used to skip the checks in this pipeline
name: $(date:yyyyMMdd)$(rev:.r)

trigger: none

pr:
- dev

parameters:
- name: shouldSkipLongRunningTest
displayName: Should skip long running test?
Expand Down Expand Up @@ -41,6 +46,11 @@ resources:
name: AzureAD/azure-activedirectory-library-for-android
ref: dev
endpoint: ANDROID_GITHUB
- repository: android-complete
type: github
name: AzureAD/android-complete
ref: pedroro/update-scripts
endpoint: ANDROID_GITHUB

stages:
- stage: getLabel
Expand All @@ -50,84 +60,148 @@ stages:
name: Hosted Windows 2019 with VS2019
jobs:
- template: ../templates/steps/fetch-pr-labels.yml
- stage: validateConsumers
- stage: publishCommon
# Validate Consumers
displayName: 'Validate'
displayName: 'Publish common'
dependsOn: getLabel
pool:
name: Hosted Windows 2019 with VS2019
variables:
prLabels: $[ stageDependencies.getLabel.getLabelsJob.outputs['fetchPrCILabel.prLabels'] ]
jobs:
# setup
- job: setupBranch
displayName: Setup branch
condition: and( succeeded(), not(contains(variables['prLabels'], variables['skipConsumerValidationLabel'])) )
- job: publishcommonlibs
displayName: Publish common
condition: and(succeeded(), not(contains(variables['prLabels'], variables['skipConsumerValidationLabel'])))
steps:
- checkout: none
- task: PowerShell@2
name: setvarStep
displayName: Set var branch
inputs:
targetType: inline
script: |
$branch = switch ( '$(Build.Reason)' )
{
PullRequest
{
'$(System.PullRequest.SourceBranch)'
}
Manual
{
'$(commonBranchName)'
}
default
{
''
}
}
Write-Output "$branch"
echo "##vso[task.setvariable variable=commonBranch;isOutput=true]$branch"
- powershell: |
if ("$(setvarStep.commonBranch)" -eq "") {
Write-Output "commonBranchName is not set using default common"
}
else{
Write-Output "Using common branch $(setvarStep.commonBranch) in consumers"
}
name: echovar
displayName: Echo branch name
# msal
- checkout: self
path: common

- checkout: android-complete
path: android-complete

- script: |
echo "##vso[task.setvariable variable=ENV_VSTS_MVN_ANDROIDCOMMON_USERNAME]VSTS"
echo "##vso[task.setvariable variable=ENV_VSTS_MVN_ANDROIDCOMMON_ACCESSTOKEN]$(System.AccessToken)"
displayName: 'Set Environment Variables'
workingDirectory: $(Pipeline.Workspace)/common

- task: Gradle@3
displayName: Assemble common4j
inputs:
gradleWrapperFile: $(Pipeline.Workspace)/common/gradlew
tasks: common4j:clean common4j:assemble
publishJUnitResults: false
jdkArchitecture: x64
jdkVersionOption: "1.11"
options: "-PprojVersion=0.0.$(Build.BuildId)"
workingDirectory: $(Pipeline.Workspace)/common

- task: Gradle@3
displayName: Publish common4j
inputs:
gradleWrapperFile: $(Pipeline.Workspace)/common/gradlew
tasks: common4j:publish
publishJUnitResults: false
jdkArchitecture: x64
jdkVersionOption: "1.11"
options: "-PprojVersion=0.0.$(Build.BuildId)"
workingDirectory: $(Pipeline.Workspace)/common

- task: PowerShell@2
inputs:
targetType: 'filePath'
filePath: 'promote-package.ps1'
arguments: "-personalAccessToken=$(System.AccessToken) -packageName=com.microsoft.identity.common4j -packageVersion=0.0.$(build.buildid)"
workingDirectory: $(Agent.SourcesDirectory)/android-complete/scripts/ado

- task: Gradle@3
displayName: Assemble common
inputs:
tasks: common:clean common:assembleDist
publishJUnitResults: false
jdkArchitecture: x64
jdkVersionOption: "1.11"
options: "PdistCommon4jVersion=0.0.$(build.buildid) -PprojVersion=0.0.$(build.buildid)"
- task: Gradle@3
displayName: Publish common
inputs:
tasks: common:publish -PprojVersion=0.0.$(build.buildid)
publishJUnitResults: false
jdkArchitecture: x64
jdkVersionOption: "1.11"
options: "-PprojVersion=0.0.$(build.buildid)"
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
Param (
[Parameter(Mandatory = $true)][String]$PackagingPAT,
[Parameter(Mandatory = $false)][String]$common4jVersion,
[Parameter(Mandatory = $false)][String]$commonVersion,
[Parameter(Mandatory = $false)][String]$PromoteToView = "Prerelease",
[Parameter(Mandatory = $false)][String]$Organization = "identitydivision",
[Parameter(Mandatory = $false)][String]$FeedName="AndroidADAL"
)

#request uri
$baseUri = "https://pkgs.dev.azure.com/$Organization";
$promotePackagesApi = "_apis/packaging/feeds/$FeedName/maven/packagesbatch?api-version=7.1-preview.1"
$promotePackagesUri = "$baseUri/$promotePackagesApi"

# Auth header
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("token:{0}" -f $PackagingPAT)))
$authHeader = @{Authorization = ("Basic {0}" -f $base64AuthInfo)};


# Request Body
$MavenPackagesBatchRequest = New-Object PSObject -Property @{
data = @{ viewId = $PromoteToView }
operation = "promote"
packages = @(
@{ artifact = "common4j"; group = "com.microsoft.identity"; version = $common4jVersion},
@{ artifact = "common"; group = "com.microsoft.identity"; version = $commonVersion}
)
}

$requestBody = $MavenPackagesBatchRequest | ConvertTo-Json

# Call ADO Rest API
try {
$Result = Invoke-RestMethod -Uri $promotePackagesUri -Method Post -ContentType "application/json" -Headers $authHeader -Body $requestBody;
} catch {
if($_.ErrorDetails.Message){
Write-Error $_.ErrorDetails.Message
}
throw $_.Exception
}
arguments:
-PackagingPAT "$(System.AccessToken)"
-common4jVersion "0.0.$(build.buildid)"
-commonVersion "0.0.$(build.buildid)"

- stage: validateMSAL
displayName: 'Validate MSAL'
dependsOn: publishCommon
jobs:
- job: msalValidation
displayName: MSAL
dependsOn:
- setupBranch
variables:
commonBranch: $[ dependencies.setupBranch.outputs['setvarStep.commonBranch'] ] # map in the variable
condition: and( succeeded(), not(contains(variables['prLabels'], variables['skipConsumerValidationLabel'])) )
steps:
- checkout: msal
displayName: Checkout msal repository
clean: true
submodules: recursive
persistCredentials: True
- task: CmdLine@2
displayName: Checkout common submodule $(commonBranch)
inputs:
script: |
git fetch
git checkout $(commonBranch)
git pull
git status
git rev-parse HEAD
workingDirectory: $(Agent.BuildDirectory)/s/common
- task: Gradle@3
displayName: Assemble msal
inputs:
jdkArchitecture: x64
jdkVersionOption: "1.11"
tasks: clean msal:assembleLocal
- template: ../templates/steps/automation-cert.yml
tasks: clean msal:assembleDist
- bash: |
echo "##vso[task.setvariable variable=ENV_VSTS_MVN_ANDROIDCOMMON_USERNAME]VSTS"
echo "##vso[task.setvariable variable=ENV_VSTS_MVN_ANDROIDCOMMON_ACCESSTOKEN]$(System.AccessToken)"
displayName: 'Set Environmnet variables'
- task: Gradle@3
displayName: Run msal Unit tests
inputs:
Expand All @@ -139,11 +213,9 @@ stages:
displayName: Broker
cancelTimeoutInMinutes: 1
timeoutInMinutes: 120
dependsOn:
- setupBranch
variables:
commonBranch: $[ dependencies.setupBranch.outputs['setvarStep.commonBranch'] ] # map in the variable
condition: and( succeeded(), not(contains(variables['prLabels'], variables['skipConsumerValidationLabel'])) )
commonBranch: $[ dependencies.publishcommon.outputs['setvarStep.commonBranch'] ] # map in the variable
condition: false
pool:
name: 1ES-AndroidPool-EOC
steps:
Expand Down Expand Up @@ -179,12 +251,7 @@ stages:
# Linux broker
- job: linuxBrokerValidation
displayName: Linux Broker
dependsOn:
- setupBranch
variables:
- name: commonBranch
value: $[ dependencies.setupBranch.outputs['setvarStep.commonBranch'] ] # map in the variable
condition: and( succeeded(), not(contains(variables['prLabels'], variables['skipConsumerValidationLabel'])) )
condition: false
pool:
vmImage: 'ubuntu-latest'
steps:
Expand Down Expand Up @@ -237,11 +304,7 @@ stages:
# adal
- job: adalValidation
displayName: ADAL
dependsOn:
- setupBranch
variables:
commonBranch: $[ dependencies.setupBranch.outputs['setvarStep.commonBranch'] ] # map in the variable
condition: and( succeeded(), not(contains(variables['prLabels'], variables['skipConsumerValidationLabel'])) )
condition: false
steps:
- checkout: adal
displayName: Checkout adal repository
Expand Down
Loading