• Home
  • Insight
  • Blog
  • Business
  • Entertainment
  • Health
  • Politics
  • Shop
    • Gift Shop
    • Value Shop
    • Store
    • Bargain Shop
    • Discount
  • Sports
  • Tech
  • Travel
  • USA
  • Video
  • World
    • Asia
    • Africa
    • South America
    • North America
    • Europe
    • Oceania
Thursday, August 20, 2026
No Result
View All Result
Subscribe Now
  • Home
  • Insight
  • Blog
  • Business
  • Entertainment
  • Health
  • Politics
  • Shop
    • Gift Shop
    • Value Shop
    • Store
    • Bargain Shop
    • Discount
  • Sports
  • Tech
  • Travel
  • USA
    NTSB releases new videos, images from deadly Philadelphia medical jet crash

    NTSB releases new videos, images from deadly Philadelphia medical jet crash

    Iran Calls Trump ‘Delusional’ After He Claims Hormuz a ‘New U.S. Territory’

    Iran Calls Trump ‘Delusional’ After He Claims Hormuz a ‘New U.S. Territory’

    IPOs for Open AI, Anthropic could unlock 0B for charity

    IPOs for Open AI, Anthropic could unlock $430B for charity

    Poll showing Bass leading Raman by double digits was bogus, company says

    Poll showing Bass leading Raman by double digits was bogus, company says

    Multiple people dead as flooding continues in Indiana : NPR

    Multiple people dead as flooding continues in Indiana : NPR

    Sophie Cunningham defends stance on biological men in women’s sports

    Sophie Cunningham defends stance on biological men in women’s sports

    Democrats Make South Carolina the First Contest in 2028 Presidential Primary Calendar

    Democrats Make South Carolina the First Contest in 2028 Presidential Primary Calendar

    Has the Left Really Met Its Limit? 

    Has the Left Really Met Its Limit? 

    U.S. Attorney confirms no meth was found in van of Texas man shot by immigration officers

    U.S. Attorney confirms no meth was found in van of Texas man shot by immigration officers

  • Video
  • World
    • Asia
    • Africa
    • South America
    • North America
    • Europe
    • Oceania
The Insight Post
  • Home
  • Insight
  • Blog
  • Business
  • Entertainment
  • Health
  • Politics
  • Shop
    • Gift Shop
    • Value Shop
    • Store
    • Bargain Shop
    • Discount
  • Sports
  • Tech
  • Travel
  • USA
    NTSB releases new videos, images from deadly Philadelphia medical jet crash

    NTSB releases new videos, images from deadly Philadelphia medical jet crash

    Iran Calls Trump ‘Delusional’ After He Claims Hormuz a ‘New U.S. Territory’

    Iran Calls Trump ‘Delusional’ After He Claims Hormuz a ‘New U.S. Territory’

    IPOs for Open AI, Anthropic could unlock 0B for charity

    IPOs for Open AI, Anthropic could unlock $430B for charity

    Poll showing Bass leading Raman by double digits was bogus, company says

    Poll showing Bass leading Raman by double digits was bogus, company says

    Multiple people dead as flooding continues in Indiana : NPR

    Multiple people dead as flooding continues in Indiana : NPR

    Sophie Cunningham defends stance on biological men in women’s sports

    Sophie Cunningham defends stance on biological men in women’s sports

    Democrats Make South Carolina the First Contest in 2028 Presidential Primary Calendar

    Democrats Make South Carolina the First Contest in 2028 Presidential Primary Calendar

    Has the Left Really Met Its Limit? 

    Has the Left Really Met Its Limit? 

    U.S. Attorney confirms no meth was found in van of Texas man shot by immigration officers

    U.S. Attorney confirms no meth was found in van of Texas man shot by immigration officers

  • Video
  • World
    • Asia
    • Africa
    • South America
    • North America
    • Europe
    • Oceania
No Result
View All Result
No Result
View All Result
Home Mobile

How to take advantage of Dynamic Workflows using Codemagic API

by Theinsightpost
August 13, 2022
in Mobile
0 0
0
How to take advantage of Dynamic Workflows using Codemagic API


Written by Souvik Biswas

You can now configure your builds using environment variables and software versions dynamically with Codemagic API. If you have multiple similar workflows for the same project, you can now combine them into one and create parametrized API calls. This way, you can run your workflows without having to change the settings in the UI or codemagic.yaml. This can be quite a useful feature for white-label apps.

In this article, I will show you how to make calls to Codemagic REST API for starting a build, getting updated status information and canceling a build.

First of all, let’s go through the features of the API.

Overview

The Codemagic API endpoints are under the domain api.codemagic.io.

All data is sent and received in the JSON format.

Authentication

While making any calls to the Codemagic REST API, an access token must be included as an HTTP header for the call to be successful.

You can get the access token from the Codemagic UI by going to User Settings -> Integrations -> Codemagic API -> Show.

Retrieving applications

You can get information about all the applications present on Codemagic by sending a GET request to the following endpoint:

GET /apps

Some of the important parameters that you can retrieve from the response are App IDs, Workflow IDs, Branches, etc.

An example of the curl request for retrieving applications is as follows:

curl -H "Content-Type: application/json" -H "x-auth-token: <API Token>" --request GET https://api.codemagic.io/apps

Replace the angle brackets with appropriate values.

Start a new build

For starting a new build using the Codemagic API, you have to send a POST request to the following endpoint:

POST /builds

The required parameters are: appId, workflowId and branch. There is also an optional parameter environment for passing environment variables and software versions.

You can pass the version of Flutter/Xcode/CocoaPods used for the build. Any environment variables can also be passed as a key-value pair.

If you have multiple workflows that have small differences, like software versions or separate git branches, you can merge them and use Codemagic API to dynamically change their values.

The variables passed via API have higher priority and will override the values defined in the UI.

For more information refer to the Official Docs.

An example of curl request for starting a new build is as follows:

curl -H "Content-Type: application/json" -H "x-auth-token: <API Token>" --data '{"appId": "<app_id>","workflowId": "<workflow_id>","branch": "<git_branch_name>"}' https://api.codemagic.io/builds

Replace the angle brackets with their appropriate values.

Get build status

While a build is running on Codemagic CI/CD, you can check its status using the Codemagic API by sending a GET request to the following endpoint:

GET /builds/:id

Here, replace the :id with the build id returned as a response of the POST request.

An example of curl request for getting the build status is as follows:

curl -H "Content-Type: application/json" -H "x-auth-token: <API Token>" --request GET https://api.codemagic.io/builds/<build_id>

Replace the angle brackets with their appropriate values.

Cancel a build

If you want to cancel a build that is currently running on Codemagic CI/CD, you can send a POST request to the following endpoint:

POST /builds/:id/cancel

Replace the :id with the build id returned as a response of the POST request while starting the build.

An example of curl request for cancelling a build is as follows:

curl -H "Content-Type: application/json" -H "x-auth-token: <API Token>" --request POST https://api.codemagic.io/builds/<build_id>/cancel

Replace the angle brackets with their appropriate values.

Use cases

You can use Codemagic REST API for better integration with other tools so that you can take advantage of the Dynamic Workflows.

As a fun project, let’s create a Flutter app using Codemagic API.

The app will be pretty simple, having features to:

  • Start a build with supplied software versions
  • Get build status while it is running
  • Cancel the build running on Codemagic CI/CD

Let’s get started building the app.

App screenshots

The final app design will be like this:

Getting started

Create a new Flutter project with the command:

flutter create codemagic_api

The only plugin required for this project is:

  • Dio (A powerful HTTP client for Dart)

Open the project in your favorite IDE and import the dio package using pubspec.yaml.

Initializing Dio

You can initialize Dio with some base options like URL, Headers, etc. Here, I have defined a connectTimeout & receiveTimeout in milliseconds.

I have stored the API token in a Map and accessing it form there.

BaseOptions options = new BaseOptions(
    baseUrl: 'https://api.codemagic.io',
    connectTimeout: 5000,
    receiveTimeout: 3000,
    headers: {
      "Content-Type": "application/json",
      "x-auth-token": _map['token'],
    });

_dio = new Dio(options);

Start a build

As I have described earlier, to start a build you have to send a POST request to the API endpoint /builds.

For this you can use the Dio post() method with the endpoint and proper parameters.

Response response = await _dio.post(
  "/builds",
  data: {
    "appId": _map['appId'],
    "workflowId": _map['workflowId'],
    "branch": _map['branch'],
  },
);

NOTE: Here, I have stored the values in a map and I am accessing them from there.

From the response received from the POST request, you can retrieve the build ID which we will require later for getting the build status and cancelling the build.

// Checking if the request was successful
if (response.statusCode == 200) {

  setState(() {
    _isBuilding = true;
  });

  // Retrieve the build id from response
  Map buildMap = response.data['build'];
  String id = buildMap['_id'].toString();

  setState(() {
    _buildId = id;
  });

  print('BUILD ID: $_buildId');
}

Build status

To get the build status, you have to send a GET request to the API endpoint /builds/:id.

You have to use the Dio get() method with the proper endpoint.

Response response = await _dio.get(
  "/builds/$_buildId",
);
// Checking if the request was successful
if (response.statusCode == 200) {

  // Retrieve build status from response
  Map buildMap = response.data['build'];
  String status = buildMap['status'].toString();

  setState(() {
    _status = status;
  });

  print('BUILD STATUS: $status');
}

Now, you can define a stream, which will run it indefinitely and get the updated build status until the build finishes or canceled.

Stream<int> _stream() {
  Duration interval = Duration(seconds: 1);

  // It will call the method to get response
  // after every 1 second
  Stream<int> stream = Stream<int>.periodic(interval, response);

  // Checking it the build is finished
  // or canceled
  if (_status == 'finished') {
    setState(() {
      _isFinished = true;
      _isBuilding = false;
    });
  } else if (_status == 'canceled') {
    setState(() {
      _isBuilding = false;
      _isFinished = false;
    });
  }

  return stream;
}

int response(int value) {
  // The method containing the dio get call
  _getResponse();
  return value;
}

Cancel a build

If you want to cancel a build, you have to perform a Dio post() method call using the endpoint /builds/:id/cancel.

Response response = await _dio.post(
  "/builds/$_buildId/cancel",
);
// Checking if the request was successful
if (response.statusCode == 200) {
  setState(() {
    _isBuilding = false;
  });
}

Building the UI

The UI of the app will be quite simple, containing mainly a TextFormField for taking user inputs and a Button for starting/canceling a build.

The TextFormField design will be as follows:

Code for each TextFormField is as follows:

TextFormField(
  initialValue: initialValue,
  cursorColor: Colors.black,
  obscureText: obscure,
  onChanged: (value) {
    // To store the updated values as they are
    // entered in the field
    setState(() {
      _map[entryList[index].key] = value;
    });
  },
  decoration: new InputDecoration(
    enabledBorder: OutlineInputBorder(
      borderRadius: BorderRadius.all(Radius.circular(20.0)),
      borderSide: BorderSide(color: Colors.grey, width: 1),
    ),
    focusedBorder: OutlineInputBorder(
      borderRadius: BorderRadius.all(Radius.circular(20.0)),
      borderSide: BorderSide(color: Colors.blue, width: 2),
    ),
    contentPadding:
        EdgeInsets.only(left: 15, bottom: 11, top: 11, right: 15),
    hintText: hint,
  ),
)

If there is no build currently running, a RaisedButton will be displayed. This button can be used for starting a new build.

RaisedButton(
  onPressed: () {
    setState(() {
      _status = 'Initializing';
    });
    // Checking whether all the required
    // parameters are passed
    if (_map['token'] != null &&
        _map['appId'] != null &&
        _map['workflowId'] != null)
      _postData();
    else {
      print('Required parameters are not supplied');
    }
  },
  color: Colors.blue,
  child: Padding(
    padding: const EdgeInsets.only(
        left: 5.0, right: 5.0, top: 10.0, bottom: 10.0),
    child: Text(
      'START BUILD',
      style: TextStyle(color: Colors.white, fontSize: 20.0),
    ),
  ),
  shape: RoundedRectangleBorder(
    borderRadius: BorderRadius.circular(30.0),
  ),
);

When there is a build running, the build status along with a CANCEL button will be displayed. The UI design will be as follows:

The whole app code is available on GitHub.

Conclusion

I hope this article will help you get started with the Codemagic REST API and take advantage of the Dynamic Workflows for building your apps.

Codemagic API Docs: https://docs.codemagic.io/rest-api/overview


Souvik Biswas is a passionate Mobile App Developer (Android and Flutter). He has worked on a number of mobile apps throughout his journey. Loves open source contribution on GitHub. He is currently pursuing a B.Tech degree in Computer Science and Engineering from Indian Institute of Information Technology Kalyani. He also writes Flutter articles on Medium – Flutter Community.



Source link

ShareTweetSend
Previous Post

‘Honor, Remember, Teach’: Special mobile museum honoring America’s veterans visits Bend

Next Post

World Elephant Day: Rising human populations hindering elephants’ role as ‘ecosystem caretakers’

Related News

Intersignal Releases Braid Pathfinder Developer Preview
Mobile

Intersignal Releases Braid Pathfinder Developer Preview

August 19, 2026
Best Zimperium Alternatives for Mobile App Security in 2026
Mobile

Best Zimperium Alternatives for Mobile App Security in 2026

August 18, 2026
Best 20+ AI Development Companies in 2026
Mobile

Best 20+ AI Development Companies in 2026

August 18, 2026
How AI Is Redefining Supply Chain Resilience in 2026
Mobile

How AI Is Redefining Supply Chain Resilience in 2026

August 17, 2026
Next Post
World Elephant Day: Rising human populations hindering elephants’ role as ‘ecosystem caretakers’

World Elephant Day: Rising human populations hindering elephants' role as 'ecosystem caretakers'

Discussion about this post

Subscribe To Our Newsletters

    Customer Support


    1251 Wilcrest Drive
    Houston, Texas
    77042 USA
    Call-832.795.1420
    e-mail – news@theinsightpost.com

    Subscribe To Our Newsletters

      Categories

      • Africa
      • Africa-East
      • African Sports
      • American Sports
      • Arts
      • Asia
      • Australia
      • Business
      • Business Asia
      • Business- Africa
      • Canada
      • Defense
      • Education
      • Egypt
      • Energy
      • Entertainment
      • Europe
      • European Soccer
      • Finance
      • Germany
      • Ghana
      • Health
      • Insight
      • International
      • Investing
      • Japan
      • Latest Headlines
      • Life & Living
      • Markets
      • Mobile
      • Movies
      • New Zealand
      • Nigeria
      • Politics
      • Scholarships
      • Science
      • South Africa
      • South America
      • Sports
      • Tech
      • Travel
      • UK
      • USA
      • Weather
      • World
      No Result
      View All Result

      Recent News

      One year on, Raiders and Broncos still reckon with the legacy of their greatest game

      One year on, Raiders and Broncos still reckon with the legacy of their greatest game

      August 19, 2026
      The Language Barrier Is the Real Barrier in Edtech

      The Language Barrier Is the Real Barrier in Edtech

      August 19, 2026
      Netflix and Chills | Short Horror Film

      Netflix and Chills | Short Horror Film

      August 19, 2026
      One Month After MV Barima Sank, Search Operations Have Ended, No Salvage Contractor Named, And Questions Remain

      One Month After MV Barima Sank, Search Operations Have Ended, No Salvage Contractor Named, And Questions Remain

      August 19, 2026
      • Home
      • Advertise With Us
      • About Us
      • Corporate
      • Consumer Rewards
      • Forum
      • Privacy Policy
      • Social Trends

      Theinsightpost ©2026 | All Rights Reserved. Theinsightpost is an Elnegy LLC company, registered in Texas, USA

      Welcome Back!

      Login to your account below

      Forgotten Password?

      Retrieve your password

      Please enter your username or email address to reset your password.

      Log In

      Add New Playlist

      We are using cookies to give you the best experience on our website.

      You can find out more about which cookies we are using or switch them off in .

      No Result
      View All Result
      • Home
      • Insight
      • Blog
      • Business
      • Entertainment
      • Health
      • Politics
      • Shop
        • Gift Shop
        • Value Shop
        • Store
        • Bargain Shop
        • Discount
      • Sports
      • Tech
      • Travel
      • USA
      • Video
      • World
        • Asia
        • Africa
        • South America
        • North America
        • Europe
        • Oceania

      Theinsightpost ©2026 | All Rights Reserved. Theinsightpost is an Elnegy LLC company, registered in Texas, USA

      The Insight Post
      Powered by  GDPR Cookie Compliance
      Privacy Overview

      This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

      Strictly Necessary Cookies

      Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

      Cookie Policy

      More information about our Cookie Policy