跳到主要内容

Pipeline

GitCode Pipeline is a continuous integration and continuous delivery (CI/CD) platform designed to help developers automate the build, test, and deployment processes. You can create workflows to manage automation from code submission to production deployment.

This document will introduce you to the core components of GitCode Pipeline, the creation process, and how to view pipeline execution results, helping you get started quickly and make full use of this tool.

Core Components


Workflow

A workflow is a configurable automated process used to execute one or more jobs. It is defined by a YAML file in the project, usually located in the .gitcode/workflows directory. A workflow can be triggered by specific events, such as code pushes, pull requests, or issue creation, or it can be manually triggered or scheduled.

A project can contain multiple workflows, each performing different tasks. For example, you can have one workflow for building and testing pull requests, another workflow for deploying the application every time a release is created, and another workflow that adds tags whenever someone opens a new issue.

Events

Events are specific activities that trigger the execution of a workflow. Common events include:

  • Code push: Triggers when code is pushed to a specific branch.
  • Pull request: Triggers when a pull request is created or updated.
  • Issue creation: Triggers when a new issue is created.
  • Manual trigger: Starts the workflow manually through the GitCode interface or API.
  • Scheduled trigger: Automatically executes the workflow according to a predefined schedule.

Job

A job is an execution unit within a workflow, containing a set of steps executed in sequence. Each job runs on a separate runner (Runner), and steps can be shell scripts or custom actions (Action). You can share data between steps. Dependencies can be set between jobs to ensure certain jobs run only after other jobs complete.

For example, you can configure the following jobs:

  • Build job: Compiles the code and generates executable files.
  • Test job: Runs unit tests and integration tests.
  • Package job: Packages the build result into deployable images or files.

Action

An action is a reusable extension on the GitCode platform used to perform complex but common tasks. By using actions, you can reduce repetitive code in workflow files and simplify process configuration. GitCode provides various built-in actions, such as:

  • checkout-action: Pulls code from GitCode.
  • setup-node: Configures the Node.js environment.
  • setup-java: Configures the Java environment.
  • setup-python: Configures the Python environment.
  • setup-go: Configures the Go environment.

You can write your own actions or find suitable actions in the GitCode plugin market.

Runner

A runner is a server that executes the pipeline. When a pipeline is triggered, GitCode assigns a brand new virtual machine runner for each job, and each runner can run one job at a time. GitCode provides the Euler runner by default, ensuring that each job runs in an independent and clean environment.

Creating a Pipeline


Create via YML

In your GitCode project, create a .gitcode/workflows directory to store workflow files. In this directory, create a new YAML file, such as gitcode-sample.yml, and add the following content:

name: gitcode-sample
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: euleros-2.10.1
steps:
- uses: checkout-action@0.0.1
- name: Use Node.js
uses: setup-node@0.0.1
with:
node-version: '20.10.0'
- run: cd repo_workspace && npm ci
- run: cd repo_workspace && npm run build --if-present
- run: cd repo_workspace && npm test

Commit and push these changes to your GitCode project.

Create via Interface

  1. On the "Pipeline" tab of your project, click the "New Pipeline" button.

    img

  2. Choose a template. GitCode provides various predefined workflow templates, and you can choose the appropriate one based on your project requirements.

    img

Execute the Pipeline


After configuration, click the "Run" button to start the pipeline. GitCode will automatically execute tasks such as building and testing according to the definitions in the workflow file.

img

View Results


After the pipeline execution is completed, you can view detailed execution results in the GitCode interface, including the output and status of each step.

img

Each pipeline execution is recorded, and users can view detailed execution records on the GitCode pipeline page. These records include the trigger time of the pipeline, the execution status (success, failure, or in progress), the log output of each step, and the execution duration, among other information.

image