@@ -20,6 +20,10 @@ parameters:
20
20
default : test
21
21
22
22
steps :
23
+ # Create the ProjectList and ProjectListSha256 variables.
24
+ # The ProjectList is used by subsequent steps and tasks to run CI.
25
+ # The ProjectListSha256 is used by the cache key, previously the cache key was using ProjectList but it was found
26
+ # that long cache keys cause caching to fail.
23
27
- pwsh : |
24
28
$artifacts = '${{ convertToJson(parameters.Artifacts) }}' | ConvertFrom-Json
25
29
$additionalModules = '${{ convertToJson(parameters.AdditionalModules) }}' | ConvertFrom-Json
@@ -35,12 +39,18 @@ steps:
35
39
36
40
Write-Host "ProjectList = $projects"
37
41
Write-Host "##vso[task.setvariable variable=ProjectList;]$projects"
42
+
43
+ $sha256 = new-object -TypeName System.Security.Cryptography.SHA256Managed
44
+ $utf8 = new-object -TypeName System.Text.UTF8Encoding
45
+
46
+ $projectListSha256 = [Convert]::ToBase64String($sha256.ComputeHash($utf8.GetBytes($projects)))
47
+ Write-Host "##vso[task.setvariable variable=ProjectListSha256;]$projectListSha256"
38
48
displayName : Initialize project list variable
39
49
40
50
- task : Cache@2
41
51
inputs :
42
52
# Note: CacheSalt is only intented to be used in special cases, as a build is queued, to force a cache miss.
43
53
# This would be set as a variable in the UI when the run is queued.
44
- key : ' maven | "$(CacheSalt)" | "$(Agent.OS)" | $(Build.SourcesDirectory)/eng/versioning/external_dependencies.txt | "$(ProjectList )" | "${{ parameters.JobType }}" | "$(TestFromSource)"'
54
+ key : ' maven | "$(CacheSalt)" | "$(Agent.OS)" | $(Build.SourcesDirectory)/eng/versioning/external_dependencies.txt | "$(ProjectListSha256 )" | "${{ parameters.JobType }}" | "$(TestFromSource)"'
45
55
path : $(MAVEN_CACHE_FOLDER)
46
56
displayName : Cache Maven local repo
0 commit comments