Deploy private code to Application Management
Application Management integrates the pipeline publishing feature of Apsara DevOps. You can configure a continuous integration and continuous deployment (CI/CD) pipeline to compile, test, and deploy source code to an application group. The pipeline templates start by compiling source code. This process requires you to grant Apsara DevOps access to the source code. Consider a scenario where User A wants to use Application Management to deploy software from User B. However, Company B's data security policy prohibits hosting source code in the cloud. Company B can only provide compiled packages. This topic describes a flexible solution that enables on-premises continuous integration and cloud-based continuous deployment.
Overall architecture
The main steps are as follows:
-
User A creates an Object Storage Service (OSS) bucket to store the build output and an access credential with the least privilege for User B.
-
User B adds a step to their existing build workflow. This step uploads the build output, such as a JAR, WAR, or compressed package, to User A's OSS bucket. The filename of the build output must indicate the version. For example, you can include a version number, branch information, or commit ID.
-
In Application Management, User A navigates to Release Management and creates a release pipeline. In the pipeline, User A removes the source code compilation step and replaces it with a step to download the build output from OSS.
-
To deploy manually, User A can start the pipeline from Release Management in Application Management.
-
If User A and User B want to fully automate their CI/CD process, they can add a step to the build workflow to automatically trigger the deployment pipeline by calling an Apsara DevOps pipeline webhook.
Detailed solution
The build workflow must be customized for your specific build system. For example, if you use Jenkins, you must first install ossutil on the Jenkins machine and configure its access credentials. Then, you can add a step to the pipeline that runs after the build is complete. This step runs ossutil to upload the build output to the OSS bucket. This topic focuses on the release configuration in Application Management.
-
Create an Apsara DevOps pipeline: In Release Management in Application Management, create a pipeline. Before you begin, make sure that an Apsara DevOps organization is associated and that Apsara DevOps is authorized to deploy applications to ECS. For a Java project, select the Java build and deployment template.
-
On the pipeline editor page, modify the pipeline steps.
-
Delete the Java build task and add an OSS download task to download a specified file from the OSS bucket that stores the build output. The file path can contain variables so that you can deploy a specific version of the build output. Retain the build output upload step.
-
In the ECS application deployment step, write a deployment script based on the contents of the artifact package and the application startup method. The script must decompress the artifact and then start the application.
-
-
When you run the pipeline, enter the variable values as prompted. In this example, enter the version number of the artifact to deploy.
-
To trigger the Apsara DevOps pipeline from an on-premises workflow, enable the webhook trigger for the pipeline and call the webhook from the build workflow. For more information, see Webhook triggers.
Summary
This approach decouples on-premises CI from cloud-based CD. You can run them separately or integrate them. When you use Apsara DevOps to deploy applications, you can take full advantage of the dynamic grouping and elastic scaling features of Application Management. For example, if ECS instances are added to or removed from a group, the next deployment is not affected.