Skip to content

Commit 13b246d

Browse files
Microsoft Graph DevX ToolingCopilot
authored andcommitted
ci: migrate production build to official 1ES template
Separate SDK build and tests from opt-in release artifact publication. Preserve the Node.js matrix and Linux build, and document pipeline authorization and downstream artifact compatibility. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 0f906b5 commit 13b246d

2 files changed

Lines changed: 124 additions & 72 deletions

File tree

Lines changed: 110 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,126 @@
1-
# Node.js
2-
# Build a general Node.js project with npm.
3-
# Add steps that analyze code, save build artifacts, deploy, and more:
4-
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
5-
61
name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
72

3+
parameters:
4+
- name: publishReleaseArtifact
5+
displayName: Publish release-drop for the external release pipeline (manual main runs only)
6+
type: boolean
7+
default: false
8+
89
trigger:
910
branches:
1011
include:
1112
- main
1213

1314
pr: none
1415

15-
stages:
16-
- stage: "Test"
17-
jobs:
18-
- job:
16+
resources:
17+
repositories:
18+
- repository: 1ESPipelineTemplates
19+
type: git
20+
name: 1ESPipelineTemplates/1ESPipelineTemplates
21+
ref: refs/tags/release
22+
23+
extends:
24+
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
25+
parameters:
1926
pool:
20-
vmImage: windows-latest
21-
strategy:
22-
matrix:
23-
Node 22:
24-
NODE_VERSION: '22.x'
25-
Node 24:
26-
NODE_VERSION: '24.x'
27-
Node 26:
28-
NODE_VERSION: '26.x'
29-
maxParallel: 2
30-
steps:
31-
- template: ./common-templates/security-pre-checks.yml
32-
- task: UseNode@1
33-
inputs:
34-
version: $(NODE_VERSION)
35-
displayName: 'Install Node.js'
27+
name: Azure-Pipelines-1ESPT-ExDShared
28+
image: windows-latest
29+
os: windows
3630

37-
- script: npm ci
38-
displayName: 'npm install for tests'
39-
- script: npm run build
40-
displayName: 'npm build for tests'
41-
- script: npm run test
42-
displayName: 'Run the node tests'
43-
- script: npm run karma
44-
displayName: 'Run karma tests'
31+
stages:
32+
- stage: Build
33+
displayName: Build and test SDK
34+
jobs:
35+
- job: Test
36+
displayName: Test supported Node.js versions
37+
strategy:
38+
matrix:
39+
Node22:
40+
NODE_VERSION: '22.x'
41+
Node24:
42+
NODE_VERSION: '24.x'
43+
Node26:
44+
NODE_VERSION: '26.x'
45+
maxParallel: 2
46+
steps:
47+
- checkout: self
48+
- task: UseNode@1
49+
inputs:
50+
version: $(NODE_VERSION)
51+
displayName: Install Node.js
4552

46-
- task: PublishTestResults@2
47-
displayName: 'Publish Unit Test Results'
48-
inputs:
49-
testResultsFormat: 'JUnit'
50-
testResultsFiles: '**/testResult.xml'
51-
failTaskOnFailedTests: true
53+
- script: npm ci
54+
displayName: Install test dependencies
55+
- script: npm run build
56+
displayName: Build SDK for tests
57+
- script: npm test
58+
displayName: Run Node.js and browser tests
5259

53-
- template: ./common-templates/security-post-checks.yml
60+
- task: PublishTestResults@2
61+
displayName: Publish unit test results
62+
condition: succeededOrFailed()
63+
inputs:
64+
testResultsFormat: JUnit
65+
testResultsFiles: '**/testResult.xml'
66+
testRunTitle: Node.js $(NODE_VERSION)
67+
failTaskOnFailedTests: true
5468

55-
- stage: "Build"
56-
jobs:
57-
- job:
58-
59-
pool:
60-
vmImage: ubuntu-latest
61-
steps:
62-
- task: UseNode@1
63-
inputs:
64-
version: '22.x'
65-
displayName: 'Install Node.js'
69+
- job: BuildPackage
70+
displayName: Build production artifact
71+
pool:
72+
name: Azure-Pipelines-1ESPT-ExDShared
73+
image: ubuntu-latest
74+
os: linux
75+
templateContext:
76+
outputs:
77+
- output: pipelineArtifact
78+
displayName: Publish SDK build for validation
79+
artifactName: sdk-build
80+
targetPath: $(Build.ArtifactStagingDirectory)
81+
steps:
82+
- checkout: self
83+
- task: UseNode@1
84+
inputs:
85+
version: '22.x'
86+
displayName: Install Node.js
6687

67-
- script: |
68-
npm ci
69-
npm run build
70-
displayName: 'Build for production artifact'
71-
- task: CopyFiles@2
72-
inputs:
73-
sourceFolder: '$(Build.SourcesDirectory)'
74-
targetFolder: $(Build.ArtifactStagingDirectory)
75-
Contents: |
76-
**/*
77-
!.azure-pipelines/**
78-
!.github/**
79-
!.git/**
80-
!.vscode/**
81-
displayName: 'Copy npm package'
88+
- script: npm ci
89+
displayName: Install production build dependencies
90+
- script: npm run build
91+
displayName: Build production SDK
92+
- task: CopyFiles@2
93+
inputs:
94+
sourceFolder: $(Build.SourcesDirectory)
95+
targetFolder: $(Build.ArtifactStagingDirectory)
96+
Contents: |
97+
**/*
98+
!.azure-pipelines/**
99+
!.github/**
100+
!.git/**
101+
!.vscode/**
102+
displayName: Stage npm package
82103

83-
- task: PublishBuildArtifacts@1
84-
inputs:
85-
pathtoPublish: $(Build.ArtifactStagingDirectory)
86-
artifactName: "release-drop"
87-
displayName: 'Publish artifacts'
88-
104+
- stage: Publish
105+
displayName: Publish release artifact
106+
dependsOn: Build
107+
condition: and(succeeded(), ${{ eq(parameters.publishReleaseArtifact, true) }}, eq(variables['Build.Reason'], 'Manual'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
108+
jobs:
109+
- job: PublishReleaseArtifact
110+
displayName: Publish validated SDK for external release
111+
pool:
112+
name: Azure-Pipelines-1ESPT-ExDShared
113+
image: ubuntu-latest
114+
os: linux
115+
templateContext:
116+
inputs:
117+
- input: pipelineArtifact
118+
artifactName: sdk-build
119+
targetPath: $(Build.ArtifactStagingDirectory)
120+
outputs:
121+
- output: pipelineArtifact
122+
displayName: Publish release-drop
123+
artifactName: release-drop
124+
targetPath: $(Build.ArtifactStagingDirectory)
125+
steps:
126+
- checkout: none

‎CONTRIBUTING.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,20 @@ To run linting,
136136
npm run lint
137137
```
138138

139+
#### Production pipeline
140+
141+
The Azure DevOps production pipeline in `.azure-pipelines/ci-build-production.yml` extends `v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates`. The official template manages SDL scanning and artifact publication instead of the legacy security-check step templates.
142+
143+
The **Build** stage tests the SDK on Windows with Node.js 22, 24, and 26, and builds the production SDK on Linux with Node.js 22. It publishes an intermediate `sdk-build` pipeline artifact for inspection. Pushes to `main` run this stage without publishing `release-drop`.
144+
145+
To validate the migration before merging, manually queue **Graph JS SDK Build pipeline** against the PR branch and leave **Publish release-drop for the external release pipeline** unchecked. An Azure DevOps administrator may need to authorize the `1ESPipelineTemplates/1ESPipelineTemplates` repository and the `Azure-Pipelines-1ESPT-ExDShared` pool for this pipeline. Confirm that the pool provides the Windows and Ubuntu images used here, including Chrome for the Windows browser tests, and that the template's SDL checks pass.
146+
147+
After a successful validation and merge, manually queue the pipeline against `main` with **Publish release-drop for the external release pipeline** checked. The separate **Publish** stage runs only after the build and tests succeed, and only for manual runs on `main`. It republishes the same `sdk-build` contents as `release-drop` without rebuilding or installing dependencies. This pipeline does not publish to npm.
148+
149+
`release-drop` is now a Pipeline Artifact rather than the Build Artifact produced by `PublishBuildArtifacts@1`. Before enabling publication, confirm the external release pipeline can download Pipeline Artifacts and triggers only on runs with `release-drop` (not build-only runs with `sdk-build`). Update its artifact download and trigger configuration if needed. The artifact name and staged file layout are unchanged.
150+
151+
#### Commit your changes
152+
139153
The files in `C:\Users\<yourusername>\<repo name>` are a working copy of the new branch that you created in your local repository. Changing anything in this folder doesn't affect the local repository until you commit a change. To commit a change to the local repository, type the following commands in GitBash:
140154

141155
git add .

0 commit comments

Comments
 (0)