tencent cloud

How to Implement Application Upload and Version Update via CAR-CLI
最終更新日:2025-08-05 10:16:05
How to Implement Application Upload and Version Update via CAR-CLI
最終更新日: 2025-08-05 10:16:05
CAR-CLI is a command line tool for managing application versions. You can use CAR-CLI to quickly and easily query, upload, update, and delete application versions by calling TencentCloud APIs. This document describes the basic features of CAR-CLI and how to use it to implement an automated pipeline for updating application versions.

Basic features

Note:
You need to place the configuration file in the same directory as the CLI tool and replace with the SecretId, SecretKey, and AppId of your Tencent Cloud account. CAR-CLI supports the macOS, Windows, and Linux operating systems. The following examples are based on Linux.

View help information

Run the following command to view the tool's help information.
‌./car help
For example, run the following command to view the help information for the application creation command.
‌./car create-application help

Create an application

Run the following command to create an application. You need to enter the application name, which can contain up to 16 Chinese characters, letters, digits, or hyphens (-). If this command is executed successfully, the application ID of the new application will be returned.
‌./car create-application --name xxx

‌Create an application version

Execute the following command to create a new version for the application. Note that the maximum number of versions allowed under the same application is five. You need to provide the following details:
app-id: Application ID
name: Version name
type: Application format, supported formats include zip/rar/7z
Additionally, the following optional parameters are supported:
regions: Application version distribution regions, supported options include:
Code
Description
ap-chinese-mainland
Mainland China (Default Region)
ap-tokyo
Tokyo Standard Zone
ap-tokyo-fusion
Tokyo Integration Zone
ap-seoul
Seoul Standard Zone
ap-seoul-fusion
Seoul Integrated Zone
ap-singapore
Singapore Standard Region
ap-singapore-fusion
Singapore Integration Zone
eu-frankfurt
Frankfurt Standard Zone
eu-frankfurt-fusion
Frankfurt Integrated Zone
na-north-america
North America Standard Region
na-north-america-fusion
North America Integration Zone
me-middle-east-fusion
Middle East Integration Zone
sa-south-america-fusion
South America Integration Zone
update-mode:The application version update methods support FULL and INCREMENT, representing full updates and incremental updates, respectively.
If there exists a version in the states of "Creating/To be Released/Creation Failed," the operation will be denied. After the version is created, the application package must be uploaded, and the version must be released. Upon successful execution, the new version's ID will be returned.
Example:
./car create-application-version --app-id app-xxx --name xxx --type zip --update-mode FULL --regions ap-chinese-mainland,ap-tokyo

Upload an application version file

Run the following command to upload an application package for a new version. You need to enter the Application ID, local path of the application file (pay attention to the format differences between Windows and Linux), and the Application Version ID. Please ensure that both the Application ID and Application Version ID are accurate. If uploading the application via a URL, input the Application ID and the URL.
./car upload-application-version-file --app-id app-xxx --path C:\\\\data\\\\xxx.zip --version-id ver-xxx
./car upload-application-version-file --app-id app-xxx --path /data/xxx.zip --version-id ver-xxx
./car upload-application-version-file --app-id app-xxx --url xxx
Note:
After the application version file is uploaded successfully, if its version name and format are different from those used to create an application version, they will be replaced with those of the uploaded file.
If the upload fails during the creation of an application or an application version, you can still proceed with this command. You must ensure that the local file path is not changed.

Release an application version

Run the following command to release an application version. You need to enter the application ID and version ID.
‌./car set-version-online --app-id app-xxx --version-id ver-xxx

Delete an application version

‌Run the following command to asynchronously delete an application version. You need to enter the application ID and version ID. To check whether the version has been deleted successfully, you can query the list of application versions.
‌./car delete-application-version --app-id app-xxx --version-id ver-xxx

Display the list of application versions

Run the following command to display the list of application versions. You need to enter the application ID. To obtain the output version ID and version status of the oldest version, use the grep and awk commands.
./car describe-application-version --app-id app-xxx
‌./car describe-application-version --app-id app-xxx | grep -v "Inuse" | awk '{print $1}' | head -n 1

Pipeline for updating application versions

Below is an example to show you how to implement a pipeline for updating application versions.


‌Download CAR-CLI

Load the remote configuration file into the current working directory.
cd workdir

‌wget "your config file url"
Run the following scripts to download the CAR-CLI tool.
cd workdir

‌mkdir pkg && cd pkg
wget https://github.com/tencentyun/car-cli/releases/download/v1.0.0/car.zip
‌unzip car.zip
mv ./car/linux/car ../
‌cd ..

‌chmod +x car

Download the application file of the new version

Configure the following scripts to download the application file of the new version.
cd workdir

wget $PackageURL # Configure `PackageURL` in pipeline environment variables

Create an application version

Create a new version for an existing application, upload the new application version file, and finally release the new version.
Note:
If the number of application versions exceeds 5, this script will automatically delete the oldest versions which are not in use.
cd workdir

# Query the list of application versions
‌output=$(./car describe-application-version --app-id $ApplicationID) # Configure `ApplicationID` in pipeline environment variables
‌lineCount=$(echo "$output" | wc -l)

# If the number of application versions exceeds 5, delete the oldest versions which are not in use
‌if [ $lineCount -ge 5 ];then
versionID=$(echo "$output" | grep -v "Inuse" | awk '{print $1}' | head -n 1)
‌./car delete-application-version --app-id $ApplicationID --version-id $versionID
‌fi

# Deleting an application version is an async operation, so you need to regularly check whether the version deletion was successful
‌waitTimes=0
‌while [ $lineCount -ge 5 ]
do
output=$(./car describe-application-version --app-id $ApplicationID) # Replace the `ApplicationID` with your actual `ApplicationID`
‌lineCount=$(echo "$output" | wc -l)
waitTimes=$((waitTimes+1))
‌if [ $waitTimes -gt 20 ]
then
echo "Error: Waiting too long to delete application version."
exit 1
fi
sleep 1
done

‌# Query the application file name and type by `PackageURL`
‌fileName=$(basename $PackageURL) # Configure `PackageURL` in pipeline environment variables
‌echo $fileName
‌fileType="${PackageURL##*.}"
‌echo $fileType

# Create an application version
‌output=$(./car create-application-version --app-id $ApplicationID --name $fileName --type $fileType)

‌# Upload the new application version file to the cloud
‌./car upload-application-version-file --app-id $ApplicationID --version-id $output --path $fileName

# Release the new version
‌./car set-version-online --app-id $ApplicationID --version-id $output



この記事はお役に立ちましたか?
営業担当者に お問い合わせ いただくか チケットを提出 してサポートを求めることができます。
はい
いいえ

フィードバック