# Codemagic

> Start and cancel Codemagic builds, read their steps and artifacts, share artifacts by link, manage apps, variable groups and caches, and follow new, successful and failed builds.

App · 24 actions. Web page: https://docs.lodol.com/docs/integrations/codemagic

## Actions

### Add app

Add a Git repository to Codemagic as an app, optionally in a team.

**Inputs**

- Repository URL (`repository_url`, text, required): The repository's SSH or HTTPS clone URL, such as git@github.com:acme/app.git.
- Team (`team`, text): The team to add it to. You must be an admin of it. Leave empty for your personal account.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "_id": "example",
    "appName": "example"
  }
}
```

### Add variables

Add environment variables to a variable group, optionally as secure (hidden) values.

**Inputs**

- Variable group ID (`variable_group_id`, text, required): The variable group's ID, as Create variable group or List variable groups gives it.
- Variables (`variables`, object, required): The variables to add, as name and value pairs, such as API_URL.
- Secure (`secure`, true/false): Store the values encrypted, so nobody can read them back. Leave off for readable values.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "added": [
      "example"
    ],
    "secure": true
  }
}
```

### Cancel build

Cancel a build that hasn't finished. A finished build is left as it is.

**Inputs**

- Build ID (`build_id`, text, required): The build's ID, as Start build or List builds gives it.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {}
}
```

### Create artifact public link

Make a download link for a build artifact that anyone can open until it expires.

**Inputs**

- Artifact link (`artifact_url`, text, required): The artifact's link in Codemagic, which starts with https://api.codemagic.io/artifacts/.
- Expires at (`expires_at`, date and time, required): When the public link stops working.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "expiresAt": "example",
    "url": "example"
  }
}
```

### Create variable group

Create a group of environment variables for an app's builds.

**Inputs**

- App (`app_id`, text, required): The Codemagic app.
- Name (`name`, text, required): The group's name, such as production. It can't contain . or $.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "data": {
      "id": "example",
      "name": "example"
    }
  }
}
```

### Delete cache

Delete one of an app's build caches, so the workflow's next build starts without it.

**Inputs**

- App (`app_id`, text, required): The Codemagic app.
- Cache (`cache_id`, text, required): The cache.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "caches": [
      "example"
    ],
    "message": "example"
  }
}
```

### Delete variable

Delete one variable from a variable group.

**Inputs**

- Variable group ID (`variable_group_id`, text, required): The variable group's ID, as Create variable group or List variable groups gives it.
- Variable (`variable_id`, text, required): The variable.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {}
}
```

### Delete variable group

Delete a variable group and all its variables. This can't be undone.

**Inputs**

- Variable group ID (`variable_group_id`, text, required): The variable group's ID, as Create variable group or List variable groups gives it.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {}
}
```

### Get app

Get an app's name, branches and Workflow Editor workflows.

**Inputs**

- App (`app_id`, text, required): The Codemagic app.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "application": {
      "_id": "example",
      "appName": "example",
      "branches": [
        "example"
      ],
      "workflowIds": [
        "example"
      ],
      "workflows": {}
    }
  }
}
```

### Get build

Get a build's status, workflow, commit, artifacts and timing.

**Inputs**

- Build ID (`build_id`, text, required): The build's ID, as Start build or List builds gives it.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "data": {
      "app_id": "example",
      "artifacts": [
        {
          "name": "example",
          "short_lived_download_url": "example",
          "size_in_bytes": 1,
          "type": "example",
          "version_code": "example",
          "version_name": "example"
        }
      ],
      "branch": "example",
      "build_inputs": {},
      "commit": {
        "author_email": "example",
        "author_name": "example",
        "hash": "example",
        "message": "example",
        "url": "example"
      },
      "config": {
        "flutter_mode": "example",
        "flutter_version": "example",
        "platforms": [
          "example"
        ],
        "xcode_version": "example"
      },
      "created_at": "example",
      "finished_at": "example",
      "id": "example",
      "index": 1,
      "instance_type": "example",
      "labels": [
        "example"
      ],
      "priority": 1,
      "pull_request": {
        "destination_branch": "example",
        "number": 1,
        "source_branch": "example"
      },
      "remote_access_enabled": true,
      "started_at": "example",
      "status": "example",
      "tag": "example",
      "workflow": {
        "id": "example",
        "name": "example",
        "source": "example"
      }
    }
  }
}
```

### Get current user

Get the Codemagic user the API token belongs to.

**Inputs**: None.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "data": {
      "avatar_url": "example",
      "email": "example",
      "id": "example",
      "name": "example"
    }
  }
}
```

### Get variable group

Get a variable group's name.

**Inputs**

- Variable group ID (`variable_group_id`, text, required): The variable group's ID, as Create variable group or List variable groups gives it.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "data": {
      "id": "example",
      "name": "example"
    }
  }
}
```

### List apps

List the apps you can reach, optionally by name.

**Inputs**

- Name (`name`, text): Only apps whose name contains every word of this.
- Page (`page`, number): Which page of apps to read, starting at 1. At least 1.
- Per page (`page_size`, number): How many apps to return on a page, up to 100. Codemagic's default is 30. From 1 to 100.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "current_page": 1,
    "data": [
      {
        "archived": true,
        "icon_url": "example",
        "id": "example",
        "last_build_id": "example",
        "name": "example"
      }
    ],
    "page_size": 1,
    "total_pages": 1
  }
}
```

### List build steps

List a build's steps, such as fetching, testing and publishing, with how each ended.

**Inputs**

- Build ID (`build_id`, text, required): The build's ID, as Start build or List builds gives it.
- Page (`page`, number): Which page of steps to read, starting at 1. At least 1.
- Per page (`page_size`, number): How many steps to return on a page, up to 100. Codemagic's default is 30. From 1 to 100.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "current_page": 1,
    "data": [
      {
        "finished_at": "example",
        "has_test_results": true,
        "id": "example",
        "name": "example",
        "script": "example",
        "started_at": "example",
        "status": "example",
        "type": "example"
      }
    ],
    "page_size": 1,
    "total_pages": 1
  }
}
```

### List builds

List a team's builds, newest first, by app, workflow, branch, tag, label or status.

**Inputs**

- Team (`team`, text, required): The Codemagic team. Your personal account is listed as a team too.
- App (`app_id`, text): Only builds of this app.
- Workflow (`workflow`, text): Only builds of this workflow.
- Branch (`branch`, text): Only builds of this branch.
- Tag (`tag`, text): Only builds of this tag.
- Labels (`label`, list): Only builds with these labels.
- Status (`status`, text): Only builds with this status. In progress covers every build that hasn't ended. One of: `queued`, `waiting`, `building` (In progress), `finished` (Finished successfully), `failed`, `canceled`, `timeout` (Timed out), `skipped`.
- Cursor (`cursor`, text): The cursor from the last answer, to read the next page.
- Per page (`page_size`, number): How many builds to return, up to 100. Codemagic's default is 30. From 1 to 100.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "cursor": "example",
    "data": [
      {
        "app_id": "example",
        "artifacts": [
          {
            "name": "example",
            "short_lived_download_url": "example",
            "size_in_bytes": 1,
            "type": "example",
            "version_code": "example",
            "version_name": "example"
          }
        ],
        "branch": "example",
        "commit": {
          "author_email": "example",
          "author_name": "example",
          "hash": "example",
          "message": "example",
          "url": "example"
        },
        "created_at": "example",
        "finished_at": "example",
        "id": "example",
        "index": 1,
        "labels": [
          "example"
        ],
        "priority": 1,
        "pull_request": {
          "destination_branch": "example",
          "number": 1,
          "source_branch": "example"
        },
        "started_at": "example",
        "status": "example",
        "tag": "example",
        "workflow": {
          "id": "example",
          "name": "example",
          "source": "example"
        }
      }
    ],
    "page_size": 1
  }
}
```

### List caches

List an app's stored build caches, by workflow, with their size and last use.

**Inputs**

- App (`app_id`, text, required): The Codemagic app.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "caches": [
      {
        "_id": "example",
        "appId": "example",
        "lastUsed": "example",
        "size": 1,
        "workflowId": "example"
      }
    ]
  }
}
```

### List team apps

List a team's apps with their repository and project type.

**Inputs**

- Team (`team`, text, required): The Codemagic team. Your personal account is listed as a team too.
- Name (`name`, text): Only apps whose name contains every word of this.
- Page (`page`, number): Which page of apps to read, starting at 1. At least 1.
- Per page (`page_size`, number): How many apps to return on a page, up to 100. Codemagic's default is 30. From 1 to 100.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "current_page": 1,
    "data": [
      {
        "archived": true,
        "icon_url": "example",
        "id": "example",
        "last_build_id": "example",
        "name": "example",
        "project_type": "example",
        "repository": {
          "url": "example"
        },
        "settings_source": "example"
      }
    ],
    "page_size": 1,
    "total_pages": 1
  }
}
```

### List team members

List a team's members with their team roles and app access.

**Inputs**

- Team (`team`, text, required): The Codemagic team. Your personal account is listed as a team too.
- Roles (`role`, list): Only members with these roles. One or more of: `owner`, `admin`, `member`, `app_developer` (App developer), `app_viewer` (App viewer).
- Page (`page`, number): Which page of members to read, starting at 1. At least 1.
- Per page (`page_size`, number): How many members to return on a page, up to 100. Codemagic's default is 30. From 1 to 100.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "current_page": 1,
    "data": [
      {
        "app_grants": [
          {
            "app_id": "example",
            "role": "example"
          }
        ],
        "avatar_url": "example",
        "created_at": "example",
        "email": "example",
        "id": "example",
        "name": "example",
        "team_roles": [
          "example"
        ]
      }
    ],
    "page_size": 1,
    "total_pages": 1
  }
}
```

### List teams

List your personal account and the teams you belong to.

**Inputs**

- Page (`page`, number): Which page of teams to read, starting at 1. At least 1.
- Per page (`page_size`, number): How many teams to return on a page, up to 100. Codemagic's default is 30. From 1 to 100.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "current_page": 1,
    "data": [
      {
        "created_at": "example",
        "icon_url": "example",
        "id": "example",
        "name": "example",
        "personal": true
      }
    ],
    "page_size": 1,
    "total_pages": 1
  }
}
```

### List variable groups

List an app's groups of environment variables.

**Inputs**

- App (`app_id`, text, required): The Codemagic app.
- Page (`page`, number): Which page of groups to read, starting at 1. At least 1.
- Per page (`page_size`, number): How many groups to return on a page, up to 100. Codemagic's default is 30. From 1 to 100.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "current_page": 1,
    "data": [
      {
        "id": "example",
        "name": "example"
      }
    ],
    "page_size": 1,
    "total_pages": 1
  }
}
```

### List variables

List a variable group's variables. Secure values come back hidden.

**Inputs**

- Variable group ID (`variable_group_id`, text, required): The variable group's ID, as Create variable group or List variable groups gives it.
- Search (`search`, text): Only variables matching this text.
- Page (`page`, number): Which page of variables to read, starting at 1. At least 1.
- Per page (`page_size`, number): How many variables to return on a page, up to 100. Codemagic's default is 30. From 1 to 100.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "current_page": 1,
    "data": [
      {
        "id": "example",
        "name": "example",
        "secure": true,
        "value": "example"
      }
    ],
    "page_size": 1,
    "total_pages": 1
  }
}
```

### List workflows

List an app's workflows, from the Workflow Editor or codemagic.yaml.

**Inputs**

- App (`app_id`, text, required): The Codemagic app.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "data": [
      {
        "id": "example",
        "name": "example",
        "source": "example"
      }
    ]
  }
}
```

### Start build

Queue a build of an app's workflow on a branch or tag, with extra variables, labels or machine.

**Inputs**

- App (`app_id`, text, required): The Codemagic app.
- Workflow (`workflow`, text, required): The workflow to build: its key in codemagic.yaml, or a Workflow Editor workflow.
- Build a (`ref_type`, text): Whether to build a branch or a tag. Leave empty for a branch. One of: `branch`, `tag`. Default: `branch`.
- Branch or tag (`ref`, text, required): The branch or tag to build, such as main or v1.2.0.
- Environment variables (`variables`, object): Environment variables for the build, by name.
- Variable groups (`variable_groups`, list): Variable groups to make available to the build, by name.
- Workflow inputs (`inputs`, object): Values for the workflow's inputs, by input name.
- Labels (`labels`, list): Labels to tag the build with.
- Machine (`instance_type`, text): The build machine. Leave empty for the workflow's own. One of: `mac_mini_m2` (Mac mini M2), `mac_mini_m4` (Mac mini M4), `mac_studio_m4_max` (Mac Studio M4 Max), `linux_x2` (Linux X2), `linux_x4` (Linux X4), `windows_x2` (Windows X2).
- Priority (`priority`, number): From 0 to 10: the team's builds with a higher priority start first. From 0 to 10.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {
    "data": {
      "id": "example"
    }
  }
}
```

### Update variable

Change a variable's name, value or whether it is secure. Only the fields filled in change.

**Inputs**

- Variable group ID (`variable_group_id`, text, required): The variable group's ID, as Create variable group or List variable groups gives it.
- Variable (`variable_id`, text, required): The variable.
- Name (`name`, text): The variable's new name.
- Value (`value`, text): The variable's new value.
- Secure (`secure`, true/false): Store the value encrypted, so nobody can read it back.

**Outputs**

- `data` (object): The response from Codemagic.

**Example output**

```json
{
  "data": {}
}
```
