diff --git a/.gitlab/choco_build/choco_build.yml b/.gitlab/choco_build/choco_build.yml index 4954aeccd3fa2..06ff3c6bb5d0d 100644 --- a/.gitlab/choco_build/choco_build.yml +++ b/.gitlab/choco_build/choco_build.yml @@ -2,7 +2,7 @@ # choco_build stage # Contains jobs which build the chocolatey Agent package. -# The online version of the choco job gets the msi package through the gitlab artifacts +# The choco job gets the msi package through the gitlab artifacts .windows_choco_7_x64: rules: !reference [.on_deploy_stable_or_beta_repo_branch] @@ -13,11 +13,7 @@ script: - '$_instance_id = (iwr -UseBasicParsing http://169.254.169.254/latest/meta-data/instance-id).content ; Write-Host "Running on instance $($_instance_id)"' - $ErrorActionPreference = "Stop" - - mkdir temp\ - - copy omnibus\pkg\*.msi temp\ - - if (Test-Path omnibus) { remove-item -recurse -force omnibus } - if (Test-Path build-out) { remove-item -recurse -force build-out } - - mkdir omnibus\pkg - > docker run --rm -v "$(Get-Location):c:\mnt" @@ -26,10 +22,8 @@ -e BUCKET_BRANCH="$BUCKET_BRANCH" -e AWS_NETWORKING=true registry.ddbuild.io/ci/datadog-agent-buildimages/windows_1809_${ARCH}${Env:DATADOG_AGENT_WINBUILDIMAGES_SUFFIX}:${Env:DATADOG_AGENT_WINBUILDIMAGES} - powershell.exe -C "C:\mnt\tasks\winbuildscripts\Generate-Chocolatey-Package.ps1 -MSIDirectory c:\mnt\temp -Flavor $FLAVOR -InstallDeps 1" + powershell.exe -C "C:\mnt\tasks\winbuildscripts\Generate-Chocolatey-Package.ps1 -MSIDirectory c:\mnt\omnibus\pkg -Flavor $FLAVOR -InstallDeps 1" - If ($lastExitCode -ne "0") { throw "Previous command returned $lastExitCode" } - - Remove-Item -Path "temp\" -Recurse -Force - - copy build-out\*.nupkg omnibus\pkg - $CopyNupkgToS3 = "$S3_CP_CMD --recursive --exclude '*' --include '*.nupkg' build-out $S3_RELEASE_ARTIFACTS_URI/choco/nupkg" - Invoke-Expression $CopyNupkgToS3 artifacts: diff --git a/tasks/winbuildscripts/Generate-Chocolatey-Package.ps1 b/tasks/winbuildscripts/Generate-Chocolatey-Package.ps1 index d8d32e9927c59..29e1651d42c7f 100644 --- a/tasks/winbuildscripts/Generate-Chocolatey-Package.ps1 +++ b/tasks/winbuildscripts/Generate-Chocolatey-Package.ps1 @@ -15,7 +15,7 @@ Overrides the Agent version when building packages locally for testing. Indicates whether to install dependencies. The default value is $true. .EXAMPLE -.\Generate-Chocolatey-Package.ps1 -Flavor datadog-agent -VersionOverride "7.62.0" -msiDirectory C:\mnt\omnibus\pkg\ +.\Generate-Chocolatey-Package.ps1 -Flavor datadog-agent -VersionOverride "7.62.0" -msiDirectory C:\mnt\omnibus\pkg Generates a chocolatey package for 7.62.0, requires the MSI file to be present in MSIDirectory. @@ -26,7 +26,7 @@ Generates a chocolatey package for PR/devel build 7.62.0-devel.git.276.e59b1b3.p The generated chocolatey package requires the MSI be uploaded to the dd-agent-mstesting bucket. #> Param( - [Parameter(Mandatory=$false)] + [Parameter(Mandatory=$true)] [String] $msiDirectory, @@ -79,16 +79,14 @@ try { # For historical reasons, use a different artifact name for the datadog-agent flavor # See agent-release-management for more details $artifactName = "ddagent-cli" - $packageSource = "$repoRoot\chocolatey\datadog-agent" - $nuspecFile = "datadog-agent.nuspec" } elseif ($Flavor -eq "datadog-fips-agent") { $artifactName = "datadog-fips-agent" - $packageSource = "$repoRoot\chocolatey\datadog-fips-agent" - $nuspecFile = "datadog-fips-agent.nuspec" } else { Write-Error "Unknown flavor $Flavor" exit 1 - } + + $packageSource = "$repoRoot\chocolatey\$Flavor" + $nuspecFile = "$Flavor.nuspec" # These files/directories are referenced in the nuspec file $licensePath = "tools\LICENSE.txt" @@ -141,16 +139,16 @@ try { # Template the install script with the URL and checksum try { - $tempMsi = Join-Path -Path "$msiDirectory" "$flavor-$rawAgentVersion-1-x86_64.msi" - if (!(Test-Path $tempMsi)) { - Write-Host "Error: Could not find MSI file in $tempMsi" + $msiPath = Join-Path -Path "$msiDirectory" "$flavor-$rawAgentVersion-1-x86_64.msi" + if (!(Test-Path $msiPath)) { + Write-Host "Error: Could not find MSI file in $msiPath" Get-ChildItem "$msiDirectory" exit 1 } - $checksum = (Get-FileHash $tempMsi -Algorithm SHA256).Hash + $checksum = (Get-FileHash $msiPath -Algorithm SHA256).Hash } catch { - Write-Host "Error: Could not generate checksum for package $($tempMsi): $($_)" + Write-Host "Error: Could not generate checksum for package $($msiPath): $($_)" exit 1 } # Set the $url in the install script