> ## Documentation Index
> Fetch the complete documentation index at: https://docs.appsignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Capistrano

export const VersionRequirements = ({versions = []}) => {
  if (!Array.isArray(versions) || versions.length === 0) {
    return null;
  }
  const boundaries = {
    upper: " or lower",
    exact: "",
    lower: " or higher"
  };
  const containerStyle = {
    marginTop: "0.5rem",
    marginBottom: "1.5rem"
  };
  const lineStyle = {
    display: "block",
    margin: "0 0 0.35rem 0",
    fontSize: "0.875rem",
    lineHeight: "1.4"
  };
  const pillBaseStyle = {
    display: "inline-block",
    padding: "0.1em 0.4em",
    borderRadius: "0.25rem",
    border: "1px solid",
    fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
    fontSize: "0.85em",
    fontWeight: 500
  };
  const pillColors = {
    "AppSignal for Elixir": {
      background: "#f3e8ff",
      borderColor: "#e9d5ff",
      color: "#9333ea"
    },
    "AppSignal for Front-end": {
      background: "#fef9c3",
      borderColor: "#fde68a",
      color: "#ca8a04"
    },
    "AppSignal for Go": {
      background: "#ccfbf1",
      borderColor: "#99f6e4",
      color: "#0d9488"
    },
    "AppSignal for JavaScript": {
      background: "#fef9c3",
      borderColor: "#fde68a",
      color: "#ca8a04"
    },
    "AppSignal for Node.js": {
      background: "#dcfce7",
      borderColor: "#bbf7d0",
      color: "#16a34a"
    },
    "AppSignal for Python": {
      background: "#dbeafe",
      borderColor: "#bfdbfe",
      color: "#2563eb"
    },
    "AppSignal for Ruby": {
      background: "#fee2e2",
      borderColor: "#fecaca",
      color: "#dc2626"
    },
    "AppSignal for Rust": {
      background: "#ffedd5",
      borderColor: "#fed7aa",
      color: "#ea580c"
    }
  };
  const defaultPillColor = {
    background: "#f4f4f5",
    borderColor: "#e4e4e7",
    color: "#52525b"
  };
  const getPillStyle = name => ({
    ...pillBaseStyle,
    ...pillColors[name] || defaultPillColor
  });
  const getBoundText = bound => {
    return boundaries[bound] || boundaries.lower;
  };
  return <div style={containerStyle}>
      {versions.map((v, i) => <p key={`${v.name}-${v.version}-${v.bound || "lower"}-${i}`} style={lineStyle}>
          This feature requires{" "}
          <code style={getPillStyle(v.name)}>{v.name}</code> version {v.version}
          {getBoundText(v.bound)}.
        </p>)}
    </div>;
};

<VersionRequirements
  versions={[
{ name: "AppSignal for Ruby", version: "1.3" },
{ name: "Capistrano", version: "2" }
]}
/>

The [Capistrano](http://capistranorb.com/) integration makes sure an AppSignal deploy marker is created on
every deploy. Read more about
[deploy markers](/appsignal/terminology#markers). Some manual
configuration may be required.

## Installation

Make sure you load the `appsignal/capistrano` file in Capistrano's `Capfile`.
This should be done automatically when you run the `appsignal install` command
during installation.

<CodeGroup>
  ```ruby Ruby theme={null}
  # Capfile
  require 'capistrano'
  # Other Capistrano requires.
  require 'appsignal/capistrano'
  ```
</CodeGroup>

## Configuration

### appsignal\_config

<CodeGroup>
  ```ruby Ruby theme={null}
  # deploy.rb
  set :appsignal_config, name: 'My app'
  ```
</CodeGroup>

`appsignal_config` allows you to override any config loaded from the [configuration file](/ruby/configuration).

### appsignal\_env (since gem version 1.3)

<CodeGroup>
  ```ruby Ruby theme={null}
  # deploy.rb
  set :stage, :alpha
  set :appsignal_env, :staging
  ```
</CodeGroup>

`appsignal_env` allows you to load a different AppSignal environment when a
stage name doesn't match the AppSignal environment as named in the AppSignal
config file or environment variable.

### appsignal\_revision (since gem version 0.8.8)

<Warning>
  This method of reporting deploy markers is **deprecated** and may be removed at any time in the future.
  Reporting deploy markers using this method is only useful for small applications that use one application instance. It creates a new deploy marker at a specific time, regardless of the version the application is actually running. This also means it's also more error prone to group data that shouldn't belong to it under the deploy. We automatically detect deployment by reading the `REVISION` file which Capistrano adds to the release directory since Ruby gem 4.5.18.
</Warning>

In Capistrano 2 AppSignal is able to fetch the revision from the Capistrano
config.

In Capistrano 3 however, this is no longer available and setting the
revision is recommended.

<CodeGroup>
  ```ruby Ruby theme={null}
  # deploy.rb
  set :appsignal_revision, "my_revision"
  ```
</CodeGroup>

The revision can be set manually or fetched from the git repository locally.

<CodeGroup>
  ```ruby Ruby theme={null}
  # Sets the current branch's git commit SHA as the revision
  set :appsignal_revision, `git rev-parse --short HEAD`.strip
  ```
</CodeGroup>

If you're using the branch configuration setting Capistrano you can also set
git to fetch the commit SHA from the selected branch.

<CodeGroup>
  ```ruby Ruby theme={null}
  set :branch, "main"
  # Sets the selected branch's git commit SHA as the revision
  set :appsignal_revision, `git rev-parse --short #{fetch(:branch)}`.strip
  ```
</CodeGroup>

### appsignal\_user (since gem version 2.4.0)

Used in combination with `appsignal_revision` (if necessary), it's possible to customize a deploy user for Capistrano deploys.

By default this uses the system's local username, read from the `USER` or `USERNAME` environment variable, so there's no need to configure it if the system has these variables available.

If you do want to customize the deploy user, set the `:appsignal_user` config option in your Capistrano config.

<CodeGroup>
  ```ruby Ruby theme={null}
  # deploy.rb
  set :appsignal_user, "Jane" # Custom deploy user name
  ```
</CodeGroup>

## Example applications

We have two example applications in our examples repository on GitHub. The
examples show how to set up AppSignal in small Capistrano applications while
loading configuration values from the environment using gems like dotenv and
Figaro.

* [AppSignal + Capistrano + dotenv][example-dotenv-app]
* [AppSignal + Capistrano + Figaro][example-figaro-app]

[example-dotenv-app]: https://github.com/appsignal/appsignal-examples/tree/capistrano+dotenv

[example-figaro-app]: https://github.com/appsignal/appsignal-examples/tree/capistrano+figaro
