-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate Windows .bat scripts (#31732)
- Loading branch information
Showing
17 changed files
with
576 additions
and
213 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import os | ||
import shutil | ||
|
||
from invoke.tasks import task | ||
|
||
from tasks.flavor import AgentFlavor | ||
from tasks.libs.common.utils import get_version | ||
from tasks.msi import build as build_agent_msi | ||
from tasks.msi import build_installer as build_installer_msi | ||
from tasks.omnibus import build as omnibus_build | ||
|
||
# Output directory for package files | ||
OUTPUT_PATH = os.path.join(os.getcwd(), "omnibus", "pkg") | ||
# Omnibus stores files here, e.g. C:\opt\datadog-agent, C:\opt\dataog-installer | ||
OPT_SOURCE_DIR = os.path.join('C:\\', 'opt') | ||
|
||
|
||
@task | ||
def agent_package( | ||
ctx, | ||
flavor=AgentFlavor.base.name, | ||
release_version="nightly-a7", | ||
skip_deps=False, | ||
): | ||
# Build agent | ||
omnibus_build( | ||
ctx, | ||
flavor=flavor, | ||
release_version=release_version, | ||
skip_deps=skip_deps, | ||
) | ||
|
||
# Package Agent into MSI | ||
build_agent_msi(ctx, release_version=release_version) | ||
|
||
# Package MSI into OCI | ||
if AgentFlavor[flavor] == AgentFlavor.base: | ||
ctx.run('powershell -C "./tasks/winbuildscripts/Generate-OCIPackage.ps1 -package datadog-agent"') | ||
|
||
|
||
@task | ||
def installer_package( | ||
ctx, | ||
release_version="nightly-a7", | ||
skip_deps=False, | ||
): | ||
# Build installer | ||
omnibus_build( | ||
ctx, | ||
release_version=release_version, | ||
skip_deps=skip_deps, | ||
target_project="installer", | ||
) | ||
|
||
# Package Insaller into MSI | ||
build_installer_msi(ctx) | ||
|
||
# Package MSI into OCI | ||
ctx.run('powershell -C "./tasks/winbuildscripts/Generate-OCIPackage.ps1 -package datadog-installer"') | ||
|
||
# Copy installer.exe to the output dir so it can be deployed as the bootstrapper | ||
agent_version = get_version( | ||
ctx, | ||
include_git=True, | ||
url_safe=True, | ||
include_pipeline_id=True, | ||
) | ||
shutil.copy2( | ||
os.path.join(OPT_SOURCE_DIR, "datadog-installer\\datadog-installer.exe"), | ||
os.path.join(OUTPUT_PATH, f"datadog-installer-{agent_version}-1-x86_64.exe"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<# | ||
.SYNOPSIS | ||
Builds the Datadog Agent packages for Windows. Builds everything with omnibus and packages the output into MSI, ZIP, and OCI. | ||
.DESCRIPTION | ||
This script builds the Datadog Agent packages for Windows, with options to configure the build environment. | ||
.PARAMETER ReleaseVersion | ||
Specifies the release version of the build. Default is the value of the environment variable RELEASE_VERSION. | ||
.PARAMETER Flavor | ||
Specifies the flavor of the agent. Default is the value of the environment variable AGENT_FLAVOR. | ||
.PARAMETER BuildOutOfSource | ||
Specifies whether to build out of source. Default is $false. | ||
Use this option in the CI to keep the job directory clean and avoid conflicts/stale data. | ||
Use this option in Hyper-V based containers to improve build performance. | ||
.PARAMETER InstallDeps | ||
Specifies whether to install dependencies (python requirements, go deps, etc.). Default is $true. | ||
.PARAMETER CheckGoVersion | ||
Specifies whether to check the Go version. If not provided, it defaults to the value of the environment variable GO_VERSION_CHECK or $true if the environment variable is not set. | ||
.EXAMPLE | ||
.\Build-AgentPackages.ps1 -InstallDeps $false | ||
.EXAMPLE | ||
.\Build-AgentPackages.ps1 -BuildOutOfSource $true -InstallDeps $true -Flavor "fips" -CheckGoVersion $true | ||
.NOTES | ||
This script should be run from the root of the repository. | ||
#> | ||
param( | ||
[bool] $BuildOutOfSource = $false, | ||
[nullable[bool]] $CheckGoVersion, | ||
[bool] $InstallDeps = $true, | ||
[string] $ReleaseVersion = $env:RELEASE_VERSION, | ||
[string] $Flavor = $env:AGENT_FLAVOR | ||
) | ||
|
||
. "$PSScriptRoot\common.ps1" | ||
|
||
Invoke-BuildScript ` | ||
-BuildOutOfSource $BuildOutOfSource ` | ||
-InstallDeps $InstallDeps ` | ||
-CheckGoVersion $CheckGoVersion ` | ||
-Command { | ||
$inv_args = @( | ||
"--skip-deps" | ||
) | ||
if ($ReleaseVersion) { | ||
$inv_args += "--release-version" | ||
$inv_args += $ReleaseVersion | ||
$env:RELEASE_VERSION=$ReleaseVersion | ||
} | ||
|
||
if ($Flavor) { | ||
$inv_args += "--flavor" | ||
$inv_args += $Flavor | ||
$env:AGENT_FLAVOR=$Flavor | ||
} | ||
|
||
Write-Host "inv -e winbuild.agent-package $inv_args" | ||
inv -e winbuild.agent-package @inv_args | ||
if ($LASTEXITCODE -ne 0) { | ||
Write-Error "Failed to build the agent package" | ||
exit 1 | ||
} | ||
|
||
# Show the contents of the output package directories for debugging purposes | ||
Get-ChildItem -Path C:\omnibus-ruby\pkg\ | ||
Get-ChildItem -Path "C:\opt\datadog-agent\bin\agent\" | ||
Get-ChildItem -Path ".\omnibus\pkg\" | ||
|
||
if ($BuildOutOfSource) { | ||
# Copy the resulting package to the mnt directory | ||
mkdir C:\mnt\omnibus\pkg -Force -ErrorAction Stop | Out-Null | ||
Copy-Item -Path ".\omnibus\pkg\*" -Destination "C:\mnt\omnibus\pkg" -Force -ErrorAction Stop | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<# | ||
.SYNOPSIS | ||
Builds the Datadog Installer packages for Windows. Builds everything with omnibus and packages the output into MSI, ZIP, and OCI. | ||
.DESCRIPTION | ||
This script builds the Datadog Installer packages for Windows, with options to configure the build environment. | ||
.PARAMETER BuildOutOfSource | ||
Specifies whether to build out of source. Default is $false. | ||
Use this option in the CI to keep the job directory clean and avoid conflicts/stale data. | ||
Use this option in Hyper-V based containers to improve build performance. | ||
.PARAMETER InstallDeps | ||
Specifies whether to install dependencies (python requirements, go deps, etc.). Default is $true. | ||
.PARAMETER ReleaseVersion | ||
Specifies the release version of the build. Default is the value of the environment variable RELEASE_VERSION. | ||
.PARAMETER CheckGoVersion | ||
Specifies whether to check the Go version. If not provided, it defaults to the value of the environment variable GO_VERSION_CHECK or $true if the environment variable is not set. | ||
.EXAMPLE | ||
.\Build-InstallerPackages.ps1 -InstallDeps $false | ||
.EXAMPLE | ||
.\Build-InstallerPackages.ps1 -BuildOutOfSource $true -InstallDeps $true -CheckGoVersion $true | ||
.NOTES | ||
This script should be run from the root of the repository. | ||
#> | ||
param( | ||
[bool] $BuildOutOfSource = $false, | ||
[nullable[bool]] $CheckGoVersion, | ||
[bool] $InstallDeps = $true, | ||
[string] $ReleaseVersion = $env:RELEASE_VERSION | ||
) | ||
|
||
. "$PSScriptRoot\common.ps1" | ||
|
||
Invoke-BuildScript ` | ||
-BuildOutOfSource $BuildOutOfSource ` | ||
-InstallDeps $InstallDeps ` | ||
-CheckGoVersion $CheckGoVersion ` | ||
-Command { | ||
$inv_args = @( | ||
"--skip-deps" | ||
) | ||
if ($ReleaseVersion) { | ||
$inv_args += "--release-version" | ||
$inv_args += $ReleaseVersion | ||
} | ||
|
||
Write-Host "inv -e winbuild.installer-package $inv_args" | ||
inv -e winbuild.installer-package @inv_args | ||
if ($LASTEXITCODE -ne 0) { | ||
Write-Error "Failed to build the agent package" | ||
exit 1 | ||
} | ||
|
||
# Show the contents of the output package directories for debugging purposes | ||
Get-ChildItem -Path C:\omnibus-ruby\pkg\ | ||
Get-ChildItem -Path C:\opt\datadog-installer | ||
Get-ChildItem -Path ".\omnibus\pkg\" | ||
|
||
if ($BuildOutOfSource) { | ||
# Copy the resulting package to the mnt directory | ||
mkdir C:\mnt\omnibus\pkg -Force -ErrorAction Stop | Out-Null | ||
Copy-Item -Path ".\omnibus\pkg\*" -Destination "C:\mnt\omnibus\pkg" -Force -ErrorAction Stop | ||
} | ||
} |
Oops, something went wrong.