This topic describes how to use the command-line interface (CLI) of Web App Service (Web+) to deploy a Java application in the Apsara DevOps 2020 console.
Step 1: Use Apsara DevOps 2020 to create a pipeline
- Log on to the Apsara DevOps 2020 console.Note If this is the first time you log on to the Apsara DevOps 2020 console, you must create an enterprise as prompted and log on with the enterprise. Apsara DevOps provides the workbench service only for enterprises.
- Click the menu icon in the upper-left corner and click Pipeline.
- On the Pipeline Flow page, click Create Pipeline.Note If you have not created any pipeline, the Welcome to Pipeline Flow dialog box appears when you enter the Pipeline Flow page. You can click Create Now to create a pipeline.
- In the Select Pipeline Template dialog box, click Other, select Other · Run Command, and then click Create.
- In the Add Pipeline Source pane, select General Git for Select Code Source, set Code Repository and Default Branch, and then set parameters in the Select Credential Type field. Then click Save.
Step 2: Orchestrate the pipeline
- On the Pipeline Orchestration page, click Run Command.
- In the Edit pane, set Task Name to Build and delete Run Command by clicking delete icon.
- In the Edit pane, click Add Step and choose .
- In the Build Java Application section, select the working directory and Java version based on your business needs and specify the content in Build Command.
- Click Add Step and choose .
- In the Upload Build Output section, select the working directory and modify Build Output Name and Packaging Path based on your business needs. Click Save in the upper-right corner and close the Edit pane.Note The final output of this step is Build output name.default, which will be used later.
- In the New Stage section of the pipeline, click New Task.
- In the left-side navigation pane of the Select Task Group dialog box, click Run Command. Then click Run Command on the right side.
- In the Edit pane, set Task Name to Publish.
- In the Edit pane, click the icon next to Run Command to show the Run Command field. In the field, enter the following script:
# Download the deployment package. curl -L $PACKAGE -o /tmp/webplus-java-demo.tgz tar -C /tmp -xzf /tmp/webplus-java-demo.tgz # Install and configure the Web + CLI. curl -s -L https://webplus-cn-shenzhen.oss-cn-shenzhen.aliyuncs.com/cli/install.sh | sudo sh wpctl configure --access-key-id $ACCESS_KEY_ID --access-key-secret $ACCESS_KEY_SECRET --region $REGION --profile webplus # Use the Web+ CLI to deploy the application. wpctl env:apply -y --package /tmp/webplus-java-demo-0.2.0-exec.jar --category "Java" --app webplus-java-demo --env test-env --create-on-absentNote For more information about how to use the Web+ CLI, see Install and upgrade the Web+ CLI (wpctl).
- In the Edit pane, click Add Parameter and add the parameters described in the following table. After the parameters are
added, click Save in the upper-right corner and close the Edit pane.
Source Parameter Description Upstream Output PACKAGE The build output generated in the package upload stage. The build output is named in the format of Build output name.default. Custom ACCESS_KEY_ID The AccessKey ID of the Alibaba Cloud account used to deploy the application in Web+. For more information, see Create an AccessKey. Custom ACCESS_KEY_SECRET The AccessKey secret of the Alibaba Cloud account used to deploy the application in Web+. For more information, see Create an AccessKey. Custom REGION Make sure that the region you entered is the same as the region where you want to deploy the application. For more information about regions supported by Web+, see Supported regions.
Step 3: Run the pipeline
- In the upper-right corner of the pipeline page, click Save and Run to start the pipeline.
- In the Run Configuration dialog box, select the branch to be published and click Run.
- Wait until the pipeline execution is complete. To view the deployed application and environment, log on to the Web+ console and select the region where the deployed application resides in the upper-left corner.
For more information about Apsara DevOps 2020, see Apsara DevOps 2020.