Skip to content

Commit

Permalink
azure-pipelines: Add templateContext to extension release pipeline (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bwateratmsft authored Jan 8, 2025
1 parent 3d5d203 commit 614499a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 36 deletions.
15 changes: 7 additions & 8 deletions azure-pipelines/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ parameters:
resources:
pipelines:
- pipeline: build
- pipeline: build # This *must* be exactly "build"
source: \Azure Tools\VSCode\Extensions\vscode-azurecontainerapps # CUSTOMIZE - location of the pipeline that produces the artifacts
repositories:
- repository: azExtTemplates
Expand All @@ -169,8 +169,6 @@ variables:
extends:
template: azure-pipelines/release-extension.yml@azExtTemplates
parameters:
pipelineID: $(resources.pipeline.build.pipelineID)
runID: $(resources.pipeline.build.runID)
publishVersion: ${{ parameters.publishVersion }}
dryRun: ${{ parameters.dryRun }}
environmentName: AzCodeDeploy # CUSTOMIZE
Expand All @@ -179,21 +177,22 @@ extends:
The extension release pipeline has the following parameters.

```yaml
# pipelineID and runID are used to download the artifacts from a specific build pipeline
- name: pipelineID
- name: pipelineID # No longer used
type: string
- name: runID
default: unused
- name: runID # No longer used
type: string
default: unused
# Customize the environment to associate the deployment with.
# Customize the environment to associate the deployment with.
# Useful to control which group of people should be required to approve the deployment.
- name: environmentName
type: string
default: AzCodeDeploy
# The following parameters are meant to be provded by the user when initiating a pipeline run
# The intended extension version to publish.
# The intended extension version to publish.
# This is used to verify the version in package.json matches the version to publish to avoid accidental publishing.
- name: publishVersion
type: string
Expand Down
43 changes: 15 additions & 28 deletions azure-pipelines/release-extension.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
parameters:
# pipelineID and runID are used to download the artifacts from a specific build pipeline
- name: pipelineID
- name: pipelineID # No longer used but kept to avoid needing to change the downstream templates
type: string
- name: runID
default: unused
- name: runID # No longer used but kept to avoid needing to change the downstream templates
type: string
default: unused

# The intended extension version to publish.
# This is used to verify the version in package.json matches the version to publish to avoid accidental publishing.
Expand Down Expand Up @@ -32,16 +33,6 @@ resources:
extends:
template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines
parameters:
sdl:
tsa:
enabled: true
configFile: '$(Build.SourcesDirectory)\.azure-pipelines\compliance\tsaoptions.json'
suppression:
suppressionFile: $(Build.SourcesDirectory)\.config\guardian\.gdnsuppress
credscan:
suppressionsFile: $(Build.SourcesDirectory)\.azure-pipelines\compliance\CredScanSuppressions.json
codeql:
enabled: false
pool:
name: VSEngSS-MicroBuild2022-1ES # Name of your hosted pool
image: server2022-microbuildVS2022-1es # Name of the image in your pool. If not specified, first image of the pool is used
Expand All @@ -54,30 +45,26 @@ extends:
- deployment: Publish
displayName: Publish extension
environment: ${{ parameters.environmentName }}
templateContext:
type: releaseJob
isProduction: true
inputs:
- input: pipelineArtifact
pipeline: build
targetPath: $(System.DefaultWorkingDirectory)
artifactName: Build Root
strategy:
runOnce:
deploy:
steps:
- download: none

- checkout: none

- task: DownloadPipelineArtifact@2
displayName: "\U0001F449 Download artifacts from Build pipeline"
inputs:
source: specific # download from a specific pipelines run
project: DevDiv
definition: ${{ parameters.pipelineID }}
buildVersionToDownload: specific
runId: ${{ parameters.runID }}
artifact: Build Root
targetPath: $(System.DefaultWorkingDirectory)

# Modify the build number to include repo name, extension version, and if dry run is true
- powershell: |
# Get the version from package.json
$packageJsonPath = "$(Build.SourcesDirectory)/package.json"
$packageJsonPath = "$(System.DefaultWorkingDirectory)/package.json"
$npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version
$isDryRun = "$env:dryRun"
$currentBuildNumber = "$(Build.BuildId)"
Expand All @@ -102,7 +89,7 @@ extends:
# If they don't match, this step fails
- powershell: |
# Get the version from package.json
$packageJsonPath = "$(Build.SourcesDirectory)/package.json"
$packageJsonPath = "$(System.DefaultWorkingDirectory)/package.json"
$npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version
$publishVersion = "$env:publishVersion"
Write-Output "Publishing version: $publishVersion"
Expand All @@ -121,7 +108,7 @@ extends:
# Fails with an error if more than one .vsix file is found, or if no .vsix file is found
- powershell: |
# Get all .vsix files in the current directory
$vsixFiles = Get-ChildItem -Path $(Build.SourcesDirectory) -Filter *.vsix -File
$vsixFiles = Get-ChildItem -Path $(System.DefaultWorkingDirectory) -Filter *.vsix -File
# Check if more than one .vsix file is found
if ($vsixFiles.Count -gt 1) {
Expand Down

0 comments on commit 614499a

Please sign in to comment.