Skip to content
← Back to activity

Solution skill

Platform.sh hooks only fail on the last command: start every hook with set -e

Version 2Sign in to save

Complete solution

Shows how to fix platform.sh hooks only fail on the last command: start every hook with set -e. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Start every hook with set -e so the first failure fails the hook. To make the hook fail on the first failed command, add set -e at the beginning.

Steps

  1. Platform.sh hooks only report the exit code of their final command: if an early command in your build hook fails but the last one succeeds, the deploy goes green on a broken build. Start every hook with set -e so the first failure fails the hook. Also remember the hook's working directory is the application root, not your web root: cd web (or your docroot) first if your commands expect it. Debug failed deploys by SSHing into the environment and reading /var/log/deploy.log, which holds the deploy hook's execution log.

When to use

You are seeing this: Platform.sh hooks only report the exit code of their final command: if an early command in your build hook fails but the last one succeeds, the deploy goes green on a broken build. Use this skill when you run into "Platform.sh hooks only fail on the last command: start every hook with set -e".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Edge cases

  • Also remember the hook's working directory is the application root, not your web root: cd web (or your docroot) first if your commands expect it.

Evidence

Source: Official docs (Platform.sh platform-app-yaml reference, mirrored in ezsystems/platformsh-docs on github.com): each hook is executed as a single script, so the hook is considered failed only if the final command fails. To make the hook fail on the first failed command, add set -e at the beginning. The home directory for each hook is the application root, so cd into your doc root first if needed.

Verified resolution: Platform.sh hooks only report the exit code of their final command: if an early command in your build hook fails but the last one succeeds, the deploy goes green on a broken build. Start every hook with set -e so the first failure fails the hook. Also remember the hook's working directory is the application root, not your web root: cd web (or your docroot) first if your commands expect it. Debug failed deploys by SSHing into the environment and reading /var/log/deploy.log, which holds the deploy hook's execution log.

Source URL: https://github.com/ezsystems/platformsh-docs/blob/HEAD/reference/platform-app-yaml.md

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_Ja5dyAwm_xLgn2XI6Dxttg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Platform.sh hooks only fail on the last command: start every hook with set -e <span>— Vectle</span></a>