Build a CI/CD pipeline that uses Jenkins to package a WordPress application, stores build artifacts in OSS, and deploys them to ECS instances through OOS batch tasks.
Background information
-
WordPress source code is available on GitHub.
-
CloudOps Orchestration Service: an automated O&M service provided by Alibaba Cloud for software version management and phased release. What is OOS?
-
OSS: stores the built software packages. Multiple storage types are supported. What is OSS?
-
Jenkins: an automation server that triggers software package updates in OSS and OOS. Jenkins official website.
-
Resource Orchestration Service (ROS): an automated resource deployment service provided by Alibaba Cloud that deploys cloud resources such as ECS, ApsaraDB RDS, and Server Load Balancer (SLB) that this system depends on with a few clicks. What is ROS?
Create a WordPress environment
Use ROS to create a WordPress environment with ECS and ApsaraDB RDS.
-
Log on to the ROS console.
-
In the left-side navigation pane, choose .
-
On the Sample Templates page, find the template named Create a WordPress Environment Based on ECS and ApsaraDB for RDS and click Create Stack.

-
Set the parameters and click Create.
After the stack is created, it appears in the stack list:

-
Click the WordPressUrl link in the Value column to open the WordPress website.
Open the URL in a browser to confirm the deployment.
Install and configure Alibaba Cloud CLI
This example uses macOS.
-
Create a RAM user and obtain an AccessKey pair for Alibaba Cloud CLI.
-
Install Alibaba Cloud CLI.
brew install aliyun-cli -
Configure Alibaba Cloud CLI.
aliyun configure -
Verify that Alibaba Cloud CLI is installed. The command output lists supported regions.
aliyun ecs DescribeRegions
Install and configure Jenkins
This example uses macOS. The Install Jenkins page covers other operating systems.
-
Install the latest version.
brew install jenkins -
Install the LTS version.
brew install jenkins-lts -
Start Jenkins.
brew services start jenkins-lts -
Open
localhost:8080in a browser. -
Copy the password from the provided directory, paste it in the Administrator password field, and then click Continue.

-
Install the default plug-ins.

-
Configure the username and password and then log on to Jenkins.
Use Jenkins to update a software package
-
Click New Item on the homepage of Jenkins.
-
Select Freestyle project, enter the project name, and click OK.
-
Go to the Source Code Management tab, select Git, and then enter the repository URL.
https://github.com/WordPress/WordPress.git -
Go to the Build tab, click Add build step, and select Execute shell. Copy the following script into the Command field. The script packages the WordPress master branch, uploads it to oss://wordpress-test-oos, and creates a software package named wordpress in OOS.
version=`date +%s` # Generate the wordpress_$version.tar package. tar -cvf wordpress_$version.tar `find .|grep -v wp-config-sample.php|grep -v targets|grep -v .git|grep -v ^\.$` # Copy the package to OSS. /usr/local/bin/aliyun oss cp wordpress_$version.tar oss://wordpress-test-oos/wordpress_$version.tar templateName=wordpress # Specify the OSS path of the package and configure the installation script. # { # "FormatVersion": "OOS-2020-01-01-Package", # "Description": "", # "Packages": [{ # "Name": "wordpress_$version.tar", # "Location": "oss://wordpress-test-oos/wordpress_$version.tar", # "InstallScript": "test -e wordpress || mkdir wordpress && cd wordpress && mv ../wordpress_$version.tar . && tar xvf wordpress_$version.tar > /dev/null && rm wordpress_$version.tar && cp -rf * /var/www/html/", # "UninstallScript": "echo uninstall", # "Targets": [{ # "PlatForm": "centos", # "Architect": "x86_64" # }] # }] # } templateContent="{\"FormatVersion\":\"OOS-2020-01-01-Package\",\"Description\":\"\",\"Packages\":[{\"Name\":\"wordpress_$version.tar\",\"Location\":\"oss://wordpress-test-oos/wordpress_$version.tar\",\"InstallScript\":\"test -e wordpress || mkdir wordpress && cd wordpress && mv ../wordpress_$version.tar . && tar xvf wordpress_$version.tar > /dev/null && rm wordpress_$version.tar && cp -rf * /var/www/html/\",\"UninstallScript\":\"echo uninstall\",\"Targets\":[{\"PlatForm\":\"centos\",\"Architect\":\"x86_64\"}]}]}" # Update the software package in OOS. /usr/local/bin/aliyun oos CreateTemplate --TemplateName=$templateName --Content "$templateContent" || /usr/local/bin/aliyun oos UpdateTemplate --TemplateName=$templateName --Content "$templateContent" # Delete the temporary package. rm wordpress_$version.tar -
Click Save.
-
Click Build Now to trigger the deployment pipeline. Check the deployment status in the Build History section.

-
View the deployment logs in Console Output.
The build pulls code from Git, packages it with tar, uploads the package to OSS, and registers it in OOS. To view the package, go to Server Management > Extensions in the OOS console and click the Custom Extensions tab.

-
On the Custom Extensions tab, click Details to view the package name, storage location, installation script, uninstallation script, and version history.

Deploy the software package from OOS
-
Log on to the OOS console.
-
In the left-side navigation pane, choose , and then click Create.
-
On the Create Task Batch Software Management page, select a public extension (WordPress-One-Click) and the instance, and then click Create.
NoteSelect the instance created by ROS.

-
Configure a role for the instance by clicking Authorize.
If the Select Instances button is disabled, configure a role for the instance. OOS uses this role to access packages in OSS. Skip this step if the button is active.


-
Grant permissions to the role.
-
If an existing RAM role has the AliyunOOSReadOnlyAccess and AliyunOSSReadOnlyAccess policies attached with ECS as the trusted service, click Create. The execution is successful in the execution list.
-
To create a RAM role for the instance:
-
Log on to the RAM console. On the Roles page, click Create Role. Select Alibaba Cloud Service as the trusted entity, select Elastic Compute Service as the trusted service, and click OK.
-
Attach the AliyunOOSReadOnlyAccess and AliyunOSSReadOnlyAccess policies to the created RAM role.

-
Go to the Create Task Batch Instance Operations page, select Instance Operations as Task Type, click Add Role, and assign the RAM role to the instance.
-
-
-
Return to the Create Task Batch Software Management page, select the instance with the RAM role, and click Create.

-
On the Task Execution Management page, check the execution status. If successful, the latest WordPress files are deployed to /var/www/html. Click Details to view execution logs.
Conclusion
You have built a CI/CD pipeline with Jenkins and OOS. The OOS Extensions feature manages software versions and supports phased release. In Jenkins, you can also directly call the Extensions feature of OOS to automate the deployment process. To automate image updates, see the "Implement automated image updates by using Jenkins, OOS, and OSS" topic.