You can use Jenkins to build a continuous integration (CI) solution for applications deployed in Enterprise Distributed Application Service (EDAS). The following computer languages and development tools are used in a CI solution. You must be familiar with these languages and tools.
Prerequisites
-
An AccessKey ID and an AccessKey secret are obtained. To obtain an AccessKey ID and an AccessKey secret, perform the following steps:
- Log on to the official website of Alibaba Cloud by using the Alibaba Cloud account that you use to activate EDAS.
- An application is created and deployed in the EDAS console. To create and deploy an
application in the EDAS console, perform the following steps:
- Log on to the EDAS console.
- For information about how to deploy an application, see Overview and Create and deploy applications (Kubernetes).
If you have already created an application, skip this step.
- In the left-side navigation pane, click Applications. Click the name of the application you created in the previous step. On the Basic Information tab, obtain the application ID.
- Your code is hosted in GitLab. You can build a GitLab package or use Alibaba Cloud Code.
In this topic, a self-managed GitLab package is used as an example. For more information, visit GitLab.
- You are familiar with Jenkins. For more information, visit Jenkins.
Background information
Tool | Description |
---|---|
Maven | Maven is an automation tool that is used to build and manage projects. |
Jenkins | Jenkins is a scalable automation server that facilitates CI. |
GitLab | GitLab is an open source, self-hosted software development platform that allows you to access private or public repositories on webpages. GitLab is built by using Ruby on Rails. Similar to GitHub, GitLab allows you to review code, manage defects, and leave comments. |
Configure a project
Configure a project and the toolkit-maven-plugin plug-in, and specify the deployment information for the plug-in. For more information, see Use toolkit-maven-plugin to deploy applications to ECS clusters. After you configure the project, we recommend that you use Maven on a self-managed server to verify whether the configuration is correct.
Install and configure Jenkins
Configure GitLab webhooks to enable automatic building
Submit the changes to GitLab
If the preceding configurations are correct, a GitLab hook is triggered. After the hook is received, Jenkins builds your Maven project and then calls the EDAS POP API script to trigger deployment.
After the project is deployed, you can choose
to view the output log.15:58:51 [INFO] Deploy application successfully!
15:58:51 [INFO] ------------------------------------------------------------------------
15:58:51 [INFO] BUILD SUCCESS
15:58:51 [INFO] ------------------------------------------------------------------------
15:58:51 [INFO] Total time: 24.330 s
15:58:51 [INFO] Finished at: 2018-12-25T15:58:51+08:00
15:58:51 [INFO] Final Memory: 23M/443M
15:58:51 [INFO] ------------------------------------------------------------------------
15:58:51 Finished: SUCCESS
If the deployment fails, log on to the EDAS console.In the left-side navigation pane, click Applications. On the Applications page, click the application. The application details page appears. In the left-side navigation pane, click Change Records to view the execution process of the deployment.
Create a Jenkins job for a multi-module project
The procedure used to create a Jenkins job for a multi-module project is the same
as Step 5. You only need to adjust the invoke top-level Maven targets. If you want to deploy a submodule for a multi-module project in Jenkins, run the
mvn clean install
command in the parent module. Then, run the mvn clean package toolkit:deploy
command in the submodule. The following structure of the demo project is used as an example:
In the preceding demo project, detail, itemcenter, and itemcenter-api are submodules.
If you want to deploy itemcenter, you must run the clean install command in the parent
module to build a target. Then, you must run the clean package toolkit:deploy
command in the itemcenter submodule to build a target.