|
| 1 | +# The name of the build that will be seen in mscodehub |
| 2 | +name: PowerShellGetv2-Release-$(Build.BuildId) |
| 3 | +# how is the build triggered |
| 4 | +# since this is a release build, no trigger as it's a manual release |
| 5 | +trigger: none |
| 6 | + |
| 7 | +pr: |
| 8 | + branches: |
| 9 | + include: |
| 10 | + - master |
| 11 | + |
| 12 | +# variables to set in the build environment |
| 13 | +variables: |
| 14 | + DOTNET_CLI_TELEMETRY_OPTOUT: 1 |
| 15 | + POWERSHELL_TELEMETRY_OPTOUT: 1 |
| 16 | + |
| 17 | +# since this build relies on templates, we need access to those |
| 18 | +# This needs a service connection in the build to work |
| 19 | +# the *name* of the service connection must be the same as the endpoint |
| 20 | +resources: |
| 21 | + repositories: |
| 22 | + - repository: ComplianceRepo |
| 23 | + type: github |
| 24 | + endpoint: ComplianceGHRepo |
| 25 | + name: PowerShell/compliance |
| 26 | + # this can be any branch of your choosing |
| 27 | + ref: master |
| 28 | + |
| 29 | +# the stages in this build. There are 2 |
| 30 | +# the assumption for PowerShellGetv2 is that test is done as part of |
| 31 | +# CI so we needn't do it here |
| 32 | +stages: |
| 33 | +- stage: Build |
| 34 | + displayName: Build |
| 35 | + pool: |
| 36 | + name: Package ES CodeHub Lab E |
| 37 | + jobs: |
| 38 | + - job: Build_Job |
| 39 | + displayName: Build Microsoft.PowerShell.PowerShellGetv2 |
| 40 | + # note the variable reference to ESRP. |
| 41 | + # this must be created in Project -> Pipelines -> Library -> VariableGroups |
| 42 | + # where it describes the link to the SigningServer |
| 43 | + variables: |
| 44 | + - group: ESRP |
| 45 | + steps: |
| 46 | + - checkout: self |
| 47 | + |
| 48 | + # the steps for building the module go here |
| 49 | + - pwsh: | |
| 50 | + Set-Location "$(Build.SourcesDirectory)/PowerShellGetv2" |
| 51 | + Import-Module ./tools/build.psm1 -Force |
| 52 | + Install-Dependencies |
| 53 | + Update-ModuleManifestFunctions |
| 54 | + Publish-ModuleArtifacts |
| 55 | + displayName: Execute build |
| 56 | +
|
| 57 | + # these are setting vso variables which will be persisted between stages |
| 58 | + - pwsh: | |
| 59 | + $signSrcPath = "$(Build.SourcesDirectory)/PowerShellGetv2/dist/PowerShellGet" |
| 60 | + dir |
| 61 | + # Set signing src path variable |
| 62 | + $vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}" |
| 63 | + Write-Host "sending " + $vstsCommandString |
| 64 | + Write-Host "##$vstsCommandString" |
| 65 | +
|
| 66 | + $signOutPath = "$(Build.SourcesDirectory)/OSS_Microsoft_PowerShellGetv2/signed/PowerShellGet" |
| 67 | + $null = New-Item -ItemType Directory -Path $signOutPath -force |
| 68 | + # Set signing out path variable |
| 69 | + $vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}" |
| 70 | + Write-Host "sending " + $vstsCommandString |
| 71 | + Write-Host "##$vstsCommandString" |
| 72 | +
|
| 73 | + # Set path variable for guardian codesign validation |
| 74 | + $vstsCommandString = "vso[task.setvariable variable=GDN_CODESIGN_TARGETDIRECTORY]${signOutPath}" |
| 75 | + Write-Host "sending " + $vstsCommandString |
| 76 | + Write-Host "##$vstsCommandString" |
| 77 | +
|
| 78 | + # Get version and create a variable |
| 79 | + $moduleData = Import-PowerShellDataFile "$(Build.SourcesDirectory)/PowerShellGetv2/dist/PowerShellGet/PowerShellGet.psd1" |
| 80 | + $moduleVersion = $moduleData.ModuleVersion |
| 81 | + $vstsCommandString = "vso[task.setvariable variable=moduleVersion]${moduleVersion}" |
| 82 | + Write-Host "sending " + $vstsCommandString |
| 83 | + Write-Host "##$vstsCommandString" |
| 84 | + displayName: Setup variables for signing |
| 85 | +
|
| 86 | + # checkout the Compliance repository so it can be used to do the actual signing |
| 87 | + - checkout: ComplianceRepo |
| 88 | + |
| 89 | + # this the MS authored step This cert covers MS autored items |
| 90 | + # note that the buildOutputPath (where we get the files to sign) |
| 91 | + # is the same as the signOutputPath in the previous step |
| 92 | + # at the end of this step we will have all the files signed that should be |
| 93 | + # signOutPath is the location which contains the files we will use to make the module |
| 94 | + - template: EsrpSign.yml@ComplianceRepo |
| 95 | + parameters: |
| 96 | + # the folder which contains the binaries to sign |
| 97 | + buildOutputPath: $(signSrcPath) |
| 98 | + # the location to put the signed output |
| 99 | + signOutputPath: $(signOutPath) |
| 100 | + # the certificate ID to use (Authenticode) |
| 101 | + certificateId: "CP-230012" |
| 102 | + pattern: | |
| 103 | + **\*.psd1 |
| 104 | + **\*.psm1 |
| 105 | + **\*.ps1xml |
| 106 | + **\*.mof |
| 107 | +
|
| 108 | + # finally publish the parts of the build which will be used in the next stages |
| 109 | + # if it's not published, the subsequent stages will not be able to access it. |
| 110 | + # This is the build directory (it contains all of the dll/pdb files) |
| 111 | + - publish: "$(Build.SourcesDirectory)/OSS_Microsoft_PowerShellGetv2" |
| 112 | + artifact: build |
| 113 | + displayName: publish build directory |
| 114 | + |
| 115 | +# Now on to the compliance stage |
| 116 | +- stage: compliance |
| 117 | + displayName: Compliance |
| 118 | + dependsOn: Build |
| 119 | + jobs: |
| 120 | + - job: Compliance_Job |
| 121 | + pool: |
| 122 | + name: Package ES CodeHub Lab E |
| 123 | + steps: |
| 124 | + - checkout: self |
| 125 | + - checkout: ComplianceRepo |
| 126 | + - download: current |
| 127 | + artifact: build |
| 128 | + |
| 129 | + # use the templates in the compliance repo |
| 130 | + # since script analyzer has modules, we're using the assembly-module-compliance template |
| 131 | + # if you don't have assemblies, you should use script-module-compliance template |
| 132 | + - template: script-module-compliance.yml@ComplianceRepo |
| 133 | + parameters: |
| 134 | + # component-governance - the path to sources |
| 135 | + sourceScanPath: '$(Build.SourcesDirectory)' |
| 136 | + # TermCheck |
| 137 | + optionsRulesDBPath: '' |
| 138 | + optionsFTPath: '' |
| 139 | + # tsa-upload |
| 140 | + # the compliance scanning must be uploaded, which you need to request |
| 141 | + codeBaseName: 'PowerShellGetv2_20200129' |
| 142 | + # selections |
| 143 | + APIScan: false # set to false when not using Windows APIs. |
0 commit comments