All Products
Search
Document Center

Function Compute:Use the runtime-setup plug-in to initialize a runtime

Last Updated:Aug 05, 2024

Each time a pipeline task runs, a new instance is allocated based on the base image. Serverless Application Center continuously maintains and updates images, and adds or updates the required build tools. When multiple versions of a build tool exist, Serverless Devs uses the latest version by default. However, some users may want to use an earlier version. Serverless Application Center provides the runtime-setup plug-in to specify the version of a build tool. This topic describes how to use a runtime-setup plug-in to initialize a runtime.

Use the runtime-setup plug-in

If you want to use a specific version of the build tool, you can use the runtime-setup plug-in to specify the version of the build tool before you use Serverless Devs.

Using the runtime-setup plugins in steps

In a pipeline template or a task template, you can use the runtime-setup plug-in by running steps in context. After the plug-in is executed, the build tool of the specified version is configured to the PATH environment variable in the container. Example:

---
kind: PipelineTemplate
name: mytemplate-<% .git.branch %>
description: cached pipelinetemplate
spec:
  context:
    data:
      envName: test
      deployFile: s.yaml
  tasks:
  # Build and deploy
  - name: build-and-deploy
    context:
      data:
        enable: true
        steps:
          # Pull code.
          - plugin: "@serverless-cd/checkout"
          # Initialize Serverless Devs.
          - plugin: "@serverless-cd/s-setup"
          # Specify the version of the build tool.
          - plugin: "@serverless-cd/runtime-setup"
            inputs:
              runtime:
              - nodejs14
              # - nodejs16
            	# - python3.9
              # - python
          # Use other plug-ins or scripts to perform actions.
          # - run: make build && make deploy
          # - plugin: "@serverless-cd/others" 
    taskTemplate: serverless-runner-task
---

The following items list the runtimes supported by the runtime-setup plug-in:

  • nodejs12

  • nodejs14

  • nodejs16

  • nodejs18

  • nodejs20

  • java8

  • java11

  • java17

  • python2.7

  • python3.6

  • python3.7

  • python3.9

  • python3.10

  • go1.18

  • go1.19

  • go1.20

  • go1.21

Among them, nodejs14, java8, python3.9, and go1.18 are the default versions of each programming language.