Updated on 2025-03-13 GMT+08:00

Step 5: Set Up a Function Update Pipeline

The pipeline allows you to release and update the helloworld function code in the functions repository to FunctionGraph.

Creating a Build Task

  1. Choose Build & CloudArtifact > CloudBuild, and click Create Task.
  2. Select functions for Source Code Repository and Blank Template for the template.
  3. Add these three actions: Run Shell Commands, Upload Files to OBS, and Upload Deployment Package to CloudRelease.
    1. Configure the Run Shell Commands action.
      # Build a function deployment package.
      cd helloworld
      zip helloworld_deploy.zip cam.yaml
      # Build a function code package.
      cd code
      zip -rp helloworld.zip *
      Figure 1 Run Shell Commands
    1. Configure the Upload Files to OBS action.
      Figure 2 Upload Files to OBS
      • Action Name: Enter Upload Function Package to OBS.
      • Build Directory: Enter helloworld/code/helloworld.zip.
      • Bucket Name: Specify a private bucket to store the function code ZIP package.
      • OBS Directory: Enter function.
    2. Configure the Upload Deployment Package to CloudRelease action.
      Figure 3 Upload Deployment Package to CloudRelease
      • Action Name: Enter Upload Deployment Package to CloudRelease.
      • Package Location: Enter helloworld/helloworld_deploy.zip.
      • Version: Enter ${releaseVersion}.
  4. On the Parameters tab page, add releaseVersion and enable Runtime Settings.
    Figure 4 Setting parameters
  5. On the Basic Information tab page, change the task name to pipeline-update-function-deploy and click Save.

Creating a Deployment Task

  1. Choose Build & CloudArtifact > CloudDeploy, and click Create Task.
  2. Select Blank Template and click Next.
  3. Add the actions Select Deployment Source and Run Shell Commands.
    Figure 5 Adding deployment actions
    1. Configure the Select Deployment Source action.
      Figure 6 Setting action name to "Download Function Deployment Package to Deployment Host"
      • Action Name: Enter Download Function Deployment Package to Deployment Host.
      • Host Group: Select deploy-function.
      • Software package: Select /functions-helloworld-build/${releaseVersion}/helloworld_deploy.zip.
      • Download Path: Enter /home/function/deploy.
    2. Configure the Run Shell Commands action.
      Figure 7 Setting action name to "Deploy Function"
      • Action Name: Enter Deploy Function.
      • Host Group: Select deploy-function.
      • Shell Commands:
        cd /home/function/deploy
        unzip -o helloworld_deploy.zip -d helloworld_deploy
        python3 deploy.py helloworld_deploy "${key}"
  4. Add two parameters.
    • releaseVersion: Use the default value 1.0.0 and enable Runtime Settings.
    • key: Enter a key and enable Private Parameter.
      Figure 8 Setting parameters
  5. On the Basic Information tab page, change the task name to update-function-deploy and click Save.

Configuring a Pipeline

  1. Choose Build & CloudArtifact > CloudPipeline, and click Create Pipeline.
  2. Select functions for Source Code Repository and Blank Template for the template.
  3. Configure Build and Check.
    1. Add a build task, and select the functions-helloworld-build task.
      Figure 9 Adding a task
    2. Set releaseVersion as a pipeline parameter.
      Figure 10 Setting releaseVersion
    3. Click Save.
  4. Configure a deployment task.
    1. Add a stage named Deploy after Build_and_Check, set Task Execution to Serial, and click Save.
      Figure 11 Configuring the stage
    2. Click Add Task to add a deployment task named DeployhelloworldScript, and select the update-function-deploy task.
      Figure 12 Clicking Add Task
      Figure 13 Adding a task
    3. Set releaseVersion as a pipeline parameter.
      Figure 14 Setting releaseVersion
    4. Click Save.
  5. On the Basic Information tab page, change the pipeline task name to pipeline-update-function-helloworld and click Save.
  6. Execute the pipeline.

    Set the runtime parameter releaseVersion to 1.0.0 and click Execute.