Updated on 2024-08-05 GMT+08:00

Creating a Source Code Job

The software package or image package can be generated with a few clicks in a build job. In this way, the entire process of source code pull, compilation, packaging, and archiving is automatically implemented.

  • Images built in the x86-system jobs are ones of the x86 system.
  • Images built in the Arm-system jobs are ones of the Arm system.

Prerequisites

  1. A cluster has been created. For details, see Creating a CCE Cluster.
    • The build job depends on the JDK, Golang, Maven, Gradle, Ant, or Node.js compilation tool preconfigured in the build container.
    • Different IAM users under the same account can perform operations on the same cluster. To cancel the build permission from a specific IAM user, set the servicestage:assembling:create, servicestage:assembling:modify, and servicestage:assembling:delete permissions to Deny by referring to Creating a Custom Policy.
  2. An EIP has been bound to the build node. For details, see Assigning an EIP and Binding It to an ECS.

Procedure

  1. Log in to ServiceStage, choose Continuous Delivery > Build, and click Create Source Code Job.
  2. Configure basic information.

    1. Enter Name.
    2. Enter Enterprise Project.

      Enterprise projects let you manage cloud resources and users by project.

      It is available after you create an enterprise project.

    3. (Optional) Enter Description.
    4. Set Code Source.
      • Create authorization by referring to Authorizing a Repository and set the code source.
      • Click Samples and select a required sample.
    5. Select a cluster from the Cluster drop-down list.
    6. (Optional) Specify Node Label to deliver the build job to a fixed node based on the node label. For details about how to add a label, see Adding a Node Label.
    7. Click Next.

  3. Select a build template.

    • If you select Maven, Ant, Gradle, Go, or Docker, you can compile and archive binary packages or Docker images at the same time. Go to 4.
    • If you select Custom, you can customize the build mode. Go to 6.

  4. Select an archive mode.

    • Not archived: No Docker build job is added or archived.
    • Archive binary package: No Docker build job is added and binary packages are archived.
    • Archive image compilation: Docker build job is added and Docker images are archived.

  5. Set mandatory parameters.

    To delete a parameter setting, click on the parameter setting page.
    • Build parameters

      Compilation parameters are set with different values. For details about parameter description, click a text box or next to it.

    • Image parameters

      On the page, enter Job Name, Dockerfile Path, Image Name, and Image Tag.

    • Image archiving parameters

      On the page, enter Job Name, Archive Image, Repository Organization, and Type of the corresponding image to archive the image.

    • Binary parameters

      On the page, set the following parameters.

      Parameter

      Description

      Task Name

      Job name.

      Sharing Type

      Repositories are classified into public repositories and private repositories.

      • Public repositories are isolated from each other. Tenants in the same system can resources.
      • Private repositories are isolated by tenants. Users under the current tenant share resources. Other tenants cannot access resources of the current tenant.

      Repository Organization

      Namespace of a repository.

      Software Repository

      Name of a software repository.

      Name

      Name of the archived software package after the build completes.

      Software Package Version

      Version of the archived software package.

      Build Package Path

      Address of the binary software package generated after the compilation and build are complete. For example, ./target/xxx.jar in the Java project.

  6. (Optional) Click Advanced Configuration to set the environment.

    To add multiple tasks, you can customize them in Advanced Configuration.
    1. Click Add Plug-in in the corresponding stage on the left. The Select Job Type page is displayed.
    2. Click Select of the target task type to add a task type. Then, configure task parameters in the right pane of the Environment Configurations page.

      When the Build Common Cmd plug-in is added to the compilation process, pay attention to the following:

      • Exercise caution when inputting sensitive information in the echo, cat, or debug command, or encrypt sensitive information to avoid information leakage.
      • When Language is set to Python and Python Framework Type is set to a Python project that complies with the WSGI standard, you need to set Main Python Module and Function of the Main Python Module. The following is an example of the main Python module and main function:

        Main Python Module: If the entry point file of the Python project is server.py, the main module name is server.

        Function of the Main Python Module: If the application function name of the Python project entry point file server.py is app=get_wsgi_application(), the function name of the main module is app.

  7. Click Build to save the settings and start the build.

    Click Save to save the settings (not to start the build).

Follow-Up Operations

After an application component is successfully built, you can manage it on ServiceStage. For details, see Deploying a Component.