In software development, the constant evolution of DevOps practices has made continuous integration and continuous deployment (CI/CD) processes an integral part of project development lifecycles. One of the tools enabling this seamless transformation is CTO.ai, a robust DevOps and Insights platform that provides an intuitive approach to automating your development workflow.

This blog post will guide you on configuring workflow events in CTO.ai with the NodeJS SDK.

What is CTO.ai?

CTO.ai is an automation, and insights platform to simplify and streamline development and deployment workflows. With the ability to define and automate tasks, CTO.ai supports teams in maintaining efficient and error-free development pipelines, fostering a more productive and collaborative Developer experience culture.

Configuring Workflow Events on CTO.ai

Workflow events on CTO.ai refer to the specific event actions or status updates in your CI/CD pipeline. By effectively configuring these events, you'll maintain visibility of your workflow processes and have valuable insights into where improvements can be made. In this tutorial, we will use the NodeJS SDK.

Creating a New Workflow

Before you begin, install Node.js and npm (Node package manager) on your system. You'll also need to install the CTO.ai SDK as a dependency in your project. npm install @cto.ai/sdk also install the CTO.ai CLI using the npm install -g @cto.ai/ops command.

Initialize and Configure Workflow Event

Next, initialize your CTO.ai command to configure your workflow events. In your terminal, initialize your command using the ops init command, and select Command.

  • Select the template you want to use in this tutorial; we will use the JavaScript template.
  • Enter the name and description of your template workflow.
  • Next, enter the version number for your workflow.
  • In your index.js file, you will see your Node.js application that uses the CTO.ai SDK, a framework that provides utilities for developing and integrating your applications on NodeJS. In the sdk.track code block, the functions are used to track an event. In this section, we will specify the workflow events for our application. The supported workflow events action in CTO.ai are succeeded and failed
const event = {
  event_name: 'deployment',
  event_action: 'succeeded',
  branch: 'main',
  repo: prompt_res.repo,
};
sdk.track([], event);
  • To run your workflow events, you must build and publish your workflow with the ops run -b workflow-events command. Replace workflow-events with the name of the workflow name you created earlier.
  • When your application is successfully built, enter the application name you want to deploy.
  • Next, you will see your application events built and deployed successfully.
  • Publish your workflow using the ops publish . command.
  • In your CTO.ai insights dashboard, you can see your workflow events deployment status.
  • The insights event activity shows the TIMESTAMP, EVENT, ACTION, CATEGORY, SOURCE, and REPOSITORY.
  • You can build the failed event action, and you will also see the changes in your insights dashboard.  
const event = {
  event_name: 'deployment',
  event_action: 'failed',
  branch: 'main',
  repo: prompt_res.repo,
};
sdk.track([], event);

The deployment status will be updated in your dashboard so that you can see the failed action status. The drop-down menu in your Event Activity also gives you a detailed example of the JSON payload.


Streamlining Your CI/CD Pipeline with CTO.ai

Configuring workflow events on CTO.ai using the Node.js SDK is a game-changer for managing your CI/CD pipeline. It not only simplifies the process of tracking key events in your workflow but also fosters a proactive approach to troubleshooting, as it provides real-time updates about the status of your workflows.

Get Started Now: Ready to enhance your CI/CD and insights experience? Start by leveraging the power of CTO.ai and the Node.js SDK. With these tools, you'll be well-equipped to create, manage, and optimize your workflows with ease. Remember, it's all about working smarter, not harder. Explore what CTO.ai can do for your team today.