Skip to content

Commit

Permalink
Add Update-java-CIConfig (#17631)
Browse files Browse the repository at this point in the history
* Add Update-java-CIConfig

* Switch from BuildNumber to BuildID for test release versions
  • Loading branch information
chidozieononiwu authored Nov 18, 2020
1 parent c3e9180 commit 5d3ee58
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
2 changes: 1 addition & 1 deletion eng/pipelines/templates/jobs/archetype-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
pwsh: true
workingDirectory: $(Build.SourcesDirectory)
filePath: eng/scripts/SetTestPipelineVersion.ps1
arguments: '-BuildNumber $(Build.BuildNumber)'
arguments: '-BuildID $(Build.BuildId)'

- script: |
echo "##vso[build.addbuildtag]Scheduled"
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/templates/stages/archetype-java-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ stages:
pwsh: true
workingDirectory: $(Build.SourcesDirectory)
filePath: eng/scripts/SetTestPipelineVersion.ps1
arguments: '-BuildNumber $(Build.BuildNumber)'
arguments: '-BuildID $(Build.BuildId)'

- task: UsePythonVersion@0
displayName: 'Use Python 3.6'
Expand Down
44 changes: 44 additions & 0 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,47 @@ function Get-java-GithubIoDocIndex() {
# Generate yml/md toc files and build site.
GenerateDocfxTocContent -tocContent $tocContent -lang "Java"
}

# a "package.json configures target packages for all the monikers in a Repository, it also has a slightly different
# schema than the moniker-specific json config that is seen in python and js
function Update-java-CIConfig($pkgs, $ciRepo, $locationInDocRepo, $monikerId=$null){
$pkgJsonLoc = (Join-Path -Path $ciRepo -ChildPath $locationInDocRepo)

if (-not (Test-Path $pkgJsonLoc)) {
Write-Error "Unable to locate package json at location $pkgJsonLoc, exiting."
exit(1)
}

$allJsonData = Get-Content $pkgJsonLoc | ConvertFrom-Json

$visibleInCI = @{}

for ($i=0; $i -lt $allJsonData[$monikerId].packages.Length; $i++) {
$pkgDef = $allJsonData[$monikerId].packages[$i]
$visibleInCI[$pkgDef.packageArtifactId] = $i
}

foreach ($releasingPkg in $pkgs) {
if ($visibleInCI.ContainsKey($releasingPkg.PackageId)) {
$packagesIndex = $visibleInCI[$releasingPkg.PackageId]
$existingPackageDef = $allJsonData[$monikerId].packages[$packagesIndex]
$existingPackageDef.packageVersion = $releasingPkg.PackageVersion
}
else {
$newItem = New-Object PSObject -Property @{
packageDownloadUrl = "https://repo1.maven.org/maven2"
packageGroupId = $releasingPkg.GroupId
packageArtifactId = $releasingPkg.PackageId
packageVersion = $releasingPkg.PackageVersion
inputPath = @()
excludePath = @()
}

$allJsonData[$monikerId].packages += $newItem
}
}

$jsonContent = $allJsonData | ConvertTo-Json -Depth 10 | % {$_ -replace "(?m) (?<=^(?: )*)", " " }

Set-Content -Path $pkgJsonLoc -Value $jsonContent
}
4 changes: 2 additions & 2 deletions eng/scripts/SetTestPipelineVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

param (
[Parameter(mandatory = $true)]
$BuildNumber
$BuildID
)

. "${PSScriptRoot}\..\common\scripts\common.ps1"
Expand All @@ -23,7 +23,7 @@ LogDebug "Last Published Version $($semVarsSorted[0])"

$newVersion = [AzureEngSemanticVersion]::ParseVersionString($semVarsSorted[0])
$newVersion.PrereleaseLabel = "beta"
$newVersion.PrereleaseNumber = $BuildNumber
$newVersion.PrereleaseNumber = $BuildID

LogDebug "Version to publish [ $($newVersion.ToString()) ]"

Expand Down

0 comments on commit 5d3ee58

Please sign in to comment.