Skip to content

Commit ed71272

Browse files
1ES Pipelines Template Adoption (#367)
* 1ES Pipelines Template Adoption - Switch to 1ES templates * 1ES Pipelines Template Adoption - CreadScan Fix * 1ES Pipelines Template Adoption - CreadScan Fix
1 parent 7375ce1 commit ed71272

File tree

2 files changed

+122
-111
lines changed

2 files changed

+122
-111
lines changed

azure-pipelines.yml

Lines changed: 114 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,128 @@
1+
# This Yaml Document has been converted by ESAI Yaml Pipeline Conversion Tool.
2+
# Please make sure to check all the converted content, it is your team's responsibility to make sure that the pipeline is still valid and functions as expected.
3+
# This pipeline will be extended to the OneESPT template
4+
# If you are not using the E+D shared hosted pool with windows-2022, replace the pool section with your hosted pool, os, and image name. If you are using a Linux image, you must specify an additional windows image for SDL: https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/1es-pipeline-templates/features/sdlanalysis/overview#how-to-specify-a-windows-pool-for-the-sdl-source-analysis-stage
5+
# The Task 'PublishPipelineArtifact@1' has been converted to an output named 'Publish _build artifact' in the templateContext section.
16
trigger:
2-
- master
3-
- releases/*
4-
7+
- master
8+
- releases/*
59
variables:
610
isMaster: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
711
isRelease: $[startsWith(variables['Build.SourceBranch'], 'refs/heads/releases')]
8-
912
parameters:
10-
- name: nodeVersionList
11-
type: object
12-
default: [6, 8, 10, 12, 14, 16]
13-
14-
- name: imageList
15-
type: object
16-
default: ['windows-latest', 'ubuntu-latest']
17-
18-
- name: publishToNpm
19-
displayName: Publish to npm
20-
type: boolean
21-
default: false
22-
23-
stages:
24-
- stage: Build
25-
displayName: Build typed-rest-client
26-
jobs:
13+
- name: nodeVersionList
14+
type: object
15+
default: [6, 8, 10, 12, 14, 16]
16+
- name: imageList
17+
type: object
18+
default:
19+
windows: 'windows-latest'
20+
ubuntu: 'ubuntu-latest'
21+
- name: publishToNpm
22+
displayName: Publish to npm
23+
type: boolean
24+
default: false
25+
resources:
26+
repositories:
27+
- repository: 1ESPipelineTemplates
28+
type: git
29+
name: 1ESPipelineTemplates/1ESPipelineTemplates
30+
ref: refs/tags/release
31+
extends:
32+
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
33+
parameters:
34+
sdl:
35+
sourceAnalysisPool:
36+
name: Azure-Pipelines-1ESPT-ExDShared
37+
image: windows-2022
38+
os: windows
39+
customBuildTags:
40+
- ES365AIMigrationTooling
41+
stages:
42+
- stage: Build
43+
displayName: Build typed-rest-client
44+
jobs:
2745
- job: Build_and_Publish
2846
displayName: Build and Publish artifact
2947
pool:
30-
vmImage: 'ubuntu-20.04'
48+
name: Azure-Pipelines-1ESPT-ExDShared
49+
image: ubuntu-latest
50+
os: linux
51+
templateContext:
52+
outputs:
53+
- output: pipelineArtifact
54+
displayName: 'Publish _build artifact'
55+
targetPath: _build
56+
artifactType: pipeline
57+
artifactName: _build
3158
steps:
32-
#build on node 8.x
33-
- task: NodeTool@0
34-
inputs:
35-
versionSpec: '8.x'
36-
displayName: Install node 8
37-
38-
- script: npm install
39-
displayName: npm install
40-
41-
- script: npm run build
42-
displayName: npm run build
43-
44-
- task: PublishPipelineArtifact@1
45-
displayName: Publish _build artifact
46-
inputs:
47-
targetPath: _build
48-
artifactType: pipeline
49-
artifactName: _build
50-
51-
# run unit tests on different platforms and node versions
52-
- stage: Test
53-
displayName: Test typed-rest-client
54-
jobs:
59+
- task: NodeTool@0
60+
inputs:
61+
versionSpec: '8.x'
62+
displayName: Install node 8
63+
- script: npm install
64+
displayName: npm install
65+
- script: npm run build
66+
displayName: npm run build
67+
- stage: Test
68+
displayName: Test typed-rest-client
69+
jobs:
5570
- ${{ each image in parameters.imageList }}:
56-
- ${{ each nodeVersion in parameters.nodeVersionList }}:
57-
- job: Node_os_${{ nodeVersion }}_${{ replace(image,'-','_') }}
58-
displayName: Node.js ${{ nodeVersion }} on ${{ image }}
59-
pool:
60-
vmImage: ${{ image }}
61-
steps:
62-
- task: DownloadPipelineArtifact@2
63-
displayName: Download built typed-rest-client package
64-
inputs:
65-
artifact: _build
66-
path: $(Build.SourcesDirectory)/_build
67-
patterns: '!package-lock.json' #Exclude package-lock.json
68-
69-
- script: npm install
70-
displayName: npm install
71-
72-
- task: NodeTool@0
73-
inputs:
74-
versionSpec: ${{ nodeVersion }}.x
75-
displayName: Install node ${{ nodeVersion }}
76-
77-
- script: npm run units
78-
displayName: npm run units
79-
80-
- script: npm run test
81-
displayName: npm run test
82-
83-
- stage: Publish
84-
condition: and(succeeded(), or(eq('${{ parameters.publishToNpm }}', true), eq(variables.isRelease, true), eq(variables.isMaster, true)))
85-
jobs:
71+
- ${{ each nodeVersion in parameters.nodeVersionList }}:
72+
- job: Node_os_${{ nodeVersion }}_${{ image.key }}
73+
displayName: Node.js ${{ nodeVersion }} on ${{ image.key }}
74+
pool:
75+
name: Azure-Pipelines-1ESPT-ExDShared
76+
image: ${{ image.value }}
77+
os: ${{ image.key }}
78+
steps:
79+
- task: DownloadPipelineArtifact@2
80+
displayName: Download built typed-rest-client package
81+
inputs:
82+
artifact: _build
83+
path: $(Build.SourcesDirectory)/_build
84+
patterns: '!package-lock.json'
85+
- script: npm install
86+
displayName: npm install
87+
- task: NodeTool@0
88+
inputs:
89+
versionSpec: ${{ nodeVersion }}.x
90+
displayName: Install node ${{ nodeVersion }}
91+
- script: npm run units
92+
displayName: npm run units
93+
- script: npm run test
94+
displayName: npm run test
95+
- stage: Publish
96+
condition: and(succeeded(), or(eq('${{ parameters.publishToNpm }}', true), eq(variables.isRelease, true), eq(variables.isMaster, true)))
97+
jobs:
8698
- job: Publish_package
8799
displayName: Publish npm package
88100
pool:
89-
vmImage: 'ubuntu-20.04'
101+
name: Azure-Pipelines-1ESPT-ExDShared
102+
image: ubuntu-latest
103+
os: linux
90104
steps:
91-
- task: DownloadPipelineArtifact@2
92-
displayName: Download built typed-rest-client package
93-
inputs:
94-
artifact: _build
95-
path: $(Build.SourcesDirectory)/_build
96-
97-
- task: Npm@1
98-
displayName: Publish typed-rest-client to npm
99-
inputs:
100-
command: publish
101-
workingDir: '_build'
102-
publishRegistry: useExternalRegistry
103-
publishEndpoint: NPM-Automation-Token
104-
continueOnError: true
105-
106-
- script: npm install
107-
displayName: npm install
108-
continueOnError: true
109-
condition: and(succeeded(), eq(variables.isMaster, true))
110-
111-
- script: node ./ci/create-release-notes.js
112-
continueOnError: true
113-
condition: and(succeeded(), eq(variables.isMaster, true))
114-
env:
115-
GH_TOKEN: $(githubToken)
116-
branch: $(Build.SourceBranchName)
117-
displayName: Create Release
105+
- task: DownloadPipelineArtifact@2
106+
displayName: Download built typed-rest-client package
107+
inputs:
108+
artifact: _build
109+
path: $(Build.SourcesDirectory)/_build
110+
- task: Npm@1
111+
displayName: Publish typed-rest-client to npm
112+
inputs:
113+
command: publish
114+
workingDir: '_build'
115+
publishRegistry: useExternalRegistry
116+
publishEndpoint: NPM-Automation-Token
117+
continueOnError: true
118+
- script: npm install
119+
displayName: npm install
120+
continueOnError: true
121+
condition: and(succeeded(), eq(variables.isMaster, true))
122+
- script: node ./ci/create-release-notes.js
123+
continueOnError: true
124+
condition: and(succeeded(), eq(variables.isMaster, true))
125+
env:
126+
GH_TOKEN: $(githubToken)
127+
branch: $(Build.SourceBranchName)
128+
displayName: Create Release

test/units/handlers.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ describe('Authentication Handlers Tests', function () {
2121
'SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
2222
},
2323
personalAccessToken: {
24-
secret: 'scbfb44vxzku5l4xgc3qfazn3lpk4awflfryc76esaiq7aypcbhs'
24+
sampleToken: 'scbfb44vxzku5l4xgc3qfazn3lpk4awflfryc76esaiq7aypcbhs'
2525
},
2626
ntlm: {
27-
username: 'Zaphod',
28-
password: 'Beeblebrox',
27+
sampleUser: 'Zaphod',
28+
samplePass: 'Beeblebrox',
2929
domain: 'Ursa-Minor',
3030
workstation: 'LightCity'
3131
}
@@ -164,7 +164,7 @@ describe('Authentication Handlers Tests', function () {
164164

165165
it('[Personal Access Token] - does basic http get request with PAT token auth', async() => {
166166
const url: string = 'http://microsoft.com';
167-
const secret: string = _authHandlersOptions.personalAccessToken.secret;
167+
const secret: string = _authHandlersOptions.personalAccessToken.sampleToken;
168168
const personalAccessToken: string = Buffer.from(`PAT:${secret}`).toString('base64');
169169
const expectedAuthHeader: string = `Basic ${personalAccessToken}`;
170170
const patAuthHandler: hm.PersonalAccessTokenCredentialHandler =
@@ -212,7 +212,7 @@ describe('Authentication Handlers Tests', function () {
212212
it('[Personal Access Token] - does redirection request with PAT token auth', async() => {
213213
const url: string = 'http://microsoft.com';
214214
const redirectionUrl: string = 'http://jfrog.com';
215-
const secret: string = _authHandlersOptions.personalAccessToken.secret;
215+
const secret: string = _authHandlersOptions.personalAccessToken.sampleToken;
216216
const personalAccessToken: string = Buffer.from(`PAT:${secret}`).toString('base64');
217217
const expectedAuthHeader: string = `Basic ${personalAccessToken}`;
218218
const patAuthHandler: hm.PersonalAccessTokenCredentialHandler =
@@ -357,7 +357,7 @@ describe('Authentication Handlers Tests', function () {
357357
/**
358358
* Following NTLM Authentication Example on:
359359
* https://www.innovation.ch/personal/ronald/ntlm.html
360-
* With username: "Zaphod", password: "Beeblebrox" &
360+
* With sampleUser: "Zaphod", samplePass: "Beeblebrox" &
361361
* workstation/hostname: "LightCity", domain: "Ursa-Minor"
362362
*/
363363
const url: string = 'http://microsoft.com';
@@ -384,8 +384,8 @@ describe('Authentication Handlers Tests', function () {
384384
.reply(httpm.HttpCodes.OK);
385385

386386
const ntlmAuthHandler: hm.NtlmCredentialHandler = new hm.NtlmCredentialHandler(
387-
_authHandlersOptions.ntlm.username,
388-
_authHandlersOptions.ntlm.password,
387+
_authHandlersOptions.ntlm.sampleUser,
388+
_authHandlersOptions.ntlm.samplePass,
389389
_authHandlersOptions.ntlm.workstation,
390390
_authHandlersOptions.ntlm.domain
391391
);

0 commit comments

Comments
 (0)