Skip to content

Commit 11cedf6

Browse files
committed
Sdk release and CI-build pipelines are seperated and restructured in Main
1 parent e29d86a commit 11cedf6

2 files changed

Lines changed: 234 additions & 110 deletions

File tree

.azure-pipelines/ci-build.yml

Lines changed: 1 addition & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,16 @@ variables:
2929
GitUserName: "Microsoft Graph DevX Tooling"
3030
REGISTRY: 'msgraphprodregistry.azurecr.io'
3131
IMAGE_NAME: 'public/microsoftgraph/powershell'
32-
PREVIEW_BRANCH: 'refs/heads/main' # Updated to target your branch
3332

3433
trigger:
3534
branches:
3635
include:
3736
- main
38-
- dev
39-
tags:
40-
include:
41-
- v*
4237

4338
pr:
4439
branches:
4540
include:
4641
- main
47-
- dev
4842
resources:
4943
repositories:
5044
- repository: 1ESPipelineTemplates
@@ -137,107 +131,4 @@ extends:
137131
packagesToPush: '$(System.DefaultWorkingDirectory)/**/drop/**/*.nupkg'
138132
publishVstsFeed: ${{ parameters.InternalFeed }}
139133
nuGetFeedType: internal
140-
allowPackageConflicts: true
141-
- stage: 'Deploy_to_PsGallery'
142-
dependsOn: stage
143-
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) # Only deploy to PSGallery on main branch
144-
jobs:
145-
- deployment: 'DeployToPowerShellGallery'
146-
displayName: 'Deploy to PowerShell Gallery'
147-
environment: 'PowerShellGallery'
148-
templateContext:
149-
type: releaseJob
150-
isProduction: true
151-
inputs:
152-
- input: pipelineArtifact
153-
artifactName: drop
154-
targetPath: '$(System.DefaultWorkingDirectory)/drop'
155-
strategy:
156-
runOnce:
157-
deploy:
158-
steps:
159-
- task: 1ES.PublishNuget@1
160-
displayName: 'Publish NuGet to feed'
161-
inputs:
162-
useDotNetTask: false
163-
packageParentPath: '$(System.DefaultWorkingDirectory)'
164-
packagesToPush: '$(System.DefaultWorkingDirectory)/**/drop/**/*.nupkg'
165-
nuGetFeedType: external
166-
publishFeedCredentials: 'microsoftgraph PowerShell Gallery connection'
167-
168-
- stage: PushDockerImageToRegistry
169-
condition: and(or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])), not(contains(variables['Build.SourceBranch'], '-preview')))
170-
dependsOn: stage
171-
displayName: 'Push docker image'
172-
jobs:
173-
- job: PushDockerImage
174-
displayName: 'Push docker image'
175-
pool:
176-
name: Azure-Pipelines-1ESPT-ExDShared
177-
image: ubuntu-latest
178-
os: linux
179-
steps:
180-
- checkout: self
181-
182-
# Display the contents of the Build.SourcesDirectory
183-
- bash: |
184-
echo "Build.SourcesDirectory: $(Build.SourcesDirectory)"
185-
ls -la $(Build.SourcesDirectory)
186-
displayName: 'List contents of Build.SourcesDirectory'
187-
188-
- task: AzureCLI@2
189-
displayName: "Log in to Azure Container Registry"
190-
inputs:
191-
azureSubscription: 'ACR Images Push Service Connection' # service connection
192-
scriptType: 'bash'
193-
scriptLocation: 'inlineScript'
194-
'inlineScript': |
195-
az acr login --name $(REGISTRY)
196-
- powershell: |
197-
$date = Get-Date -Format "yyyyMMdd"
198-
Write-Host "##vso[task.setvariable variable=currentDate]$date"
199-
200-
- script: |
201-
docker run --privileged --rm tonistiigi/binfmt --install all
202-
displayName: 'Enable multi-platform builds'
203-
204-
- script: |
205-
docker buildx create --use --name mybuilder
206-
displayName: 'Set up Docker BuildX'
207-
208-
- powershell: |
209-
$version = $Env:BUILD_SOURCEBRANCH.replace("refs/tags/", "")
210-
Write-Output "##vso[task.setvariable variable=version]$version"
211-
displayName: 'Get truncated run number'
212-
213-
- bash: |
214-
echo "Build Number: $(Build.BuildNumber)"
215-
# Extract the last 3 characters for the run number
216-
runnumber=$(echo "$(Build.BuildNumber)" | grep -o '[0-9]\+$')
217-
echo "Extracted Run Number: $runnumber"
218-
219-
# If extraction fails, set a default
220-
if [ -z "$runnumber" ]; then
221-
echo "Extraction failed, using default value"
222-
runnumber=$(date +"%S%N" | cut -c1-3)
223-
echo "Generated fallback run number: $runnumber"
224-
fi
225-
226-
# Set the variable for later steps
227-
echo "##vso[task.setvariable variable=RUNNUMBER]$runnumber"
228-
echo "##vso[task.setvariable variable=RUNNUMBER;isOutput=true]$runnumber"
229-
displayName: 'Get truncated run number'
230-
name: getrunnumber
231-
232-
- bash: |
233-
echo "Building docker images"
234-
# Format the date to be compatible with Docker tags
235-
formatted_date=$(date +"%Y%m%d%H%M%S")
236-
docker buildx build \
237-
--platform linux/amd64 \
238-
--push \
239-
-t "$(REGISTRY)/$(IMAGE_NAME):latest" \
240-
-t "$(REGISTRY)/$(IMAGE_NAME):$formatted_date.$RUNNUMBER" \
241-
"$(Build.SourcesDirectory)"
242-
displayName: 'Build and push docker images'
243-
134+
allowPackageConflicts: true

.azure-pipelines/sdk-release.yml

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
4+
parameters:
5+
- name: BuildAgent
6+
default: 1es-windows-ps-compute-m
7+
displayName: Build Agent
8+
- name: Test
9+
type: boolean
10+
default: true
11+
- name: Pack
12+
type: boolean
13+
default: true
14+
- name: Sign
15+
type: boolean
16+
default: true
17+
- name: InternalFeed
18+
type: string
19+
default: '0985d294-5762-4bc2-a565-161ef349ca3e/PowerShell_V2_Build'
20+
displayName: Internal NuGet Feed
21+
values:
22+
- '0985d294-5762-4bc2-a565-161ef349ca3e/PowerShell_v2'
23+
- 'ATPopFeed'
24+
- '0985d294-5762-4bc2-a565-161ef349ca3e/PowerShell_V2_Build'
25+
26+
variables:
27+
BuildAgent: ${{ parameters.BuildAgent }}
28+
GitUserEmail: "GraphTooling@service.microsoft.com"
29+
GitUserName: "Microsoft Graph DevX Tooling"
30+
REGISTRY: 'msgraphprodregistry.azurecr.io'
31+
IMAGE_NAME: 'public/microsoftgraph/powershell'
32+
PREVIEW_BRANCH: 'refs/heads/main' # Updated to target your branch
33+
34+
trigger:
35+
tags:
36+
include:
37+
- v*
38+
39+
resources:
40+
repositories:
41+
- repository: 1ESPipelineTemplates
42+
type: git
43+
name: 1ESPipelineTemplates/1ESPipelineTemplates
44+
ref: refs/tags/release
45+
extends:
46+
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
47+
parameters:
48+
pool: $(BuildAgent)
49+
sdl:
50+
binskim:
51+
enabled: false
52+
justificationForDisabling: "Binskim keeps on crushing and failing the weekly build pipeline. Disabling it for now because we are unable to publish the artifacts to internal feeds."
53+
credscan:
54+
suppressionsFile: $(Build.SourcesDirectory)/.azure-pipelines/config/credscan/credscan-suppressions.json
55+
policheck:
56+
exclusionFile: $(Build.SourcesDirectory)/.azure-pipelines/config/policheck/policheck-exclusions.xml
57+
customBuildTags:
58+
- ES365AIMigrationTooling
59+
stages:
60+
- stage: stage
61+
jobs:
62+
- job: SDK_Release_Build
63+
displayName: Microsoft Graph PowerShell SDK Release Build
64+
timeoutInMinutes: 840
65+
templateContext:
66+
outputs:
67+
- ${{ if and(eq(parameters.Pack, true), eq(parameters.Sign, true)) }}:
68+
- output: pipelineArtifact
69+
displayName: 'Publish Module Artifacts'
70+
targetPath: '$(Build.ArtifactStagingDirectory)'
71+
artifactName: 'drop'
72+
publishLocation: 'Container'
73+
steps:
74+
- script: |
75+
git submodule update --init --recursive
76+
- template: .azure-pipelines/common-templates/install-tools.yml@self
77+
- template: .azure-pipelines/common-templates/security-pre-checks.yml@self
78+
79+
- template: .azure-pipelines/generation-templates/authentication-module.yml@self
80+
parameters:
81+
Test: ${{ parameters.Test }}
82+
Pack: ${{ parameters.Pack }}
83+
Sign: ${{ parameters.Sign }}
84+
85+
- template: .azure-pipelines/generation-templates/workload-modules.yml@self
86+
parameters:
87+
Test: ${{ parameters.Test }}
88+
Pack: ${{ parameters.Pack }}
89+
Sign: ${{ parameters.Sign }}
90+
91+
- template: .azure-pipelines/generation-templates/meta-module.yml@self
92+
parameters:
93+
Test: ${{ parameters.Test }}
94+
Pack: ${{ parameters.Pack }}
95+
Sign: ${{ parameters.Sign }}
96+
97+
- template: .azure-pipelines/common-templates/guardian-analyzer.yml@self
98+
99+
- ${{ if and(eq(parameters.Pack, true), eq(parameters.Sign, true)) }}:
100+
- template: .azure-pipelines/common-templates/esrp/codesign-nuget.yml@self
101+
parameters:
102+
FolderPath: "$(Build.ArtifactStagingDirectory)"
103+
Pattern: "Microsoft.Graph*.nupkg"
104+
105+
- template: .azure-pipelines/common-templates/security-post-checks.yml@self
106+
- stage: 'Deploy_to_Internal_Feed'
107+
dependsOn: stage
108+
jobs:
109+
- deployment: 'DeployToInternalFeed'
110+
displayName: 'Deploy to Internal Feed'
111+
environment: 'PowerShellInternalFeed'
112+
templateContext:
113+
type: releaseJob
114+
isProduction: true
115+
inputs:
116+
- input: pipelineArtifact
117+
artifactName: drop
118+
targetPath: '$(System.DefaultWorkingDirectory)/drop'
119+
strategy:
120+
runOnce:
121+
deploy:
122+
steps:
123+
- task: 1ES.PublishNuget@1
124+
displayName: 'Publish NuGet to feed'
125+
inputs:
126+
useDotNetTask: false
127+
packageParentPath: '$(System.DefaultWorkingDirectory)'
128+
packagesToPush: '$(System.DefaultWorkingDirectory)/**/drop/**/*.nupkg'
129+
publishVstsFeed: ${{ parameters.InternalFeed }}
130+
nuGetFeedType: internal
131+
allowPackageConflicts: true
132+
- stage: 'Deploy_to_PsGallery'
133+
dependsOn: stage
134+
condition: succeeded() # Only deploy to PSGallery on main branch, this only runs on main branch due to trigger settings
135+
jobs:
136+
- deployment: 'DeployToPowerShellGallery'
137+
displayName: 'Deploy to PowerShell Gallery'
138+
environment: 'PowerShellGallery'
139+
templateContext:
140+
type: releaseJob
141+
isProduction: true
142+
inputs:
143+
- input: pipelineArtifact
144+
artifactName: drop
145+
targetPath: '$(System.DefaultWorkingDirectory)/drop'
146+
strategy:
147+
runOnce:
148+
deploy:
149+
steps:
150+
- task: 1ES.PublishNuget@1
151+
displayName: 'Publish NuGet to feed'
152+
inputs:
153+
useDotNetTask: false
154+
packageParentPath: '$(System.DefaultWorkingDirectory)'
155+
packagesToPush: '$(System.DefaultWorkingDirectory)/**/drop/**/*.nupkg'
156+
nuGetFeedType: external
157+
publishFeedCredentials: 'microsoftgraph PowerShell Gallery connection'
158+
159+
- stage: PushDockerImageToRegistry
160+
condition: and(or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])), not(contains(variables['Build.SourceBranch'], '-preview')))
161+
dependsOn: stage
162+
displayName: 'Push docker image'
163+
jobs:
164+
- job: PushDockerImage
165+
displayName: 'Push docker image'
166+
pool:
167+
name: Azure-Pipelines-1ESPT-ExDShared
168+
image: ubuntu-latest
169+
os: linux
170+
steps:
171+
- checkout: self
172+
173+
# Display the contents of the Build.SourcesDirectory
174+
- bash: |
175+
echo "Build.SourcesDirectory: $(Build.SourcesDirectory)"
176+
ls -la $(Build.SourcesDirectory)
177+
displayName: 'List contents of Build.SourcesDirectory'
178+
179+
- task: AzureCLI@2
180+
displayName: "Log in to Azure Container Registry"
181+
inputs:
182+
azureSubscription: 'ACR Images Push Service Connection' # service connection
183+
scriptType: 'bash'
184+
scriptLocation: 'inlineScript'
185+
'inlineScript': |
186+
az acr login --name $(REGISTRY)
187+
- powershell: |
188+
$date = Get-Date -Format "yyyyMMdd"
189+
Write-Host "##vso[task.setvariable variable=currentDate]$date"
190+
191+
- script: |
192+
docker run --privileged --rm tonistiigi/binfmt --install all
193+
displayName: 'Enable multi-platform builds'
194+
195+
- script: |
196+
docker buildx create --use --name mybuilder
197+
displayName: 'Set up Docker BuildX'
198+
199+
- powershell: |
200+
$version = $Env:BUILD_SOURCEBRANCH.replace("refs/tags/", "")
201+
Write-Output "##vso[task.setvariable variable=version]$version"
202+
displayName: 'Get truncated run number'
203+
204+
- bash: |
205+
echo "Build Number: $(Build.BuildNumber)"
206+
# Extract the last 3 characters for the run number
207+
runnumber=$(echo "$(Build.BuildNumber)" | grep -o '[0-9]\+$')
208+
echo "Extracted Run Number: $runnumber"
209+
210+
# If extraction fails, set a default
211+
if [ -z "$runnumber" ]; then
212+
echo "Extraction failed, using default value"
213+
runnumber=$(date +"%S%N" | cut -c1-3)
214+
echo "Generated fallback run number: $runnumber"
215+
fi
216+
217+
# Set the variable for later steps
218+
echo "##vso[task.setvariable variable=RUNNUMBER]$runnumber"
219+
echo "##vso[task.setvariable variable=RUNNUMBER;isOutput=true]$runnumber"
220+
displayName: 'Get truncated run number'
221+
name: getrunnumber
222+
223+
- bash: |
224+
echo "Building docker images"
225+
# Format the date to be compatible with Docker tags
226+
formatted_date=$(date +"%Y%m%d%H%M%S")
227+
docker buildx build \
228+
--platform linux/amd64 \
229+
--push \
230+
-t "$(REGISTRY)/$(IMAGE_NAME):latest" \
231+
-t "$(REGISTRY)/$(IMAGE_NAME):$formatted_date.$RUNNUMBER" \
232+
"$(Build.SourcesDirectory)"
233+
displayName: 'Build and push docker images'

0 commit comments

Comments
 (0)