The PHP test build pipeline automates code checkout, compilation and build, unit testing, result recording, and test statistics collection. This minimizes manual intervention, improves project visibility, and enables developers to easily identify and resolve issues based on valid logs.
Step 1: Create a test build pipeline
Log on to the Flow console. In the console, click Create Pipeline in the upper-right corner.
In the Select a pipeline template dialog box, select PHP · Build, deploy to Alibaba Cloud ECS/self-hosted server and click Create.

Step 2: Configure a pipeline source
On the Process Configuration page of the new pipeline, click Add Pipeline Source in Pipeline Source.
Click Code Source. In this topic, select Sample Code Source, select PHP as Code Type, and click Add.
Step 3: Configure the test build
The pipeline allows you to specify different values for Build Cluster and Build Environment in different Test stages to perform build jobs.
Configure basic parameters.
Parameter
Description
Job Name
You can specify a 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 (default build cluster provided by Alibaba Cloud DevOps): Flow starts the specified container on the build machine and builds a single-container environment. Alibaba Cloud DevOps provides Flow System Images. You can also specify your image as the build environment.
Default VM Environment (supported only by self-hosted build clusters): You must select a value from the Specify Build Nodes drop-down list. Flow directly installs the environment on the build machine and runs the job. To increase job build efficiency, we recommend that you install the related SDK and environment on the build machine in advance.
NoteDuring job execution, the pipeline job build environment is assigned to you. You have the permissions to use the build environment and can create a custom job execution script.
Download Source
The configured source file can be downloaded to the corresponding working directory. The following three download methods are available:
Download All Pipeline Sources
Do Not Download Pipeline Sources
Download Selected Pipeline Sources
Configure build steps.
Specified Container Environment/Default VM Environment
Unit Testing
Click Add New Stage. Then, click Empty Job in Empty Template. Click the Empty Job node. In the Edit panel, click Add Step in the Build Steps section, and choose . Configure the commands to be executed.
Click Add Step and choose . Configure parameters of Unit Test Report.
Parameter
Description
Step Name
Specify a step name.
Container Image
Enter a container image URL. This parameter is valid only for Specify Container Environment.
Provide a complete container image URL in the following format: build-steps-public-registry.ap-southeast-1.cr.aliyuncs.com/build-steps/php:version number.
Execute Commands
Specify the correct PHP version in your code repository. Otherwise, an error may occur when commands are run.
mkdir report php --version curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer composer -v composer install composer require --dev phpunit/phpunit:^10 vendor/bin/phpunit --testdox-html ${PROJECT_DIR}/report/index.html echo "==================" cat report/index.html echo "=================="Path of Test Report
The path of test reports. The path must point to a file, and all files in the directory where the file exists are uploaded. Example: report/index.html.
Reporter
Select a testing tool or framework. Example: Php-UnitTest.
Fail on Error
Specifies whether to stop the pipeline when a unit test fails. The check box is selected by default.

PHP BUILD
In the PHP BUILD stage, you can select different values from the Build Environment drop-down list based on the values of Build Cluster to perform the build job.
Configure build environment parameters and related commands to be executed.
Parameter
Description
Container Image
Provide a complete container image URL in the following format: build-steps-public-registry.xxx.cr.aliyuncs.com/build-steps/alinux3:latest. This parameter is valid only for Specify Container Environment.
Use Private Image Repository
Add a service connection. For more information, see Manage service connection. This parameter is valid only for Specify Container Environment.
Download Source
The configured source file can be downloaded to the corresponding working directory.
Commands to Execute
The default command to be executed for PHP is php --version.

In the Artifact Upload job step, configure Upload Type and related parameters.
Upload build artifacts to Packages for centralized management
Parameter description:
Parameter
Description
Add a service connection
Click Add a service connection. Create a service connection from Flow to Alibaba Cloud DevOps Packages. For more information, see Manage service connection.
Repository
After a service connection is added, select the Generic repositor type in Packages.
NoteFor more information about Generic repositories, see Generic artifact management.
Artifact Name
This parameter is used to distinguish between different artifacts generated by multiple builds. The artifact name is used in component deployment. We recommend that you specify the name by using a dynamic variable.
Artifacts_${PIPELINE_ID}is used by default. You can also specify an artifact name, such astarget1.Product version
Uniquely identifies your artifact file. Repeated versions are not allowed for the same file. We recommend that you specify the name by using a dynamic variable. Example:
${DATETIME}.Package Path
Set the starting position as the relative path of the project folder. Example:
target/. You can set multiple file paths.The directory containing the package path in the product
If this option is selected, the generated package contains the complete packaging path. Otherwise, the package contains only files. When multiple packaging paths are set, this option is selected automatically.
Configuration example:

Host Deployment
In the Host Deployment stage, you can deploy the artifacts produced in the PHP BUILD stage to the hosts in a host group. For more information about the parameters, see Host deployment.

Step 4: Run and view a pipeline job
After the process configuration is complete, click Save and Run in the upper-right corner. In the dialog box that appears, click Run to run the pipeline job.
After the pipeline job is complete, in the build image job node, click Logs in the lower right part to view the execution process and result logs of the pipeline job.
