Skip to content
This repository was archived by the owner on Mar 16, 2021. It is now read-only.

Commit 88a1c7a

Browse files
Merge pull request #38 from microsoftgraph/rsh/buildAndPackagePipeline
Rsh/build and package pipeline
2 parents 2e0f805 + 99a5b43 commit 88a1c7a

File tree

4 files changed

+208
-8
lines changed

4 files changed

+208
-8
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#Copyright (c) Microsoft Corporation. All rights reserved.
2+
#Licensed under the MIT License.
3+
#Building and packaging the artifacts of the Java-Auth libraries using the build.gradle file.
4+
#Ready the package for deployment and release.
5+
6+
trigger:
7+
branches:
8+
include:
9+
- dev
10+
- main
11+
- master
12+
paths:
13+
include:
14+
- src/*
15+
exclude:
16+
- .gitignore
17+
- CONTRIBUTING.md
18+
- LICENSE
19+
- THIRD PARTY NOTICES
20+
- build.gradle
21+
- gradle.properties
22+
- gradlew
23+
- gradlew.bat
24+
- readme.md
25+
- settings.gradle
26+
- scripts/*
27+
28+
pr: none
29+
30+
pool:
31+
vmImage: 'windows-latest'
32+
33+
steps:
34+
- checkout: self
35+
clean: true
36+
fetchDepth: 1
37+
38+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
39+
displayName: 'Run CredScan'
40+
inputs:
41+
debugMode: false
42+
43+
- task: DownloadSecureFile@1
44+
inputs:
45+
secureFile: 'local.properties'
46+
47+
- task: DownloadSecureFile@1
48+
inputs:
49+
secureFile: 'secring.gpg'
50+
51+
- task: DownloadSecureFile@1
52+
inputs:
53+
secureFile: 'secring.gpg.lock'
54+
55+
- task: CopyFiles@2
56+
inputs:
57+
SourceFolder: '$(Agent.TempDirectory)'
58+
Contents: '**'
59+
TargetFolder: '$(System.DefaultWorkingDirectory)'
60+
61+
- task: Gradle@2
62+
inputs:
63+
gradleWrapperFile: 'gradlew'
64+
tasks: 'build'
65+
publishJUnitResults: true
66+
testResultsFiles: '**/TEST-*.xml'
67+
javaHomeOption: 'JDKVersion'
68+
sonarQubeRunAnalysis: false
69+
70+
- task: CopyFiles@2
71+
inputs:
72+
SourceFolder: '$(System.DefaultWorkingDirectory)'
73+
Contents: |
74+
**/libs/*
75+
build.gradle
76+
gradlew
77+
gradlew.bat
78+
settings.gradle
79+
gradle.properties
80+
**/gradle/wrapper/*
81+
TargetFolder: '$(Build.ArtifactStagingDirectory)/'
82+
83+
- task: PublishBuildArtifacts@1
84+
inputs:
85+
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
86+
ArtifactName: 'drop'
87+
publishLocation: 'Container'
88+
89+
- task: YodLabs.O365PostMessage.O365PostMessageBuild.O365PostMessageBuild@0
90+
displayName: 'Graph Client Tooling pipeline fail notification'
91+
inputs:
92+
addressType: serviceEndpoint
93+
serviceEndpointName: 'microsoftgraph pipeline status'
94+
title: '$(Build.DefinitionName) failure notification'
95+
text: 'This pipeline has failed. View the build details for further information. This is a blocking failure.'
96+
condition: and(failed(), ne(variables['Build.Reason'], 'Manual'))
97+
enabled: true

.azure-pipelines/prValidate.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#Copyright (c) Microsoft Corporation. All rights reserved.
2+
#Licensed under the MIT License.
3+
#Build and test Java Core to make sure a valid pull request is being made
4+
#Validate that the versions dont conflict with those online in case a pull request is made to main or master
5+
16
pr:
27
branches:
38
include:
@@ -17,6 +22,7 @@ pr:
1722
- gradlew.bat
1823
- readme.md
1924
- settings.gradle
25+
- scripts/*
2026

2127
trigger: none
2228

@@ -37,14 +43,12 @@ steps:
3743
inputs:
3844
debugMode: false
3945

40-
#TODO: Bintray and Maven Repos dont contain Auth library yet
41-
# Uncomment once Auth library is avaliable publicaly online
42-
#- task: PowerShell@2
43-
# condition: and(failed(), eq(variables['Build.SourceBranchName'], 'dev'))
44-
# inputs:
45-
# filePath: '$(System.DefaultWorkingDirectory)\Scripts\validateMavenVersion.ps1'
46-
# pwsh: true
47-
# arguments: '-packageName "$(PACKAGE_NAME)" -propertiesPath "$(PROPERTIES_PATH)"'
46+
- task: PowerShell@2
47+
condition: and(failed(), eq(variables['Build.SourceBranchName'], 'dev'))
48+
inputs:
49+
filePath: '$(System.DefaultWorkingDirectory)\scripts\validateMavenVersion.ps1'
50+
pwsh: true
51+
arguments: '-packageName "$(PACKAGE_NAME)" -propertiesPath "$(PROPERTIES_PATH)"'
4852

4953
- task: Gradle@2
5054
inputs:

scripts/getLatestVersion.ps1

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
<#
5+
.Synopsis
6+
Retrieve the latest version of the library
7+
.Description
8+
Retrieves the latest version specified in the Gradle.Properties file
9+
Uses the retrieved values to update the enviornment variable VERSION_STRING
10+
#>
11+
12+
.Parameter propertiesPath
13+
14+
Param(
15+
[parameter(Mandatory = $true)]
16+
[string]$propertiesPath,
17+
)
18+
19+
#Retrieve the current version from the Gradle.Properties file given the specified path
20+
$file = get-item $propertiesPath
21+
$findVersions = $file | Select-String -Pattern "mavenMajorVersion" -Context 0,2
22+
$findVersions = $findVersions -split "`r`n"
23+
24+
$majorVersion = $findVersions[0].Substring($findVersions[0].Length-1)
25+
$minorVersion = $findVersions[1].Substring($findVersions[1].Length-1)
26+
$patchVersion = $findVersions[2].Substring($findVersions[2].Length-1)
27+
$version = "$majorVersion.$minorVersion.$patchVersion"
28+
29+
#Update the VERSION_STRING env variable and inform the user
30+
Write-Host "##vso[task.setVariable variable=VERSION_STRING]$($version)";
31+
Write-Host "Updated the VERSION_STRING environment variable with the current Gradle.Properties, $version"

scripts/validateMavenVersion.ps1

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
<#
5+
.Synopsis
6+
Ensure the maven version is updated in the case that the pull request is
7+
to the main/master branch of the repo.
8+
.Description
9+
Retrieves the local, Maven, and Bintray versions of the Java-Auth build.
10+
Checks that the Maven and Bintray versions are aligned, trigger warning if not.
11+
Checks that the current local version is greater than those currently deployed.
12+
#>
13+
14+
.Parameter packageName
15+
.Parameter propertiesPath
16+
17+
Param(
18+
[parameter(Mandatory = $true)]
19+
[string]$packageName,
20+
21+
[parameter(Mandatory = $true)]
22+
[string]$propertiesPath
23+
)
24+
25+
#Find the local version from the Gradle.Properties file
26+
$file = get-item $propertiesPath
27+
$findLocalVersions = $file | Select-String -Pattern "mavenMajorVersion" -Context 0,2
28+
$findLocalVersions = $findLocalVersions -split "`r`n"
29+
30+
$localMajor = $findLocalVersions[0].Substring($findLocalVersions[0].Length-1)
31+
$localMinor = $findLocalVersions[1].Substring($findLocalVersions[1].Length-1)
32+
$localPatch = $findLocalVersions[2].Substring($findLocalVersions[2].Length-1)
33+
$localVersion = [version]"$localMajor.$localMinor.$localPatch"
34+
35+
#Set Web Client and retrieve Maven and Bintray versions from their respective repos.
36+
$web_client = New-Object System.Net.WebClient
37+
38+
$mavenAPIurl = "https://search.maven.org/solrsearch/select?q=$packageName&rows=20&wt=json"
39+
$jsonResult = $web_client.DownloadString($mavenAPIurl) | ConvertFrom-Json
40+
$mavenVersion = [version]$jsonResult.response.docs.latestVersion
41+
42+
$bintrayAPIurl = "https://api.bintray.com/search/packages?name=$packageName"
43+
$jsonResult = $web_client.DownloadString($bintrayAPIurl) | ConvertFrom-Json
44+
$bintrayVersion = [version]$jsonResult.latest_version
45+
46+
#If the api calls return empty then this library cannot be compared to the online versions
47+
#may proceed with the pull request
48+
if(($mavenVersion -eq $null) -and ($bintrayVersion -eq $null))
49+
{
50+
Write-Information "This package does not exist yet in the online repository, therefore there are no versions to compare."
51+
return
52+
}
53+
54+
#Inform host of current Maven and Bintray versions
55+
Write-Host 'The current version in the Maven central repository is:' $mavenVersion
56+
Write-Host 'The current version in the Bintray central repository is:' $bintrayVersion
57+
58+
#Warn in case Maven and Bintray versions are not the same.
59+
if($mavenVersion -ne $bintrayVersion){
60+
Write-Warning "The current Maven and Bintray versions are not the same"
61+
}
62+
#Success if Local version has been updated, Error otherwise.
63+
if($localVersion -gt $bintrayVersion){
64+
Write-Host "The current pull request is of a greater version"
65+
}
66+
else{
67+
Write-Error "The current local version is not updated. Please update the local version in the Gradle.Properties file."
68+
}

0 commit comments

Comments
 (0)