Skip to content

Commit ee2548e

Browse files
authored
Merge pull request #1950 from microsoft/ci/ado-esrp-migration
ci: adds build stage for ADO pipeline
2 parents cc2329d + 6213629 commit ee2548e

File tree

3 files changed

+151
-0
lines changed

3 files changed

+151
-0
lines changed

.azure-pipelines/ci-build.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
5+
6+
trigger:
7+
tags:
8+
include:
9+
- "v*"
10+
branches:
11+
include:
12+
- main
13+
14+
parameters:
15+
- name: previewBranch
16+
type: string
17+
default: "refs/heads/main"
18+
19+
resources:
20+
repositories:
21+
- repository: 1ESPipelineTemplates
22+
type: git
23+
name: 1ESPipelineTemplates/1ESPipelineTemplates
24+
ref: refs/tags/release
25+
26+
extends:
27+
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
28+
parameters:
29+
sdl:
30+
sourceAnalysisPool:
31+
name: Azure-Pipelines-1ESPT-ExDShared
32+
os: windows
33+
image: windows-latest
34+
35+
stages:
36+
- stage: build
37+
jobs:
38+
- job: build
39+
pool:
40+
name: Azure-Pipelines-1ESPT-ExDShared
41+
os: linux
42+
image: ubuntu-latest
43+
#TODO maybe missing template context with sdl baselines?
44+
steps:
45+
- checkout: self
46+
persistCredentials: true
47+
48+
- task: JavaToolInstaller@1
49+
inputs:
50+
versionSpec: '21'
51+
jdkArchitectureOption: 'x64'
52+
jdkSourceOption: 'PreInstalled'
53+
54+
- task: DownloadSecureFile@1
55+
inputs:
56+
secureFile: 'local.properties'
57+
58+
- task: DownloadSecureFile@1
59+
inputs:
60+
secureFile: 'secring.gpg'
61+
62+
- displayName: Copy secring
63+
pwsh: |
64+
Copy-Item secring.gpg components/abstractions/ -Verbose
65+
Copy-Item secring.gpg components/authentication/azure/ -Verbose
66+
Copy-Item secring.gpg components/serialization/form/ -Verbose
67+
Copy-Item secring.gpg components/serialization/text/ -Verbose
68+
Copy-Item secring.gpg components/serialization/json/ -Verbose
69+
Copy-Item secring.gpg components/serialization/multipart/ -Verbose
70+
Copy-Item secring.gpg components/http/okHttp/ -Verbose
71+
Copy-Item secring.gpg components/bundle/ -Verbose
72+
73+
- shell: ./gradlew --no-daemon publishToMavenLocal
74+
displayName: Publish to local Maven
75+
if: not(contains(variables['build.sourceBranch'], 'refs/tags/v'))
76+
77+
- shell: ./gradlew --no-daemon publishToMavenLocal -PmavenCentralSnapshotArtifactSuffix=""
78+
displayName: Publish to local Maven
79+
if: contains(variables['build.sourceBranch'], 'refs/tags/v')
80+
81+
- displayName: Get current SNAPSHOT version
82+
pwsh: |
83+
$contents = Get-Content gradle.properties -Raw
84+
$major = $contents | Select-String -Pattern 'mavenMajorVersion = ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
85+
$minor = $contents | Select-String -Pattern 'mavenMinorVersion = ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
86+
$patch = $contents | Select-String -Pattern 'mavenPatchVersion = ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
87+
$version = "$major.$minor.$patch$Env:SNAPSHOT_SUFFIX"
88+
echo "Current version is $version"
89+
echo "##vso[task.setvariable variable=PACKAGE_VERSION;isOutput=true]$version"
90+
env:
91+
${{ if contains(variables['build.sourceBranch'], 'refs/tags/v') }}:
92+
SNAPSHOT_SUFFIX: '-SNAPSHOT'
93+
94+
- displayName: Inspect contents of local Maven cache
95+
pwsh: |
96+
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-abstractions -Version $env:PACKAGE_VERSION
97+
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-authentication-azure -Version $env:PACKAGE_VERSION
98+
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-http-okHttp -Version $env:PACKAGE_VERSION
99+
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-serialization-form -Version $env:PACKAGE_VERSION
100+
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-serialization-json -Version $env:PACKAGE_VERSION
101+
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-serialization-text -Version $env:PACKAGE_VERSION
102+
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-serialization-multipart -Version $env:PACKAGE_VERSION
103+
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-bundle -Version $env:PACKAGE_VERSION
104+
105+
- displayName: Zip contents of local Maven cache
106+
pwsh: |
107+
.\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-abstractions -Version $env:PACKAGE_VERSION
108+
.\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-authentication-azure -Version $env:PACKAGE_VERSION
109+
.\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-http-okHttp -Version $env:PACKAGE_VERSION
110+
.\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-serialization-form -Version $env:PACKAGE_VERSION
111+
.\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-serialization-json -Version $env:PACKAGE_VERSION
112+
.\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-serialization-text -Version $env:PACKAGE_VERSION
113+
.\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-serialization-multipart -Version $env:PACKAGE_VERSION
114+
.\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-bundle -Version $env:PACKAGE_VERSION
115+
env:
116+
OUTPUT_DIRECTORY: $(Build.ArtifactStagingDirectory)
117+
118+
- task: 1ES.PublishPipelineArtifact@1
119+
displayName: "Publish Artifact: jars"
120+
inputs:
121+
artifactName: jars
122+
targetPath: "$(Build.ArtifactStagingDirectory)/*.zip"
123+
124+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,3 +359,4 @@ build/
359359
local.properties
360360

361361
*.gpg
362+
*.zip

scripts/zipPackageContent.ps1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Checks that expected files are present & have contents after the publish process to the local cache
2+
param(
3+
[Parameter(Mandatory=$true)][string] $ArtifactId,
4+
[Parameter(Mandatory=$true)][string] $Version,
5+
[Parameter(Mandatory=$true)][string] $OutputDirectory,
6+
[Parameter()][string] $GroupId = "com.microsoft.kiota",
7+
[Parameter()][string] $MavenLocalCachePath = "~" + [System.IO.Path]::DirectorySeparatorChar + ".m2" + [System.IO.Path]::DirectorySeparatorChar + "repository"
8+
)
9+
10+
$groupIdPath = $GroupId -replace "\.", [System.IO.Path]::DirectorySeparatorChar
11+
$packagePath = Join-Path -Path $groupIdPath -ChildPath $ArtifactId
12+
$packageFullPath = Join-Path -Path $MavenLocalCachePath -ChildPath $packagePath -AdditionalChildPath $Version
13+
14+
Write-Output "---------------------------------------------------"
15+
Write-Output "Zipping package contents at $packageFullPath"
16+
17+
if(-not (Test-Path -Path $packageFullPath)) {
18+
Write-Output "Package not found in local cache."
19+
exit 1
20+
}
21+
22+
$outputFilePath = Join-Path -Path $OutputDirectory -ChildPath "$ArtifactId-$Version.zip")
23+
Remove-Item -Path $outputFilePath -ErrorAction SilentlyContinue
24+
Compress-Archive -Path "$packageFullPath\*" -DestinationPath $outputFilePath
25+
26+
exit 0

0 commit comments

Comments
 (0)