< img height="1" width="1" style="display:none;" alt="" src="https://px.ads.linkedin.com/collect/?pid=3131724&fmt=gif" />

Create Pipelines Using Pipeline Templates

This document illustrates how to create pipelines using pipeline templates on KubeSphere.

DevOps provides a graphic editing panel that facilitates the definition of stages and steps in Jenkins pipelines through interactive operations. It includes various built-in pipeline templates like Node.js, Maven, and Golang, enabling users to swiftly create pipelines based on these templates. While DevOps also offers CI and CI & CD pipeline templates, they might not fully align with custom requirements. It is advisable to use other built-in templates or directly customize pipelines.

  • CI Pipeline Template

    The CI pipeline template comprises two stages. The clone code stage fetches the code, while the build & push stage builds the image and pushes it to Docker Hub. Prior to editing, create credentials for the code repository and Docker Hub repository, and then configure the URLs and credentials in the corresponding steps. Once editing is finalized, the pipeline can be initiated.

  • CI & CD Pipeline Template

    The CI & CD pipeline template consists of six stages. For detailed information on each stage, please refer to Create a Pipeline Using a Jenkinsfile. Prior to editing, create credentials for the code repository and Docker Hub repository, and then configure the URLs and credentials in the corresponding steps. Once editing is finalized, the pipeline can be initiated.

Prerequisites

  • DevOps must have been installed and enabled.

  • A workspace, a DevOps project, and a user (e.g. project-regular) have been created, and the user has been invited to the DevOps project with the operator role. Refer to Role and Member Management.

Steps

The following takes Node.js as an example to show how to use a built-in pipeline template. Steps for using Maven and Golang pipeline templates are analogous.

  1. Log in to the KubeSphere web console as the project-regular user.

  2. Click Workspace Management and navigate to your DevOps project. Click Pipelines and then click Create.

  3. In the pop-up dialog, input the pipeline name, click Next, and then click Create.

  4. Click the created pipeline, proceed to the Pipeline Configurations tab, and select Edit Pipeline.

  5. In the Create Pipeline dialog, select Node.js, and then click Next.

  6. On the Parameter Configuration tab, configure the following parameters according to the actual situation, and then click Create.

    Parameter Description

    GitURL

    The URL of the project repository to be cloned.

    GitRevision

    The branch to be checked out.

    NodeDockerImage

    The Docker image version for Node.js.

    InstallScript

    Shell script to install dependencies.

    TestScript

    Shell script for project testing.

    BuildScript

    Shell script to build the project.

    ArtifactsLocation

    Path where artifact files are located.

  7. By default, a series of steps has been added on the left graphic editing panel. Select Add Step or Add Parallel Stage to make adjustments.

  8. Click on a step, on the right side of the page, you can:

    • Modify the stage name.

    • Delete the stage.

    • Specify the agent type.

    • Add conditions.

    • Edit or remove a specific task.

    • Add steps or add nesting steps.

    Note

    Refer to Create a Pipeline Using Graphic Editing Panels to get how to customize steps and stages in the pipeline template.

  9. In the Agent section on the right, choose the agent type, defaulting to kubernetes, and click OK.

    Agent Type Description

    any

    Uses the default base pod template to create a Jenkins agent for running pipelines.

    node

    Uses a pod template with the specific label to create a Jenkins agent for running pipelines. Available labels include base, java, nodejs, maven, go, and more.

    kubernetes

    Use a standard Kubernetes pod template defined in a yaml file to create a jenkins agent for running pipelines.

  10. Review the details of the created pipeline template, and click Run to run the pipeline.

Receive the latest news, articles and updates from KubeSphere


Thanks for the feedback. If you have a specific question about how to use KubeSphere, ask it on Slack. Open an issue in the GitHub repo if you want to report a problem or suggest an improvement.

What’s on this Page