-
Notifications
You must be signed in to change notification settings - Fork 214
Separate ci and release build pipelines #3451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+234
−109
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,234 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
| name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r) | ||
| parameters: | ||
| - name: BuildAgent | ||
| default: 1es-windows-ps-compute-m | ||
| displayName: Build Agent | ||
| - name: Test | ||
| type: boolean | ||
| default: true | ||
| - name: Pack | ||
| type: boolean | ||
| default: true | ||
| - name: Sign | ||
| type: boolean | ||
| default: true | ||
| - name: InternalFeed | ||
| type: string | ||
| default: '0985d294-5762-4bc2-a565-161ef349ca3e/PowerShell_V2_Build' | ||
| displayName: Internal NuGet Feed | ||
| values: | ||
| - '0985d294-5762-4bc2-a565-161ef349ca3e/PowerShell_v2' | ||
| - 'ATPopFeed' | ||
| - '0985d294-5762-4bc2-a565-161ef349ca3e/PowerShell_V2_Build' | ||
|
|
||
| variables: | ||
| BuildAgent: ${{ parameters.BuildAgent }} | ||
| GitUserEmail: "GraphTooling@service.microsoft.com" | ||
| GitUserName: "Microsoft Graph DevX Tooling" | ||
| REGISTRY: 'msgraphprodregistry.azurecr.io' | ||
| IMAGE_NAME: 'public/microsoftgraph/powershell' | ||
| PREVIEW_BRANCH: 'refs/heads/main' # Updated to target your branch | ||
|
|
||
| trigger: | ||
| tags: | ||
| include: | ||
| - v* | ||
|
|
||
| resources: | ||
| repositories: | ||
| - repository: 1ESPipelineTemplates | ||
| type: git | ||
| name: 1ESPipelineTemplates/1ESPipelineTemplates | ||
| ref: refs/tags/release | ||
| extends: | ||
| template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates | ||
| parameters: | ||
| pool: $(BuildAgent) | ||
| sdl: | ||
| binskim: | ||
| enabled: false | ||
| 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." | ||
| credscan: | ||
| suppressionsFile: $(Build.SourcesDirectory)/.azure-pipelines/config/credscan/credscan-suppressions.json | ||
| policheck: | ||
| exclusionFile: $(Build.SourcesDirectory)/.azure-pipelines/config/policheck/policheck-exclusions.xml | ||
| customBuildTags: | ||
| - ES365AIMigrationTooling | ||
| stages: | ||
| - stage: stage | ||
| jobs: | ||
| - job: SDK_Release_Build | ||
| displayName: Microsoft Graph PowerShell SDK Release Build | ||
| timeoutInMinutes: 840 | ||
| templateContext: | ||
| outputs: | ||
| - ${{ if and(eq(parameters.Pack, true), eq(parameters.Sign, true)) }}: | ||
| - output: pipelineArtifact | ||
| displayName: 'Publish Module Artifacts' | ||
| targetPath: '$(Build.ArtifactStagingDirectory)' | ||
| artifactName: 'drop' | ||
| publishLocation: 'Container' | ||
| steps: | ||
| - script: | | ||
| git submodule update --init --recursive | ||
| - template: .azure-pipelines/common-templates/install-tools.yml@self | ||
| - template: .azure-pipelines/common-templates/security-pre-checks.yml@self | ||
|
|
||
| - template: .azure-pipelines/generation-templates/authentication-module.yml@self | ||
| parameters: | ||
| Test: ${{ parameters.Test }} | ||
| Pack: ${{ parameters.Pack }} | ||
| Sign: ${{ parameters.Sign }} | ||
|
|
||
| - template: .azure-pipelines/generation-templates/workload-modules.yml@self | ||
| parameters: | ||
| Test: ${{ parameters.Test }} | ||
| Pack: ${{ parameters.Pack }} | ||
| Sign: ${{ parameters.Sign }} | ||
|
|
||
| - template: .azure-pipelines/generation-templates/meta-module.yml@self | ||
| parameters: | ||
| Test: ${{ parameters.Test }} | ||
| Pack: ${{ parameters.Pack }} | ||
| Sign: ${{ parameters.Sign }} | ||
|
|
||
| - template: .azure-pipelines/common-templates/guardian-analyzer.yml@self | ||
|
|
||
| - ${{ if and(eq(parameters.Pack, true), eq(parameters.Sign, true)) }}: | ||
| - template: .azure-pipelines/common-templates/esrp/codesign-nuget.yml@self | ||
| parameters: | ||
| FolderPath: "$(Build.ArtifactStagingDirectory)" | ||
| Pattern: "Microsoft.Graph*.nupkg" | ||
|
|
||
| - template: .azure-pipelines/common-templates/security-post-checks.yml@self | ||
| - stage: 'Deploy_to_Internal_Feed' | ||
| dependsOn: stage | ||
| jobs: | ||
| - deployment: 'DeployToInternalFeed' | ||
| displayName: 'Deploy to Internal Feed' | ||
| environment: 'PowerShellInternalFeed' | ||
| templateContext: | ||
| type: releaseJob | ||
| isProduction: true | ||
| inputs: | ||
| - input: pipelineArtifact | ||
| artifactName: drop | ||
| targetPath: '$(System.DefaultWorkingDirectory)/drop' | ||
| strategy: | ||
| runOnce: | ||
| deploy: | ||
| steps: | ||
| - task: 1ES.PublishNuget@1 | ||
| displayName: 'Publish NuGet to feed' | ||
| inputs: | ||
| useDotNetTask: false | ||
| packageParentPath: '$(System.DefaultWorkingDirectory)' | ||
| packagesToPush: '$(System.DefaultWorkingDirectory)/**/drop/**/*.nupkg' | ||
| publishVstsFeed: ${{ parameters.InternalFeed }} | ||
| nuGetFeedType: internal | ||
| allowPackageConflicts: true | ||
| - stage: 'Deploy_to_PsGallery' | ||
| dependsOn: stage | ||
| condition: succeeded() # Only deploy to PSGallery on main branch, this only runs on main branch due to trigger settings | ||
| jobs: | ||
| - deployment: 'DeployToPowerShellGallery' | ||
| displayName: 'Deploy to PowerShell Gallery' | ||
| environment: 'PowerShellGallery' | ||
| templateContext: | ||
| type: releaseJob | ||
| isProduction: true | ||
| inputs: | ||
| - input: pipelineArtifact | ||
| artifactName: drop | ||
| targetPath: '$(System.DefaultWorkingDirectory)/drop' | ||
| strategy: | ||
| runOnce: | ||
| deploy: | ||
| steps: | ||
| - task: 1ES.PublishNuget@1 | ||
| displayName: 'Publish NuGet to feed' | ||
| inputs: | ||
| useDotNetTask: false | ||
| packageParentPath: '$(System.DefaultWorkingDirectory)' | ||
| packagesToPush: '$(System.DefaultWorkingDirectory)/**/drop/**/*.nupkg' | ||
| nuGetFeedType: external | ||
| publishFeedCredentials: 'microsoftgraph PowerShell Gallery connection' | ||
|
|
||
| - stage: PushDockerImageToRegistry | ||
| condition: and(or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])), not(contains(variables['Build.SourceBranch'], '-preview'))) | ||
| dependsOn: stage | ||
| displayName: 'Push docker image' | ||
| jobs: | ||
| - job: PushDockerImage | ||
| displayName: 'Push docker image' | ||
| pool: | ||
| name: Azure-Pipelines-1ESPT-ExDShared | ||
| image: ubuntu-latest | ||
| os: linux | ||
| steps: | ||
| - checkout: self | ||
|
|
||
| # Display the contents of the Build.SourcesDirectory | ||
| - bash: | | ||
| echo "Build.SourcesDirectory: $(Build.SourcesDirectory)" | ||
| ls -la $(Build.SourcesDirectory) | ||
| displayName: 'List contents of Build.SourcesDirectory' | ||
| - task: AzureCLI@2 | ||
| displayName: "Log in to Azure Container Registry" | ||
| inputs: | ||
| azureSubscription: 'ACR Images Push Service Connection' # service connection | ||
| scriptType: 'bash' | ||
| scriptLocation: 'inlineScript' | ||
| 'inlineScript': | | ||
| az acr login --name $(REGISTRY) | ||
| - powershell: | | ||
| $date = Get-Date -Format "yyyyMMdd" | ||
| Write-Host "##vso[task.setvariable variable=currentDate]$date" | ||
| - script: | | ||
| docker run --privileged --rm tonistiigi/binfmt --install all | ||
| displayName: 'Enable multi-platform builds' | ||
| - script: | | ||
| docker buildx create --use --name mybuilder | ||
| displayName: 'Set up Docker BuildX' | ||
| - powershell: | | ||
| $version = $Env:BUILD_SOURCEBRANCH.replace("refs/tags/", "") | ||
| Write-Output "##vso[task.setvariable variable=version]$version" | ||
| displayName: 'Get truncated run number' | ||
| - bash: | | ||
| echo "Build Number: $(Build.BuildNumber)" | ||
| # Extract the last 3 characters for the run number | ||
| runnumber=$(echo "$(Build.BuildNumber)" | grep -o '[0-9]\+$') | ||
| echo "Extracted Run Number: $runnumber" | ||
| # If extraction fails, set a default | ||
| if [ -z "$runnumber" ]; then | ||
| echo "Extraction failed, using default value" | ||
| runnumber=$(date +"%S%N" | cut -c1-3) | ||
| echo "Generated fallback run number: $runnumber" | ||
| fi | ||
| # Set the variable for later steps | ||
| echo "##vso[task.setvariable variable=RUNNUMBER]$runnumber" | ||
| echo "##vso[task.setvariable variable=RUNNUMBER;isOutput=true]$runnumber" | ||
| displayName: 'Get truncated run number' | ||
| name: getrunnumber | ||
| - bash: | | ||
| echo "Building docker images" | ||
| # Format the date to be compatible with Docker tags | ||
| formatted_date=$(date +"%Y%m%d%H%M%S") | ||
| docker buildx build \ | ||
| --platform linux/amd64 \ | ||
| --push \ | ||
| -t "$(REGISTRY)/$(IMAGE_NAME):latest" \ | ||
| -t "$(REGISTRY)/$(IMAGE_NAME):$formatted_date.$RUNNUMBER" \ | ||
| "$(Build.SourcesDirectory)" | ||
| displayName: 'Build and push docker images' | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have build and validation run in ci-build. What's the plan here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I quite understand the question here. We are maintaining this CI pipeline as is for the most part, but removing the unused stages where we publish to nuget or to registry. The build validation occurs during the templates at lines 83, 89, 95 and finally at 109.