Deploy an SAE application
You can use a pipeline with a native or image build to create a continuous deployment workflow for your SAE applications.
Background
When deploying an SAE application with a pipeline, your code source can support two build methods.
A native build, such as building a JAR or WAR file for a Java application.
An image build, such as building a container image.
Prerequisites
Before you begin, create and configure an SAE application instance that meets the following requirements:
For a native build, configure your SAE application for package deployment. For more information, see Deploy a Java application.
For an image build, configure your SAE application for image deployment. For more information, see Deploy an application from an image in the SAE console.
Step 1: Create a pipeline
Log on to the Flow console. In the upper-right corner, click New Pipeline.
In the dialog box, select a pipeline template. This tutorial uses the empty template. Click Create.
Step 2: Configure the pipeline code source
Add a code source to your pipeline. You can choose from various sources, such as a self-managed GitLab, Codeup, or GitHub. Click the job node, set Code Source to Sample Code Source, and select JAVA for Code Type.
Alternatively, you can add a pipeline source from an external service, such as an Artifact Source, Jenkins, or another Flow Pipeline.
If you choose the image build method to deploy your SAE application, ensure that your code source contains a Dockerfile.
Step 3: Configure the build and upload tasks
Native build
Add a build job node and select a build method. Click the Empty Job or New Job button. In the Edit pane or navigation menu that appears, select Build > Java Build.
Parameter
Description
Task name
Enter a custom task name.
Build cluster
Select an Alibaba Cloud DevOps default build cluster or a custom private build cluster.
NoteTo learn how to use a private build cluster, see Build Cluster.
Build environment
Select a suitable build environment.
NoteDuring task execution, a build environment is allocated to you, giving you full control to customize the execution scripts.
Download pipeline source
Select a method that meets your needs.
In the Task Steps section, add and configure a Java Build step and an Upload Artifact step.
Configure the Java build parameters.
Configure the Upload Artifact step. You can enter a custom Step Name. For Upload Method, select Organization Private Generic Repository. You must add a service connection to authorize Flow to access your repository resources. Then, select your custom generic repository.
NoteFor more information about the organization private generic repository, see Manage generic artifacts.
Image build
After configuring the code source, add an image build task.
NoteWe recommend the Build and Push Image to Alibaba Cloud Container Registry Enterprise Edition task. The Enterprise Edition supports multiple regions and provides stable and fast image uploads and downloads.
The Build and Push Image to Alibaba Cloud Container Registry Personal Edition task targets individual developers, has more functional limitations, and does not offer a service-level agreement (SLA) for image network acceleration. For details, see What is Container Registry (ACR)?.
Select a build environment and configure how the image is built and pushed to ACR.
Specified container environment/default VM environment
Select the New Task task node, and then select .
Default environment
Select the Empty Task task node. In the Edit panel, add the task step.
In the task editing panel, configure the parameters.
Parameter
Description
Job Name
You can specify a custom job name or use the default name.
Build Cluster
The following build clusters are supported:
Build Environment
The following build environments are supported:
Specify Container Environment (Alibaba Cloud DevOps default build cluster): Flow starts a specified container on the build machine and performs the build in that container. You can select from the provided Flow System Images or specify your own custom image as the runtime environment.
Default VM Environment (supported only for self-hosted build clusters): You must select a build node from the Specify Build Nodes list. Flow installs the required environment and runs the job directly on the build machine. To speed up the build process, we recommend that you install the necessary SDKs and environment dependencies on the machine beforehand.
Default Environment (Alibaba Cloud DevOps default build cluster/self-hosted build cluster): (Deprecated) Flow uses a default container image based on the job type. The image comes pre-installed with the required SDKs and environment, and cannot be changed.
NoteDuring job execution, the build environment is exclusively allocated to you. You have full control over the environment and can customize the execution scripts.
Download Pipeline Source
When enabled, the configured source files are downloaded to the working directory. The following options are available:
Download All Pipeline Sources
Do Not Download Pipeline Sources
Download Selected Pipeline Sources
Configure the parameters for the edition that fits your needs.
Enterprise edition
Parameter
Description
Step name
Customize the step name.
Select service connection
Select a service connection. If one does not exist, click Add Service Connection, set up the Service Authorization/Certificate, and click New to grant Flow access to your ACR resources. Then, click Create.
Region
Select the region where your target Container Registry (ACR) instance is located.
Enterprise instance
Select the target Container Registry (ACR) Enterprise Edition instance.
Namespace
Select the namespace where the target ACR repository is located.
Repository
Select the target ACR repository.
Tag
Set a tag. For example, using the dynamic parameter ${DATETIME} sets the current date and time as the image tag.
NoteTags can be fixed values like 1.0 or dynamic variables like ${DATETIME}.
Dockerfile path
The Dockerfile in the sample code source is in the root directory, so you can keep the default path.
NoteThe Dockerfile path is relative to the root of the code repository, for example,
META/config/DockerfileorDockerfile.ImportantTo push the image to an ACR repository, enable public network access for the target ACR Enterprise Edition instance. Then, add the public egress IP address of the Flow build cluster to the ACR instance's public access allowlist.
To find the public egress IP address of the Flow build cluster, go to the Flow console. In the navigation pane, click Global Settings at the bottom. On the Global Settings page, click Build Cluster Management. On the Build Cluster Management page, find the cluster you are using. This tutorial uses the Alibaba Cloud DevOps Beijing build cluster under Alibaba Cloud DevOps Default Build Cluster. Select the appropriate region and add the displayed public egress IP address to the ACR allowlist.
If you use a private build cluster, Flow pushes the image to the ACR repository using a VPC address. In this case, you do not need to enable public access for the ACR instance. Instead, select the Push Image Using VPC Address checkbox in the task step configuration. For more information about adding a private build cluster, see Build Cluster.
Personal edition
Parameter
Description
Step name
Customize the step name.
Select service connection
Same as the configuration for the Enterprise Edition.
Region
Select the region where your target Container Registry (ACR) instance is located.
Repository
Select the target ACR repository.
Dockerfile path
The Dockerfile in the sample code source is in the root directory, so you can keep the default path.
Step 4: Configure SAE application deployment
Click the New Job node. In the navigation menu of the pane that appears, select from various deployment tasks under Deploy, such as Deploy to ECS or Deploy to Kubernetes. For this topic, add the Deploy to Serverless App Engine (SAE) task to your pipeline.
NoteFor more information about other deployment methods, see Continuous Deployment (CD).
After adding the SAE deployment task, configure its parameters in the Task Steps section as described in the following table.
Parameter
Description
Select service connection
Click Add Service Connection on the right to configure authorization for Flow to access SAE resources.
Region
Select the region where the target SAE application instance is located.
Namespace
Select the custom namespace where the target SAE application instance is located.
SAE application
Select the name of the target SAE application instance.
Build artifact
Select the value that you specified for the Artifact Name parameter in the artifact upload task.
ImportantIf you are using the image build method, ensure that the following configurations are set:
Select the Use Alibaba Cloud ACR Enterprise Edition checkbox. For build artifact, select Build and Push to Alibaba Cloud ACR Enterprise Edition.Image Public URL. If you use a private build cluster, you can select Build and Push to Alibaba Cloud ACR Enterprise Edition.Image VPC URL.
In the Container Registry (ACR) console, navigate to the management page of your target Enterprise Edition instance. Configure access control to add the VPC of your target SAE application instance. This allows the SAE instance to communicate with ACR.
ACR Enterprise Edition instance ID
This parameter is required when you select Use Alibaba Cloud ACR Enterprise Edition.
NoteYou can find the instance ID on the instance overview page in the Container Registry console.
Release policy
Select a release policy. A phased release deploys to a set number of instances at a time. A canary release gradually directs a percentage of traffic to the new version.
Batch mode
Select a suitable execution method for the application deployment.
Number of batches
Specify the number of instances for the deployment based on the total number of instances configured for the SAE application.
NoteIf your SAE application is configured with two instances and you set the number of batches to 2, the application will be deployed to the two instances in two separate batches.
Wait time between batches
Specify the wait time between the deployment of each batch of SAE application instances.
Wait time within a batch
The wait time before the deployment starts on a target instance within a batch.
Step 5: Run the pipeline and view status
In the Flow console, go to My Pipelines, find your pipeline, and click Run
. After the run starts, click the pipeline name to view its job nodes.After the pipeline run is complete, click Logs in the lower-right corner of the SAE deployment job node to view the execution logs.
In the SAE console, you can view the deployment history and instance logs for the application.