diff --git a/.azure-pipelines/buildAndPackage.yml b/.azure-pipelines/buildAndPackage.yml index 0092324b9..7b0f89d28 100644 --- a/.azure-pipelines/buildAndPackage.yml +++ b/.azure-pipelines/buildAndPackage.yml @@ -32,6 +32,9 @@ pr: pool: vmImage: windows-latest +variables: + DROP_PATH: '$(Agent.BuildDirectory)/Drop' + stages: - stage: Build jobs: @@ -57,14 +60,17 @@ stages: deploy: steps: - template: templates/download-artifacts.yml + parameters: + directoryPath: $(DROP_PATH) - template: templates/install-java.yml - template: templates/secure-files.yml - template: templates/copy-and-build.yml parameters: task: 'publishSnapshotPublicationToSonatypeSnapshotRepository' + directoryPath: $(DROP_PATH) - stage: Maven_Release_And_Github_Release - dependsOn: [] + dependsOn: Build condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) jobs: - deployment: Maven_Release @@ -76,6 +82,8 @@ stages: deploy: steps: - template: templates/download-artifacts.yml + parameters: + directoryPath: $(DROP_PATH) - template: templates/install-java.yml - template: templates/secure-files.yml parameters: @@ -83,6 +91,7 @@ stages: - template: templates/copy-and-build.yml parameters: task: 'publishMavenCentralReleasePublicationToSonatypeRepository' + directoryPath: $(DROP_PATH) - deployment: Github_Release dependsOn: Maven_Release @@ -94,6 +103,9 @@ stages: deploy: steps: - template: templates/download-artifacts.yml + parameters: + directoryPath: $(DROP_PATH) - template: templates/version-and-release.yml parameters: gitConnection: 'microsoftgraphrelease' + directoryPath: $(DROP_PATH) diff --git a/.azure-pipelines/templates/build/publish-artefacts.yml b/.azure-pipelines/templates/build/publish-artefacts.yml index fc7f7a4c3..5c67587a8 100644 --- a/.azure-pipelines/templates/build/publish-artefacts.yml +++ b/.azure-pipelines/templates/build/publish-artefacts.yml @@ -1,5 +1,6 @@ steps: - task: CopyFiles@2 + condition: ne(variables['Build.Reason'], 'PullRequest') inputs: SourceFolder: '$(System.DefaultWorkingDirectory)' Contents: | @@ -16,5 +17,6 @@ steps: TargetFolder: '$(Build.ArtifactStagingDirectory)/' - publish: $(Build.ArtifactStagingDirectory) + condition: ne(variables['Build.Reason'], 'PullRequest') artifact: Drop displayName: Publish Build Artifact diff --git a/.azure-pipelines/templates/copy-and-build.yml b/.azure-pipelines/templates/copy-and-build.yml index 0ae9f5d55..787fe1a6f 100644 --- a/.azure-pipelines/templates/copy-and-build.yml +++ b/.azure-pipelines/templates/copy-and-build.yml @@ -2,18 +2,20 @@ parameters: - name: task type: string default: '' +- name: directoryPath + type: string steps: - task: CopyFiles@2 inputs: SourceFolder: '$(Agent.TempDirectory)' Contents: '**' - TargetFolder: '$(Agent.BuildDirectory)/Drop/' + TargetFolder: '${{ parameters.directoryPath }}/' - task: Gradle@2 inputs: - gradleWrapperFile: $(Agent.BuildDirectory)/Drop/gradlew - workingDirectory: '$(Agent.BuildDirectory)/Drop/' + gradleWrapperFile: ${{ parameters.directoryPath }}/gradlew + workingDirectory: '${{ parameters.directoryPath }}/' options: '-x jar -x javadoc -x javadocJar -x compileJava -x processResources -x classes -x sourceJar' tasks: ${{ parameters.task }} publishJUnitResults: true diff --git a/.azure-pipelines/templates/download-artifacts.yml b/.azure-pipelines/templates/download-artifacts.yml index dfc62df72..ecd6d7d9e 100644 --- a/.azure-pipelines/templates/download-artifacts.yml +++ b/.azure-pipelines/templates/download-artifacts.yml @@ -1,10 +1,14 @@ +parameters: +- name: directoryPath + type: string + steps: - download: none - task: DownloadPipelineArtifact@2 inputs: source: current artifact: Drop - path: '$(Agent.BuildDirectory)/Drop/' + path: '${{ parameters.directoryPath }}/' patterns: | ** - * \ No newline at end of file + * diff --git a/.azure-pipelines/templates/version-and-release.yml b/.azure-pipelines/templates/version-and-release.yml index 78597aeb9..92eb32359 100644 --- a/.azure-pipelines/templates/version-and-release.yml +++ b/.azure-pipelines/templates/version-and-release.yml @@ -2,12 +2,14 @@ parameters: - name: gitConnection type: string default: '' +- name: directoryPath + type: string steps: - task: PowerShell@2 inputs: - filePath: '$(DROP_PATH)/Scripts/getLatestVersion.ps1' - arguments: '-propertiesPath "$(DROP_PATH)/gradle.properties"' + filePath: '${{ parameters.directoryPath }}/Scripts/getLatestVersion.ps1' + arguments: '-propertiesPath "${{ parameters.directoryPath }}/gradle.properties"' pwsh: true - task: GitHubRelease@1 diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 87a956450..1beef4a0f 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -2,12 +2,12 @@ dependencies { // Use JUnit test framework testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2' - testImplementation 'org.mockito:mockito-inline:3.11.2' + testImplementation 'org.mockito:mockito-inline:3.12.3' api 'com.squareup.okhttp3:okhttp:4.9.1' implementation 'com.google.guava:guava:30.1.1-jre' - implementation 'com.google.code.gson:gson:2.8.7' + implementation 'com.google.code.gson:gson:2.8.8' api 'com.azure:azure-core:1.19.0' } \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3823f7259..e1b3b7f3c 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ com.google.code.gson gson - 2.8.7 + 2.8.8 com.google.guava @@ -46,7 +46,7 @@ org.mockito mockito-inline - 3.11.2 + 3.12.3 test diff --git a/scripts/getLatestVersion.ps1 b/scripts/getLatestVersion.ps1 index d269bcaa8..088034789 100644 --- a/scripts/getLatestVersion.ps1 +++ b/scripts/getLatestVersion.ps1 @@ -23,11 +23,12 @@ $file = get-item $propertiesPath $findVersions = $file | Select-String -Pattern "mavenMajorVersion" -Context 0,2 $findVersions = $findVersions -split "`r`n" -$majorVersion = $findVersions[0].Substring($findVersions[0].Length-1) -$minorVersion = $findVersions[1].Substring($findVersions[1].Length-1) -$patchVersion = $findVersions[2].Substring($findVersions[2].Length-1) +$versionIndex = $findVersions[0].IndexOf("=") +$majorVersion = $findVersions[0].Substring($versionIndex+2) +$minorVersion = $findVersions[1].Substring($versionIndex+2) +$patchVersion = $findVersions[2].Substring($versionIndex+2) $version = "$majorVersion.$minorVersion.$patchVersion" #Update the VERSION_STRING env variable and inform the user Write-Host "##vso[task.setVariable variable=VERSION_STRING]$($version)"; -Write-Host "Updated the VERSION_STRING enviornment variable with the current Gradle.Properties, $version" \ No newline at end of file +Write-Host "Updated the VERSION_STRING enviornment variable with the current Gradle.Properties, $version"