Skip to content

Commit

Permalink
OneBranch Build (microsoft#1406)
Browse files Browse the repository at this point in the history
  • Loading branch information
littleaj authored Mar 22, 2021
1 parent 9e68643 commit e5c8ce0
Show file tree
Hide file tree
Showing 55 changed files with 2,957 additions and 110 deletions.
38 changes: 38 additions & 0 deletions .pipelines/pipeline.user.windows.buddy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version:
major: 0
minor: 0
tag: 'SNAPSHOT'
name: 'ApplicationInsights-Java'
system: 'custom'
build:
commands:
- !!buildcommand
name: 'Assemble Perf Counters DLL'
command: '.scripts/gradle.cmd'
arguments: ':core:windowsSharedLibrary'
artifacts:
- from: 'core/build/libs/windows/shared'
include:
- '**/*'
exclude:
- '**/*.pdb'
signing_options:
profile: external_distribution
sign_inline: true
logs:
- to: 'PerfCounters DLL Build Logs'
from: 'core/build/tmp'
include:
- '*WindowsCpp/*'
- !!buildcommand
name: 'Assemble ApplicationInsights-Java JARs'
command: '.scripts/gradle.cmd'
arguments: 'assemble -Pcore.native.artifacts.prebuilt=true'
artifacts:
- to: 'Artifacts'
include:
- '**/build/libs/*.jar'
exclude:
- '**/build/libs/*-sources.jar'
- '**/build/libs/*-javadoc.jar'
- 'buildSrc/**/*'
37 changes: 37 additions & 0 deletions .pipelines/pipeline.user.windows.official.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version:
major: 0
minor: 0
name: 'ApplicationInsights-Java'
system: 'custom'
build:
commands:
- !!buildcommand
name: 'Assemble Perf Counters DLL'
command: '.scripts/gradle.cmd'
arguments: ':core:windowsSharedLibrary'
artifacts:
- from: 'core/build/libs/windows/shared'
include:
- '**/*'
exclude:
- '**/*.pdb'
signing_options:
profile: external_distribution
sign_inline: true
logs:
- to: 'PerfCounters DLL Build Logs'
from: 'core/build/tmp'
include:
- '*WindowsCpp/*'
- !!buildcommand
name: 'Assemble ApplicationInsights-Java JARs'
command: '.scripts/gradle.cmd'
arguments: 'assemble -Pcore.native.artifacts.prebuilt=true -DisRelease=true -Pai.etw.native.build=release'
artifacts:
- to: 'Artifacts'
include:
- '**/build/libs/*.jar'
exclude:
- '**/build/libs/*-sources.jar'
- '**/build/libs/*-javadoc.jar'
- 'buildSrc/**/*'
78 changes: 78 additions & 0 deletions .pipelines/pipeline.user.windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
environment:
host:
os: 'windows'
flavor: 'server'
version: '2019'
runtime:
provider: 'appcontainer'
image: 'cdpxwin1809.azurecr.io/global/vse2019:latest'
source_mode: 'link'
versioning:
commands:
- !!defaultcommand
name: 'Generate Version'
command: '.scripts/version.cmd'
signing_options:
profile: '170'
static_analysis_options:
policheck_options:
disable_tool_scan: false
fail_on_error: true
restore:
commands:
- !!defaultcommand
name: 'Install Windows 8.1 SDK'
command: '.scripts/installWindows81Sdk.cmd'
logs:
- from: 'WinSdkInstall'
to: 'WinSdkInstall'
include:
- '**/*.log'
- !!defaultcommand
name: 'Install Windows 10 SDK'
command: '.scripts/installWindows10Sdk.cmd'
logs:
- from: 'WinSdkInstall'
to: 'WinSdkInstall'
include:
- '**/*.log'
- !!defaultcommand
name: 'Install Java 11 JDK'
command: '.scripts/installJava11jdk.cmd'
- !!defaultcommand
name: 'Add OpenTelemetry to MavenLocal'
command: '.scripts/ot-gradle.cmd'
arguments: 'publishToMavenLocal --refresh-dependencies'
- !!defaultcommand
name: 'Clean and Resolve Dependencies'
command: '.scripts/gradle.cmd'
arguments: 'clean resolveDependencies --refresh-dependencies'
- !!defaultcommand
name: 'List Installation Information'
command: '.scripts/dumpInstallationInfo.cmd'
test:
commands:
# - !!defaultcommand
# name: 'Gradle Static Analysis'
# command: '.scripts/gradle.cmd'
# arguments: 'check -x test'
# logs:
# - to: 'Checks Reports'
# include:
# - '**/build/reports/**/*'
# exclude:
# - '**/build/reports/tests/**/*'
- !!testcommand
name: 'ApplicationInsights-Java Unit Tests'
command: '.scripts/gradle.cmd'
arguments: 'test'
fail_on_stderr: false
testresults:
- title: ':Unit Test Results'
type: 'junit'
include:
- '**/build/test-results/test/**/*'
logs:
- to: 'Test Logs'
include:
- '**/build/reports/tests/**/*'
4 changes: 4 additions & 0 deletions .pipelines/pipeline.user.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
artifact_publish_options:
publish_to_legacy_artifacts: false
publish_to_pipeline_artifacts: true
publish_to_cloudvault_artifacts: false
18 changes: 18 additions & 0 deletions .scripts/copyBitsToAzureBlob.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
param (
[Parameter(Mandatory=$true, HelpMessage="azuresdkpartnerdrops service principal key")]
[ValidateNotNullOrEmpty()]
[string]$ServicePrincipalKey,

[Parameter(Mandatory=$true, HelpMessage="azuresdkpartnerdrops Service principal client ID")]
[ValidateNotNullOrEmpty()]
[string]$ServicePrincipleClientId,

[Parameter(Mandatory=$true, HelpMessage="applicationinsights-java version")]
[ValidateNotNullOrEmpty()]
[string]$SDKVersionNumber
)

$Env:AZCOPY_SPA_CLIENT_SECRET=$ServicePrincipalKey
azcopy login --service-principal --application-id $ServicePrincipleClientId
azcopy copy "$(System.DefaultWorkingDirectory)/_applicationinsights-java-Windows-Official-master/drop/outputs/build/Artifacts/agent/agent/build/libs/applicationinsights-agent-$SDKVersionNumber.jar" "https://azuresdkpartnerdrops.blob.core.windows.net/drops/applicationinsights-sdk/java/$SDKVersionNumber/"
Remove-Item Env:AZCOPY_SPA_CLIENT_SECRET
5 changes: 5 additions & 0 deletions .scripts/dumpInstallationInfo.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off

echo "Listing installed software..."
powershell -NoProfile -ExecutionPolicy Unrestricted -File "%~dp0List-Programs.ps1" || exit /B 1
echo "Finished listing installed software."
15 changes: 15 additions & 0 deletions .scripts/generateVersion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# To generate a custom version with "M.m.p.yyyymmdd<build_count_of_day>"
$path = "core\build\src\generated\main\resources\sdk-version.properties"
if (-Not (Test-Path -Path $path -PathType Leaf)) {
Write-Error -Message "'$path' does not exist" -Category ObjectNotFound
exit 2
}
$versionProps = ConvertFrom-StringData (Get-Content $path -Raw)
Write-Host "Read from sdk-version.properties: " $versionProps.version
$matchObj = ($versionProps.version | Select-String -Pattern "^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(?:-(?<tag>.*))?")
$major, $minor, $patch, $tag = $matchObj.Matches[0].Groups['major', 'minor','patch','tag'].Value
$date = Get-Date -UFormat "%Y%m%d"
$revision = "$date$env:CDP_DEFINITION_BUILD_COUNT_DAY"
$buildNumber = "$major.$minor.$patch.$revision"
[Environment]::SetEnvironmentVariable("CustomBuildNumber", $buildNumber, "User") # This will allow you to use it from env var in later steps of the same phase
Write-Host "##vso[build.updatebuildnumber]${buildNumber}"
20 changes: 20 additions & 0 deletions .scripts/gradle.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@echo off
setlocal

pushd %~dp0
set SCRIPT_ROOT=%CD%
popd

pushd %~dp0..
set PROJECT_ROOT=%CD%

set DEFAULT_OPTIONS=--info --stacktrace -DisBuildServer=true --warning-mode=all
set GRADLE_CMD=gradlew.bat %DEFAULT_OPTIONS% %*
echo Running '%GRADLE_CMD%' in '%PROJECT_ROOT%'
call %GRADLE_CMD%
if errorlevel 1 (
echo Error running '%GRADLE_CMD%' in '%PROJECT_ROOT%'
exit /b 1
)
popd
endlocal
95 changes: 95 additions & 0 deletions .scripts/install-azcopy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
param (
[Parameter(Mandatory=$true, HelpMessage="Url to download. Must point to a zip file. Assumes filename is last path element. Assumes zip contains top level directory with same name as zip file.")]
[ValidateNotNullOrEmpty()]
[string]$Url,

[Parameter(Mandatory=$true, HelpMessage="Destination directory to unzip downloaded file.")]
[ValidateNotNullOrEmpty()]
[System.IO.FileInfo]$Destination,

[Parameter(HelpMessage="When used, adds bin directory to PATH.")]
[switch]$UpdatePath = $false,

[Parameter(HelpMessage="When used, downloads directory will be cleaned and temp directories cleaned.")]
[switch]$CleanOnFinish = $false,

[Parameter(Mandatory=$false, HelpMessage="7Zip location. Should point to 7z.exe.")]
[ValidateNotNullOrEmpty()]
[System.IO.FileInfo]$PathTo7Zip,

[Parameter(Mandatory=$false, HelpMessage="Skips download step.")]
[switch]$SkipDownload = $false,

[Parameter(Mandatory=$false, HelpMessage="Skips unzip.")]
[switch]$SkipUnzip = $false
)

$fileName, $dirName = ($Url | Select-String -Pattern ".+/(?<filename>(?<dirname>[^/]+)\..+)$").Matches[0].Groups['filename', 'dirname'].Value
$Source = [System.IO.Path]::Combine("C:\Downloads", $fileName)

$ErrorActionPreference = "Stop"
Import-Module "$PSScriptRoot\win-installer-helper.psm1" -DisableNameChecking

Start-Setup

$PathNodes=@()
try
{
if (-not $SkipDownload) {
Write-Host "Downloading '$fileName' from '$Url' to '$Source'"
Get-File -Url $url -FileName $fileName
Write-Host "Download finished: $Source"
}
else
{
Write-Host "Skipping download."
if (-not (Test-Path $Source)) {
Write-Error "$Source does not exist"
exit
}
}

if ($SkipUnzip)
{
if($Destination.ToString() -eq "C:\7-Zip") {
Start-Process -Wait -FilePath "$Source" -ArgumentList "/S"
}
}
else
{
if ($PathTo7Zip)
{
Write-Host "***"
Write-Host $PathTo7Zip.ToString()
Write-Host "***"
if (-not (Test-Path $PathTo7Zip))
{
Write-Error "7zip location still does not exist $PathTo7Zip"
exit
}
Expand-ArchiveWith7Zip -Source $Source -Destination $destination -ToolPath $PathTo7Zip
}
else
{
Write-Host "$PathTo7Zip does not exist"
Expand-ArchiveWith7Zip -Source $Source -Destination $destination
}
Write-Host "Finished unzipping to $destination"
}
}
finally
{
if (!$PathNodes -eq "")
{
Write-Host "Appending to PATH: '$PathNodes'"
Update-Path -PathNodes $PathNodes
}
if ($CleanOnFinish)
{
Stop-Setup
}
else
{
Stop-Setup -PreserveTemp -PreserveDownloads
}
}
Loading

0 comments on commit e5c8ce0

Please sign in to comment.