Skip to content
Build Station

Codemagic

Codemagic in the Build Station: store your token, link an app, auto-build on push, start builds, download artifacts and check your codemagic.yaml.

The Build Station builds locally. But some builds run in Codemagic: automatically on a push to a release branch, or because Windows builds need a Windows machine. The project’s Codemagic tab brings these builds into the same window. You see status and logs, start new builds, download artifacts and have your codemagic.yaml checked.

Storing the API token

  1. In Codemagic, copy the token under Account settings › API token.
  2. In the Station, paste it under Einstellungen › Codemagic (Settings › Codemagic) into the Neues API-Token (new API token) field and click Im Schlüsselbund speichern (save to keychain).
  3. Verbindung testen (test connection) shows how many apps are visible with the token.

The token is stored in the macOS keychain, not in config.json. If the environment variable CM_API_TOKEN is set, it takes precedence. The Station shows this.

The token has the rights of your Codemagic account, so it can also start and cancel builds. To rotate it, revoke it in Codemagic, create a new one and replace it here. Entfernen (remove) deletes it from the Mac.

Linking a project

In the Codemagic tab of a project that isn’t linked yet, there are two ways.

Vorhandene App verknüpfen … (link existing app) in the tab or Verknüpfen … (link) in the project editor under Codemagic opens the Mit Codemagic verknüpfen (link with Codemagic) dialog. The Station loads the account’s apps and marks the one that passt zum Repo (matches the repo) via the repository’s remote URL, otherwise via the name. Without a token, you enter the app ID by hand. It’s in the address codemagic.io/app/<App-ID>/settings.

The Station looks for codemagic.yaml in the project folder and from there upward to the repository root. So if the app sits in a subfolder of a monorepo, the file at the root is found. If it’s somewhere else, enter the path in the link.

Set up at Codemagic

Bei Codemagic einrichten … (set up at Codemagic) creates the app in Codemagic and makes sure every push to the chosen branch builds automatically. For a project that’s already linked, the same dialog is called Auto-Builds …. In one go, it takes care of:

  1. Creating the app for the repository’s remote URL. If there’s already an app for the same repository, the dialog suggests it instead of creating a second one. Optionally with a team ID.
  2. codemagic.yaml: If it’s missing, the dialog creates a template at the repository root, with a workflow for the project’s platforms, without signing. If it exists, the chosen workflow gets a trigger for pushes to the branch. Patterns like release/* are allowed. Workflows that already have triggers or use YAML anchors are left untouched.
  3. Committing and pushing codemagic.yaml: only this file, to the currently checked-out branch. Can be deselected.
  4. Webhook: Codemagic only learns about a push through a webhook. If Codemagic is connected to the repository via the GitHub app, it creates the webhook itself. Otherwise the Station creates it via the GitHub CLI (brew install gh and gh auth login, admin rights on the repository required). Without gh, or with GitLab and Bitbucket, the webhook address is shown at the end for copying.

Private repositories without Git integration in Codemagic need an SSH key, ideally a deploy key with read access. It goes to Codemagic once and isn’t stored anywhere.

The link is saved as soon as the app is settled, even if a later step fails. In that case, just open the dialog again.

The template builds without signing. For signed builds and publishing, store the credentials in Codemagic itself.

The “Codemagic” tab

  • Builds in Codemagic: newest first, with status, workflow, branch, commit and duration. While a build is running, the tab polls every 15 seconds. A filter shows only builds of the current branch.
  • Build details: steps, artifacts, Codemagic’s message and, on failure, the Log der gescheiterten Schritte (log of the failed steps), the last 300 lines per step, ready to copy.
  • Build starten … (start build): a workflow from codemagic.yaml, Branch or Tag, optionally variables just for this build. The dialog shows when the workflow runs on its own anyway. In Codemagic starten (start in Codemagic) sends off the job.
  • Codemagic opens the app in the Codemagic web interface.
  • A running build can be cancelled.

What’s checked before starting

Check Why
workflow is in codemagic.yaml otherwise Codemagic rejects it
branch is on origin Codemagic only builds what’s been pushed
no unpushed commits otherwise Codemagic builds an older state
codemagic.yaml without local changes Codemagic reads the file from the repository

The comparison is against the state of the last git fetch. The Station doesn’t fetch by itself, since that would hang without a network. In the Build tab, you refresh the state with Remote prüfen (git fetch) (check remote).

Downloading artifacts

Herunterladen (download) next to an artifact downloads it with your token into the collection folder of the local builds:

<Sammelordner>/<Projekt-ID>/codemagic/<Nummer>_<Build-ID>/<Datei>

Afterwards, Im Finder (in Finder) opens the folder. Cleanup covers these folders just like local builds.

In den Store (to the store) downloads the file and queues the upload to the configured store. This works for IPA, AAB, APK and MSIX. For Windows apps, this is the usual route, see Microsoft Store.

Checking and repairing codemagic.yaml

The tab shows a line about the file it found. Prüfen & reparieren … (check & repair) shows all findings. If there are none, the button is called Ansehen (view). It checks:

  • Syntax with line numbers, including duplicate keys
  • Structure: workflows present, unknown keys (typos), max_build_duration between 1 and 120, scripts with a command, artifacts as a list, triggers and branch_patterns
  • cd into nowhere: A script’s first cd has to point to a folder in the repository.
  • Flutter version: If environment.flutter differs from .fvmrc or the project setting, that’s the most common cause of “it works locally”.
  • Deprecated things that break first when the build machines are updated: flutter packages pub get, flutter pub run and built-in FCI_* variables, which are called CM_* today. Variables you defined yourself stay as they are.
  • Encrypted values (Encrypted(…)): just a note that they only apply to the app they were encrypted in.

Corrections appear as before and after and are written only when you click, line by line. Comments and order are preserved. If a line has changed since the check, the correction aborts instead of overwriting the wrong thing.

Afterwards you have to commit and push the file, because Codemagic reads it from the repository. You can do that right in the Build tab with Commit & Push.

The check doesn’t replace Codemagic’s own, which knows the full schema. It catches what can be said for sure without Codemagic, and does so before the push rather than after a failed build.

Limits

  • Workflows defined only in the Codemagic web interface (Workflow Editor) are shown in the tab. The Station can’t start them, because it reads its workflows from codemagic.yaml.
  • Filtered by branch or workflow, the build list goes back at most 120 builds.

Codemagic for AI assistants

The MCP server offers the same functions to an AI assistant, such as Claude Code. It can then investigate and repair a failed Codemagic build on its own. See MCP server for AI assistants.