Experience introduction

This scenario guides you through deploying microservices applications to the SAE platform with Jenkins: Scenario Resources

Background knowledge

This scenario mainly involves the following cloud products and services: Serverless Application engine SAE

Serverless App Engine (SAE) is an application-oriented Serverless PaaS platform, which enables PaaS users to avoid IaaS, use on demand, and charge by volume, thus enabling them to access the cloud with a low threshold. Compared with other Serverless products, it abstracts the concept of application and provides a complete set of microservice solutions, supporting Spring Cloud, Dubbo, HSF and other mainstream microservice development frameworks, realizing the perfect combination of Serverless architecture and microservice architecture.

Create a resource

  1. On the left side of the page, click the drop-down menu of Cloud Product Resources to view the experimental resources.

  2. Click Free to create the required resources.

Description:

The resource creation process takes 1 to 3 minutes. After the experiment resource is created, you can view the information about the created resource, such as the IP address, user name, and password, in the cloud product resource list.

Configuration items

1. Modify the Maven project configuration and add the Toolbo-Maven-plugin and deployment information. For details, see Deploying Applications Automatically using Maven Plug-ins.

Configuration Jenkins

1. On the Menu bar of the Jenkins console, choose Manage Jenkins > Manage Plugins to install Git and GitLab Plugins.

2. On the menu bar of the Jenkins console, choose Manage Jenkins > Global Tool Configuration, set the Maven version name and configure the path, and click Save.

3. Generate SSH RSA key pair on Jenkins server and import the public key into GitLab to realize automatic authentication when Jenkins pulls GitLab code.

3.1 Generate SSH RSA key pair on Jenkins server. Specific information,GitLab document 3.2 Go to the GitLab home page, choose Settings > Deploy Keys on the menu bar, and click New Deploy Key to import the SSH RSA public Key created on the Jenkins server.

Create Jenkins task

1. Click New Item in the left navigation bar of Jenkins home page, enter the task name in the create task interface, select Freestyle Project, and click OK to configure the task information.

2. Click Source Management. On the source management TAB page, select Git and set related parameters.

Repository URL: The Git protocol address of your project. Credentials: Security Credentials. Select None.3. Click Build trigger and select GitHub Hook Trigger for GITScm Polling on the Build trigger TAB.

4. Click build environment. On the build environment TAB page, select Add timestamps to the Console Output to Add timestamps to the Output information of the Console.

5. Click Build. On the Build TAB page, click add Build step and select Invoke Top-level Maven Targets from the drop-down list.

6. Set Maven Version and Goals in the Invoke Top-level Maven targets area. If you want to deploy a multi-module project, see the (Optional) Jenkins task for Creating a Multi-module Project.

Maven Version: Click the drop-down box next to this option and select the Maven Version name configured in the Global Tool configuration. Goals: Enter MVN Clean Package Toolkit: deploy-dToolkit_profile =toolkit_profile.yaml -dToolkit_package =toolkit_package.yaml -dtoolkit_deploy =toolkit_deploy.yaml (If other parameters are required, set them based on actual conditions).

Configure GitLab’s Web Hook

1. Right-click the Gitlab project on the Gitlab home page and choose Setting > Web Hooks.

2. In the URL field of the Web Hooks page, enter http://jenkins server address: Jenkins server listening port /git/notifyCommit? Url = Git protocol address of this project.

The Jenkins server address represented in the figure is the Web access address of your Jenkins server, such as 192.168.xx.xx :80803. Click Test Hook to Test the configuration result

Commit changes to GitLab

If the above steps are configured correctly, a GitLab Hook will be triggered after the submission. Jenkins will build your Maven project after receiving the Hook and invoke the SAE POP API script to trigger the deployment at the end of the build.

Submit log information for successful deployment (Build Number > console output).If deployment fails, you can log inThe SAE consoleTo view the execution process of the deployment task. Specific steps,See Viewing change Records.