Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 76 additions & 6 deletions packages/windows-connector/config.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# Copyright 2025 Delphix
# Copyright 2025, 2026 Delphix
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -24,12 +24,82 @@ function prepare() {
openjdk-17-jdk-headless
}

#
# windows-connector is only rebuilt when its version (project.ext.connectorVersion
# in appliance/host/windows/build.gradle) is bumped. Unlike other linux-pkg
# packages, windows-connector's build toolchain (nsis/mono/mingw-w64, replacing a
# formerly-licensed Visual Studio toolchain) lives outside our own source and can
# drift independently of any change to windows-connector itself. Rebuilding on
# every unrelated trigger risks silently shipping a different toolchain
# combination without anyone deciding to re-certify it, which matters more here
# since this installer isn't tied to the engine upgrade path -- customers
# manually uninstall/reinstall it.
#
# Rather than maintain a bespoke cache location, we reuse the same "latest"
# post-push artifact lookup every linux-pkg package already uses to fetch its own
# build dependencies (get_package_dependency_s3_url). That artifact is already
# kept alive indefinitely by the existing s3-artifact-refresh job, and correctly
# resolves to the frozen release snapshot instead when building against a
# release tag (e.g. for a hotfix), with no special-casing needed here.
#
# The existence check below is written to fail soft: if the previous artifact
# (or its "latest" pointer) can't be found for any reason -- including having
# been deleted, accidentally or otherwise -- we just fall through to a normal
# build, rather than aborting the job.
#
function build() {
CONNECTOR_DIR="${WORKDIR}/repo/appliance/server/connector"
INSTALLER_DIR="${WORKDIR}/repo/appliance/host/windows"
logmust cd "$CONNECTOR_DIR"
logmust sudo ../../gradlew build
logmust cd "$INSTALLER_DIR"
logmust sudo ../../gradlew createDebPackage
logmust sudo mv ./build/distributions/*deb "$WORKDIR/artifacts/"

local version
version=$(grep "project.ext.connectorVersion" "$INSTALLER_DIR/build.gradle" |
sed -E "s/.*'([^']+)'.*/\1/")
local deb_name="windows-connector_${version}_all.deb"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this assumes a rebuild will produce an artifact of this specific filename.. without actually controlling it here.. IMO, that coupling is fragile, as the filename can change in the app-gate repo, and this repo would then not behave properly (e.g. it'd start to rebuild when we don't want it to)..


#
# Resolve windows-connector's own "latest" post-push artifact, the same way
# any other package would resolve a build dependency on it. This runs in a
# subshell so that a missing "latest" pointer -- get_package_dependency_s3_url
# calls die(), which calls exit -- only aborts this lookup, not the whole
# build.
#
local latest_s3_url
latest_s3_url=$(
get_package_dependency_s3_url "windows-connector" 1>&2
printf '%s' "$_RET"
)

local reused=false
if [[ -n "$latest_s3_url" ]]; then
local bucket="${latest_s3_url#s3://}"
bucket="${bucket%%/*}"
local key="${latest_s3_url#s3://"$bucket"/}"

if aws s3api head-object --bucket "$bucket" --key "$key/$deb_name" >/dev/null 2>&1; then
echo "windows-connector $version already built (latest); reusing it instead of rebuilding"
logmust cd "$WORKDIR/artifacts"
logmust aws s3 cp --only-show-errors "$latest_s3_url/$deb_name" .
reused=true
Comment on lines +79 to +82

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed, and wastes s3 object space for nothing. The previously built package is already referenced by the "latest" combine-packages object, so there is no reason to have to copy that and call combine-packages again. IMO we should do nothing at all in this case. There is an explicit Jenkins build status to represent that something wasn't built ("NOT_BUILT"). That feels appropriate here. We should exit with some code that results in the build-package job ending as "NOT_BUILT".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree.

fi
fi

if [[ "$reused" != true ]]; then
echo "No reusable artifact found for windows-connector $version; building from source"
logmust cd "$CONNECTOR_DIR"
logmust sudo ../../gradlew build
logmust cd "$INSTALLER_DIR"
logmust sudo ../../gradlew createDebPackage
logmust cp ./build/distributions/*.deb "$WORKDIR/artifacts/$deb_name"
#
# No explicit upload here -- the shared post-push Publish stage already
# syncs $WORKDIR/artifacts to S3 and updates "latest" for us, exactly
# like every other linux-pkg package.
#
Comment on lines +93 to +97

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary comment, this is core behavior provided by the linux-pkg infra, and relied on by every package.. don't think it needs a package specific comment.

fi

if [[ "$reused" == true ]]; then
echo "reused" >"$WORKDIR/artifacts/BUILD_STATUS"
else
echo "built_fresh" >"$WORKDIR/artifacts/BUILD_STATUS"
fi
Comment on lines +100 to +104

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this matter? this essentially equates to it always being "reused", due to the cadence of app-gate pushes to connect version bumps.. regardless, what consumes this, and why?

feels overly complicated for no good reason, IMO..

}