diff --git a/.azure-pipelines/buildAndPackage.yml b/.azure-pipelines/buildAndPackage.yml new file mode 100644 index 000000000..ad8e81eea --- /dev/null +++ b/.azure-pipelines/buildAndPackage.yml @@ -0,0 +1,101 @@ +#Copyright (c) Microsoft Corporation. All rights reserved. +#Licensed under the MIT License. +#Building and packaging the artifacts of the Java-Core libraries using the build.gradle file. +#Ready the package for deployment and release. + +trigger: + branches: + include: + - dev + - main + - master + paths: + include: + - src/* + exclude: + - .gitignore + - CONTRIBUTING.md + - LICENSE + - THIRD PARTY NOTICES + - build.gradle + - gradle.properties + - gradlew + - gradlew.bat + - readme.md + - settings.gradle + +pr: none + +pool: + vmImage: 'windows-latest' + +steps: +- checkout: self + clean: true + fetchDepth: 1 + +- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2 + displayName: 'Run CredScan' + inputs: + debugMode: false + +- task: DownloadSecureFile@1 + inputs: + secureFile: 'local.properties' + +- task: DownloadSecureFile@1 + inputs: + secureFile: 'secring.gpg' + +- task: DownloadSecureFile@1 + inputs: + secureFile: 'secring.gpg.lock' + +- task: CopyFiles@2 + inputs: + SourceFolder: '$(Agent.TempDirectory)' + Contents: '**' + TargetFolder: '$(System.DefaultWorkingDirectory)' + +- task: Gradle@2 + inputs: + gradleWrapperFile: 'gradlew' + tasks: 'build' + publishJUnitResults: true + testResultsFiles: '**/TEST-*.xml' + javaHomeOption: 'JDKVersion' + sonarQubeRunAnalysis: false + +- task: PublishBuildArtifacts@1 + displayName: 'Publish Artifact: drop' + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)' + +- task: CopyFiles@2 + inputs: + SourceFolder: '$(System.DefaultWorkingDirectory)' + Contents: | + **/libs/* + build.gradle + gradlew + gradlew.bat + settings.gradle + gradle.properties + **/gradle/wrapper/* + TargetFolder: '$(Build.ArtifactStagingDirectory)/' + +- task: PublishBuildArtifacts@1 + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)' + ArtifactName: 'drop' + publishLocation: 'Container' + +- task: YodLabs.O365PostMessage.O365PostMessageBuild.O365PostMessageBuild@0 + displayName: 'Graph Client Tooling pipeline fail notification' + inputs: + addressType: serviceEndpoint + serviceEndpointName: 'microsoftgraph pipeline status' + title: '$(Build.DefinitionName) failure notification' + text: 'This pipeline has failed. View the build details for further information. This is a blocking failure.' + condition: and(failed(), ne(variables['Build.Reason'], 'Manual')) + enabled: true diff --git a/.azure-pipelines/prValidate.yml b/.azure-pipelines/prValidate.yml new file mode 100644 index 000000000..cdd049d0e --- /dev/null +++ b/.azure-pipelines/prValidate.yml @@ -0,0 +1,65 @@ +# Build and test Java Core to make sure a valid pull request is being made +pr: + branches: + include: + - master + - main + - dev + paths: + exclude: + - .azure-pipelines + - .gradle/wrapper + - .gitignore + - CONTRIBUTING.md + - LICENSE + - THIRD PARTY NOTICES + - gradle.properties + - gradlew + - gradlew.bat + - readme.md + - settings.gradle + +trigger: none # disable triggers based on commits. + +variables: + PACKAGE_NAME: 'microsoft-graph-core' + PROPERTIES_PATH: '.\gradle.properties' + +pool: + vmImage: windows-latest + +steps: +- checkout: self + clean: true + fetchDepth: 1 + +- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2 + displayName: 'Run CredScan' + inputs: + debugMode: false + +- task: PowerShell@2 + condition: and(failed(), eq(variables['Build.SourceBranchName'], 'dev')) + inputs: + filePath: '$(System.DefaultWorkingDirectory)\Scripts\validateMavenVersion.ps1' + pwsh: true + arguments: '-packageName "$(PACKAGE_NAME)" -propertiesPath "$(PROPERTIES_PATH)"' + +- task: Gradle@2 + inputs: + gradleWrapperFile: 'gradlew' + tasks: 'build' + publishJUnitResults: true + testResultsFiles: '**/TEST-*.xml' + javaHomeOption: 'JDKVersion' + sonarQubeRunAnalysis: false + +- task: YodLabs.O365PostMessage.O365PostMessageBuild.O365PostMessageBuild@0 + displayName: 'Graph Client Tooling pipeline fail notification' + inputs: + addressType: serviceEndpoint + serviceEndpointName: 'microsoftgraph pipeline status' + title: '$(Build.DefinitionName) failure notification' + text: 'This pipeline has failed. View the build details for further information. This is a blocking failure. ' + condition: and(failed(), ne(variables['Build.Reason'], 'Manual')) + enabled: true \ No newline at end of file diff --git a/Scripts/validateMavenVersion.ps1 b/Scripts/validateMavenVersion.ps1 new file mode 100644 index 000000000..282567a45 --- /dev/null +++ b/Scripts/validateMavenVersion.ps1 @@ -0,0 +1,60 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +<# +.Synopsis + Ensure the maven version is updated in the case that the pull request is + to the main/master branch of the repo. +.Description + Retrieves the local, Maven, and Bintray versions of the Java-Core build. + Checks that the Maven and Bintray versions are aligned, trigger warning if not. + Checks that the current local version is greater than those currently deployed. +#> + +.Parameter packageName +.Parameter propertiesPath + +Param( + [parameter(Mandatory = $true)] + [string]$packageName, + + [parameter(Mandatory = $true)] + [string]$propertiesPath +) + +#Find the local version from the Gradle.Properties file +$file = get-item $propertiesPath +$findLocalVersions = $file | Select-String -Pattern "mavenMajorVersion" -Context 0,2 +$findLocalVersions = $findLocalVersions -split "`r`n" + +$localMajor = $findLocalVersions[0].Substring($findLocalVersions[0].Length-1) +$localMinor = $findLocalVersions[1].Substring($findLocalVersions[1].Length-1) +$localPatch = $findLocalVersions[2].Substring($findLocalVersions[2].Length-1) +$localVersion = [version]"$localMajor.$localMinor.$localPatch" + +#Set Web Client and retrieve Maven and Bintray versions from their respective repos. +$web_client = New-Object System.Net.WebClient + +$mavenAPIurl = "https://search.maven.org/solrsearch/select?q=$packageName&rows=20&wt=json" +$jsonResult = $web_client.DownloadString($mavenAPIurl) | ConvertFrom-Json +$mavenVersion = [version]$jsonResult.response.docs.latestVersion + +$bintrayAPIurl = "https://api.bintray.com/search/packages?name=$packageName" +$jsonResult = $web_client.DownloadString($bintrayAPIurl) | ConvertFrom-Json +$bintrayVersion = [version]$jsonResult.latest_version + +#Inform host of current Maven and Bintray versions +write-host 'The current version in the Maven central repository is:' $mavenVersion +write-host 'The current version in the Bintray central repository is:' $bintrayVersion + +#Warn in case Maven and Bintray versions are not the same. +if($mavenVersion -ne $bintrayVersion){ + Write-Warning "The current Maven and Bintray versions are not the same" +} +#Success if Local version has been updated, Error otherwise. +if($localVersion -gt $bintrayVersion){ + Write-Host "The current pull request is of a greater version" +} +else{ + Write-Error "The current local version is not updated. Please update the local version in the Gradle.Properties file." +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 77dfc55e9..5203616e8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -27,7 +27,7 @@ mavenGroupId = com.microsoft.graph mavenArtifactId = microsoft-graph-core mavenMajorVersion = 1 mavenMinorVersion = 0 -mavenPatchVersion = 0 +mavenPatchVersion = 1 mavenArtifactSuffix = nightliesUrl = http://dl.bintray.com/MicrosoftGraph/Maven diff --git a/readme.md b/readme.md index eaf78529e..d16859cdd 100644 --- a/readme.md +++ b/readme.md @@ -19,7 +19,7 @@ repository { dependency { // Include the sdk as a dependency - compile('com.microsoft.graph:microsoft-graph-core:1.0.0') + compile('com.microsoft.graph:microsoft-graph-core:1.0.1') } ``` @@ -29,7 +29,7 @@ Add the dependency in `dependencies` in pom.xml com.microsoft.graph microsoft-graph-core - 1.0.0 + 1.0.1 ``` diff --git a/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java b/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java index 3e0b8ec06..e9a84bbc4 100644 --- a/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java +++ b/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java @@ -11,8 +11,9 @@ public class TelemetryHandler implements Interceptor{ public static final String SDK_VERSION = "SdkVersion"; - public static final String VERSION = "v1.0.0"; + public static final String VERSION = "v1.0.1"; public static final String GRAPH_VERSION_PREFIX = "graph-java-core"; + public static final String JAVA_VERSION_PREFIX = "java"; public static final String CLIENT_REQUEST_ID = "client-request-id"; @Override @@ -25,7 +26,8 @@ public Response intercept(Chain chain) throws IOException { telemetryOptions = new TelemetryOptions(); String featureUsage = "(featureUsage=" + telemetryOptions.getFeatureUsage() + ")"; - String sdkversion_value = GRAPH_VERSION_PREFIX + "/" + VERSION + " " + featureUsage; + String javaVersion = System.getProperty("java.version"); + String sdkversion_value = GRAPH_VERSION_PREFIX + "/" + VERSION + " " + featureUsage + " " + JAVA_VERSION_PREFIX + "/" + javaVersion; telemetryAddedBuilder.addHeader(SDK_VERSION, sdkversion_value); if(request.header(CLIENT_REQUEST_ID) == null) {