public function markFailed($notify = true) {
		// Abort all running or queued steps.
		$steps = $this->Steps();
		foreach($steps as $step) {
			if ($step->isQueued() || $step->isRunning()) $step->abort();
		}

		if($this->canStartRollback()) {
			$this->beginRollback();
		} else if ($this->isRollback()) {
			$this->finaliseRollback();
		} else {
			// Not able to roll back - fail immediately.
			$this->Status = 'Failed';
			$this->log("Pipeline failed, not running rollback (not configured or not applicable yet).");
			$this->write();
			if($notify) $this->sendMessage(self::ALERT_FAILURE);
		}

		// Regardless of whether a rollback succeeded or not, we consider the deployment a failure.
		$deployment = $this->CurrentDeployment();
		if ($deployment) {
			$deployment->Status = 'Failed';
			$deployment->write();
		}
	}