Deploy a Node.js job to SAE
You can use Apsara DevOps Flow to implement continuous integration and deployment for job templates. This article describes how to use Apsara DevOps to deploy a Node.js job template to SAE as an image.
Prerequisites
An Alibaba Cloud account.
Your application code, including a Dockerfile, is stored in a code repository.
Background information
If this is your first time using Apsara DevOps, familiarize yourself with its deployment process and the deployment methods supported by SAE. For more information, see Overview of deploying SAE applications and job templates in Apsara DevOps 2020.
Step 1: Create a job template in SAE
If this is your first time running a job on SAE, you must create a job template in the SAE console. SAE supports both package-based and image-based deployments. The deployment method for the job template must match the pipeline configuration.
For more information, see Manage job templates.
Step 2: Create an enterprise in Apsara DevOps
Before using Pipeline Flow for the first time, you must create an enterprise in Apsara DevOps.
Log on to Apsara DevOps Flow.
Set an enterprise name, select the R&D organization size, then click Create Now.
Step 3: Create a pipeline in Apsara DevOps
Log on to Apsara DevOps Flow.
In the upper-right corner of the Pipeline Flow page, click New pipeline.
In the Select a pipeline template dialog box, select Empty template · Empty template and click Create.
On the pipeline editing page, click Add pipeline source. In the Add pipeline source panel, select Code source from the navigation pane. In the main pane, configure the code source information and click Add.
Parameter
Description
Select code source
Select the code source where your application code is located.
NoteThe required parameters vary depending on the code source. Configure the parameters as prompted on the page.
Code repository
Select the address of your code repository.
Default branch
Select the code branch.
Step 4: Deploy the job template
In the Stage 1 area, click Empty Task. In the Edit panel, enter a custom Task Name, and select a Build Cluster, Specify Build Node, Build Environment, and Download pipeline source.
Click Add Step, select from the drop-down list, configure the image information, and then click Save Only.
This example uses a Personal Edition instance.
Parameter
Description
Select service connection
Select a service connection to authorize Apsara DevOps to store images in Alibaba Cloud Container Registry (ACR).
NoteIf you have not created a service connection, click Add service connection and complete the Alibaba Cloud RAM authorization as prompted before proceeding.
Region
Select the region where the job template created in Step 1 is located.
Repository
Select the repository where the image will be built and pushed.
Tag
A custom tag name.
Dockerfile path
The path where the Dockerfile is located.
Context path
The build context path for the docker build command. If you leave this parameter empty, it defaults to the Dockerfile path.
Do not use cache
Once selected, docker build will use the
no-cache=trueparameter to build the image.Build arguments
A set of parameters that are passed as
--build-argto the build command when a build is run. You can configure these parameters as needed.In the New stage area, click New Task and select Serverless (SAE) job template update.
In the Edit panel, configure the task information and click Save and Run.
Parameter
Description
Task name
Enter a custom task name, up to 20 characters long.
Build cluster
The build cluster to use for the task.
Download pipeline source
If enabled, source files from the pipeline source are downloaded to the working directory.
Select service connection
Select a service connection to authorize Apsara DevOps to deploy the job template in SAE.
If you have not created a service connection, click Add service connection and complete the Alibaba Cloud RAM authorization as prompted before proceeding.
Region
Select the region of the job template created in Step 1: Create a job template in SAE.
Namespace
Select the namespace of the job template created in Step 1: Create a job template in SAE.
SAE job template
Select the job template created in Step 1: Create a job template in SAE.
Build artifact
Use Alibaba Cloud Container Registry Enterprise Edition
This example uses a Personal Edition instance, so no configuration is required.
Task plug-in
Configure task plug-ins to send notifications as needed.
DingTalk robot notification plug-in: For more information, see Send group messages with a DingTalk robot.
Email notification: Enter email addresses. Separate multiple addresses with semicolons (;).
Webhook notification plug-in: For more information, see Send notifications by using a webhook plug-in.
WeCom group notification: For more information, see Send group messages with a WeCom robot.
Lark group notification: For more information, see Send group messages with a Lark robot.
In the Run Configurations dialog box, confirm the settings and click Run.
Verify the results
After the deployment starts in Apsara DevOps, you are automatically directed to the Recent Runs tab, where you can view the pipeline's execution results. If a run fails, you can troubleshoot the issue by checking the pipeline logs. You can then save the pipeline and run it again to debug.
More information
After the application is deployed in SAE, you can perform the following operations.
Actions | Related documentation |
Manage the application lifecycle, such as updating, scaling, starting, stopping, and deleting applications. | |
Improve application performance through auto scaling, SLB binding, and batch start and stop operations. | |
Monitor application health by managing logs, monitoring metrics, and viewing application events and change records. |