All Products
Search
Document Center

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

Last Updated:Dec 21, 2023

Each time a pipeline task is run, 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. The following sample code shows an 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 table lists the runtimes supported by the runtime-setup plug-in.

  • Node.js 12

  • Node.js 14

  • Node.js 16

  • Node.js 18

  • Node.js 20

  • Java 8

  • Java 11

  • Java 17

  • Python 2.7

  • Python 3.6

  • Python 3.7

  • Python 3.9

  • Python 3.10

  • Go 1.18

  • Go 1.19

  • Go 1.20

  • Go 1.21

Node.js 14, Java 8, Python 3.9, and Go 1.18 are the runtimes of the default versions.