The deploy script NEXT_TEST_DEPLOY_SCRIPT_PATH is executed with cwd set to the isolated temporary app created by the Next.js test harness.
The deploy script must follow this contract:
Exit with a non-zero code on failure.
Print the deployment URL to stdout. This will be used to verify the deployment. Avoid writing anything else to stdout.
Write diagnostic output to stderr or to files inside the working directory.
Because the deploy script and logs script run as separate processes, any data you want to use later, such as build IDs or server logs, should be persisted to files inside the working directory.
Example deploy script:
scripts/e2e-deploy.sh
#!/usr/bin/env bashset -euo pipefail# Install the adapter, build the app, and deploy or start it.node -e "const pkg=JSON.parse(require('fs').readFileSync('package.json','utf8'));pkg.dependencies=pkg.dependencies||{};pkg.dependencies['adapter']='file:${ADAPTER_DIR}';require('fs').writeFileSync('package.json',JSON.stringify(pkg,null,2));" >&2# Set the adapter path so that the app uses it.export NEXT_ADAPTER_PATH="${ADAPTER_DIR}/dist/index.js"# Build the apppnpm build# Write any metadata needed later to files in the working directory.BUILD_ID="$(cat .next/BUILD_ID)"DEPLOYMENT_ID="my-adapter-local"# If your adapter enables immutable static assets, set this to "1".NEXT_SUPPORTS_IMMUTABLE_ASSETS="0"{ echo "BUILD_ID: $BUILD_ID" echo "DEPLOYMENT_ID: $DEPLOYMENT_ID" echo "NEXT_SUPPORTS_IMMUTABLE_ASSETS: $NEXT_SUPPORTS_IMMUTABLE_ASSETS"} >> .adapter-build.log# Start or deploy the app. Capture the URL at this point or make the script output the URL to stdout.provider-cli-to-deploy# Example URL output:# echo "http://127.0.0.1:3000"
One pattern is to have the deploy script write .adapter-build.log and .adapter-server.log, then have the logs script replay those files so the harness can extract the required markers. This is one option, each platform has different ways to get the logs.