Files
runner-images-sangeeth/images.CI/macos/azure-pipelines/image-generation.yml
MaksimZhukov 0b2ee087e3 Fix comments
2020-09-15 16:10:29 +03:00

106 lines
3.8 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
jobs:
- job: Image_generation
displayName: Image Generation (${{ parameters.image_label }})
timeoutInMinutes: 720
pool:
name: Mac-Cloud Image Generation
variables:
- group: Mac-Cloud Image Generation
- group: Mac-Cloud Image Generation Key Vault
steps:
- pwsh: |
$allowedContributors = $env:CONTRIBUTOR_ALLOWLIST.Split(",").Trim()
$validСontributor = $allowedContributors | Where-Object { $_ -eq $env:BUILD_SOURCEVERSIONAUTHOR } `
| Select-Object -First 1
if (-not $validСontributor) {
Write-Host "Failed to start this build. $env:BUILD_SOURCEVERSIONAUTHOR is an unknown contributor"
Write-Host "Please add $env:BUILD_SOURCEVERSIONAUTHOR to the allowed list to run builds"
exit 1
}
displayName: Validate contributor permissions
- checkout: self
clean: true
fetchDepth: 1
- task: PowerShell@2
displayName: 'Download custom repository'
condition: and(ne(variables['CUSTOM_REPOSITORY_URL'], ''), ne(variables['CUSTOM_REPOSITORY_BRANCH'], ''))
inputs:
targetType: 'filePath'
filePath: ./images.CI/download-repo.ps1
arguments: -RepoUrl $(CUSTOM_REPOSITORY_URL) `
-RepoBranch $(CUSTOM_REPOSITORY_BRANCH)
- task: DeleteFiles@1
displayName: Clean up self-hosted machine
inputs:
SourceFolder: 'images/macos/provision/log/'
RemoveSourceFolder: true
- pwsh: |
$SensitiveData = @(
'IP address:',
'Using ssh communicator to connect:'
)
packer build -on-error=abort `
-var="vcenter_server=$(vcenter_server_v2)" `
-var="vcenter_username=$(vcenter_username_v2)" `
-var="vcenter_password=$(vcenter_password_v2)" `
-var="vcenter_datacenter=$(vcenter_datacenter_v2)" `
-var="cluster_or_esxi_host=$(esxi_cluster_v2)" `
-var="esxi_datastore=${{ parameters.target_datastore }}" `
-var="output_folder=$(output_folder)" `
-var="vm_username=$(vm_username)" `
-var="vm_password=$(vm_password)" `
-var="build_id=$(Build.BuildNumber)" `
-var="baseimage_name=${{ parameters.base_image_name }}" `
-var="github_feed_token=$(GITHUB_FEED_TOKEN)" `
-var="xcode_install_user=$(xcode-installation-user)" `
-var="xcode_install_password=$(xcode-installation-password)" `
-color=false `
${{ parameters.template_path }} `
| Where-Object {
#Filter sensitive data from Packer logs
$currentString = $_
$sensitiveString = $SensitiveData | Where-Object { $currentString -match $_ }
$sensitiveString -eq $null
}
displayName: 'Build VM'
env:
PACKER_LOG: 0
workingDirectory: 'images/macos'
- bash: |
echo "Copy image output files"
cp -R "images/image-output/software-report/." "$(Build.ArtifactStagingDirectory)/"
echo "Copy test results"
cp -R "images/image-output/tests/." "$(Common.TestResultsDirectory)/"
ls $(Common.TestResultsDirectory)
echo "Put VM name to 'VM_Done_Name' file"
echo "$(Build.BuildNumber)" > "$(Build.ArtifactStagingDirectory)/VM_Done_Name"
displayName: Prepare artifact
- bash: |
cat "$(Build.ArtifactStagingDirectory)/systeminfo.md"
displayName: Print software report
- task: PublishBuildArtifacts@1
inputs:
ArtifactName: 'Built_VM_Artifacts'
displayName: Publish Artifacts
- task: PublishTestResults@2
inputs:
testResultsFiles: '*.xml'
testResultsFormat: NUnit
searchFolder: '$(Common.TestResultsDirectory)'
failTaskOnFailedTests: true
displayName: Publish test results
condition: always()