Pre-Build Hooks and Build Artifacts
Run project-defined verification or preparation scripts in .appmana/prebuild/*.sh before Unity builds, and collect generated files from .appmana/ after the build finishes.
AppMana cloud builds support project-defined pre-build shell hooks under .appmana/prebuild/ and automatic post-build upload of generated files from .appmana/.
Pre-build hooks (.appmana/prebuild/*.sh)
Every Linux, Windows, and WebGL Unity build pipeline runs a do-pre-build task after do-post-clone and before do-build. If your repository contains .sh files under .appmana/prebuild/, AppMana executes them automatically before Unity starts.
Discovery and execution order
Scripts are discovered with a case-insensitive filename match and executed in sorted lexicographical order:
find .appmana/prebuild/ -iname "*.sh" | sort
Use numeric prefixes (01-verify.sh, 02-generate.sh, ...) so execution order is explicit and deterministic. If .appmana/prebuild/ does not exist or contains no .sh files, do-pre-build succeeds immediately.
Linux and Windows behavior
| Target | Tekton task | Container image | Shell & working directory |
|---|---|---|---|
| Linux / WebGL | prebuild |
harbor.appmana.com/appmana-shared/builder:linux-latest |
bash from the repository root ($(workspaces.source.path)) |
| Windows | prebuild-windows |
harbor.appmana.com/appmana-shared/builder:latest |
C:/busybox64.exe bash from $(workspaces.source.path)/repository |
If your project builds on both Linux and Windows, write POSIX/bash-compatible scripts and guard OS-specific commands (for example by checking uname -s).
Timeout and fail-fast exit codes
- Timeout:
do-pre-buildhas a 15-minute (15m) step timeout. - Fail-fast: Each script runs as
bash "$SCRIPT" || exit $?. If any script exits with a non-zero status code,do-pre-buildstops immediately without running later scripts, runs its cleanup trap, and fails the pipeline with that exit code beforedo-buildbegins.
Security hardening
do-pre-build runs in an isolated build task before the Unity Editor starts:
- Runs under the unprivileged
*-build-executionServiceAccount with no Kubernetes API token mounted (automountServiceAccountToken: false). - Before executing any repository script, the step unsets shell, JVM, and linker injection variables (
BASH_ENV,ENV,PROMPT_COMMAND,JAVA_TOOL_OPTIONS,JDK_JAVA_OPTIONS,GRADLE_OPTS,LD_PRELOAD), deletes.git-credentials, and removes global and system Gitcredential.helpersettings. - An
EXITtrap always deletes shell startup dotfiles (~/.bashrc,~/.bash_profile,~/.profile, and/tekton/home/.bashrc,/tekton/home/.bash_profile,/tekton/home/.profile) and~/.gradle//tekton/home/.gradle, even when a hook exits non-zero. - Unity build tasks mount a task-local ephemeral volume over
Library/, so pre-build hooks should not attempt to pre-populate or modifyLibrary/.
Example pre-build script
Commit .appmana/prebuild/01-verify.sh to your repository to fail fast on broken Git LFS pointers or failing project checks before spending time on a Unity build:
#!/usr/bin/env bash
set -euo pipefail
echo "Verifying repository before Unity build..."
# Example: verify no tracked LFS pointer files were left unhydrated
if command -v git >/dev/null 2>&1; then
git lfs status || true
fi
# Example: run project-specific preflight checks
if [ -x "./Tests/WebGL/run-bridge-preflight.sh" ]; then
./Tests/WebGL/run-bridge-preflight.sh
fi
Post-build .appmana/ S3 artifact sync (do-post-build)
When do-build runs, the pipeline's finally task do-post-build (build-notification-linux on Linux/WebGL or build-notification-windows on Windows) checks for a .appmana/ directory in the workspace and syncs its contents to object storage:
s3://appmana-generated-files/<namespace>/<projectName>
Use .appmana/ for build-generated reports, thumbnails, or diagnostic files that you want persisted after a build finishes.
Security note:
do-post-buildintentionally does not execute user scripts (there is no.appmana/postbuild/*.shhook). It only reads and uploads files from.appmana/using scoped workload storage credentials so post-build notification and storage steps never run untrusted repository code.
