pipeline-operations
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePipeline Operations with Acquia Pipelines CLI
使用Acquia Pipelines CLI进行流水线操作
Use when:
- Triggering a pipeline build
- Checking pipeline job status or streaming logs
- Terminating a running job
- Encrypting pipeline variables or connecting GitHub
Use the Pipelines CLI to trigger, monitor, and manage CI/CD pipeline jobs on Acquia Cloud.
See Getting Started for installation, authentication, and finding your application ID.
适用场景:
- 触发流水线构建
- 检查流水线作业状态或流式查看日志
- 终止运行中的作业
- 加密流水线变量或连接GitHub
使用Pipelines CLI在Acquia Cloud上触发、监控和管理CI/CD流水线作业。
有关安装、身份验证和查找应用ID的信息,请查看**入门指南**。
Starting a Pipeline Job
启动流水线作业
Important:fires immediately — there is no confirmation prompt. Verify your application ID and target branch before running.pipelines start
重要提示:命令会立即执行——没有确认提示。请在运行前验证你的应用ID和目标分支。pipelines start
Verify before starting
启动前验证
bash
undefinedbash
undefinedConfirm the application ID
确认应用ID
pipelines list-applications
pipelines list-applications
Check whether a job is already running on the branch
检查分支上是否已有作业在运行
pipelines status --application-id=1g2i3b4b5o6u7s --job-id=latest
Proceed with `start` only after confirming the correct application and branch.pipelines status --application-id=1g2i3b4b5o6u7s --job-id=latest
确认应用和分支正确后,再执行`start`命令。Start for the current branch
为当前分支启动作业
Run from inside your git repository:
bash
pipelines start --application-id=1g2i3b4b5o6u7sThe CLI detects the current branch automatically.
在你的git仓库内运行:
bash
pipelines start --application-id=1g2i3b4b5o6u7sCLI会自动检测当前分支。
Start for a specific branch
为指定分支启动作业
bash
pipelines start \
--application-id=1g2i3b4b5o6u7s \
--vcs-path=feature/my-branchbash
pipelines start \
--application-id=1g2i3b4b5o6u7s \
--vcs-path=feature/my-branchStart and write artifact to a deploy branch
启动作业并将构建产物推送到部署分支
bash
pipelines start \
--application-id=1g2i3b4b5o6u7s \
--vcs-path=feature/my-branch \
--deploy-vcs-path=deploy/my-branchThe build artifact is pushed to on success.
deploy/my-branchbash
pipelines start \
--application-id=1g2i3b4b5o6u7s \
--vcs-path=feature/my-branch \
--deploy-vcs-path=deploy/my-branch构建成功后,产物会被推送到分支。
deploy/my-branchStart with environment variables
使用环境变量启动作业
bash
pipelines start \
--application-id=1g2i3b4b5o6u7s \
--vcs-path=main \
-D MY_VAR=foo \
-D ANOTHER_VAR=barbash
pipelines start \
--application-id=1g2i3b4b5o6u7s \
--vcs-path=main \
-D MY_VAR=foo \
-D ANOTHER_VAR=barStart and stream logs immediately
启动作业并立即流式查看日志
bash
pipelines start --application-id=1g2i3b4b5o6u7s --tailbash
pipelines start --application-id=1g2i3b4b5o6u7s --tailStart with log streaming delay
延迟流式查看日志启动作业
Useful when the build takes a moment to produce output:
bash
pipelines start --application-id=1g2i3b4b5o6u7s --tail --delay=5适用于构建需要一段时间才会输出内容的场景:
bash
pipelines start --application-id=1g2i3b4b5o6u7s --tail --delay=5Start with retry options
使用重试选项启动作业
Control how many times the log streaming retries on failure:
bash
pipelines start \
--application-id=1g2i3b4b5o6u7s \
--retries=3 \
--delay=5控制日志流式传输失败时的重试次数:
bash
pipelines start \
--application-id=1g2i3b4b5o6u7s \
--retries=3 \
--delay=5Start from an external (non-Acquia) repository
从外部(非Acquia)仓库启动作业
Use to pull source code from a GitHub or other external repo, with pointing to the SSH private key for access:
--source-vcs-uri--source-key-pathbash
pipelines start \
--application-id=1g2i3b4b5o6u7s \
--source-vcs-uri=git@github.com:myorg/myrepo.git \
--source-key-path=~/.ssh/id_rsa \
--vcs-path=mainNote: Pass the private key path, not thefile..pub
使用从GitHub或其他外部仓库拉取源代码,指向用于访问的SSH私钥:
--source-vcs-uri--source-key-pathbash
pipelines start \
--application-id=1g2i3b4b5o6u7s \
--source-vcs-uri=git@github.com:myorg/myrepo.git \
--source-key-path=~/.ssh/id_rsa \
--vcs-path=main注意:传入的是私钥路径,不是公钥文件。.pub
Start with container kept alive for debugging
启动作业并保持容器存活以进行调试
Keeps the build container running after the job completes so you can SSH in to debug:
bash
pipelines start --application-id=1g2i3b4b5o6u7s --keep-process-aliveYou will be prompted to confirm before the build starts.
作业完成后保持构建容器运行,以便你通过SSH进入调试:
bash
pipelines start --application-id=1g2i3b4b5o6u7s --keep-process-alive构建启动前会提示你确认。
Start using a codebase ID instead of application ID
使用代码库ID而非应用ID启动作业
bash
pipelines start \
--codebase-id=abcd1234-5678-90ab-cdef-000000000000 \
--vcs-path=mainOutput on success:
Successfully started a build:
VCS path: main
Target deployment branch: pipelines-build-main
Job ID: job-abc12345bash
pipelines start \
--codebase-id=abcd1234-5678-90ab-cdef-000000000000 \
--vcs-path=main成功输出:
Successfully started a build:
VCS path: main
Target deployment branch: pipelines-build-main
Job ID: job-abc12345Checking Job Status
检查作业状态
Check status of the latest job
检查最新作业状态
bash
pipelines status --application-id=1g2i3b4b5o6u7s --job-id=latestbash
pipelines status --application-id=1g2i3b4b5o6u7s --job-id=latestCheck status for a specific job
检查指定作业状态
bash
pipelines status \
--application-id=1g2i3b4b5o6u7s \
--job-id=job-abc12345bash
pipelines status \
--application-id=1g2i3b4b5o6u7s \
--job-id=job-abc12345Check status of latest job on a specific branch
检查指定分支的最新作业状态
bash
pipelines status \
--application-id=1g2i3b4b5o6u7s \
--job-id=latest:mainOutput:
Job ID: job-abc12345
Status: succeeded
Summary:
Site: my-site
VCS path: main
Submitted: 2024-02-20 10:15:00 (UTC)
Started: 2024-02-20 10:15:05 (UTC)
Finished: 2024-02-20 10:18:34 (UTC)Possible status values: , , , , , , .
succeededabortedsystem failurebuild errorqueuedrunningpausedbash
pipelines status \
--application-id=1g2i3b4b5o6u7s \
--job-id=latest:main输出:
Job ID: job-abc12345
Status: succeeded
Summary:
Site: my-site
VCS path: main
Submitted: 2024-02-20 10:15:00 (UTC)
Started: 2024-02-20 10:15:05 (UTC)
Finished: 2024-02-20 10:18:34 (UTC)可能的状态值:、、、、、、。
succeededabortedsystem failurebuild errorqueuedrunningpausedMachine-readable JSON output
机器可读的JSON格式输出
bash
pipelines status \
--application-id=1g2i3b4b5o6u7s \
--job-id=latest \
--format=jsonbash
pipelines status \
--application-id=1g2i3b4b5o6u7s \
--job-id=latest \
--format=jsonViewing Logs
查看日志
View logs for the latest job
查看最新作业日志
bash
pipelines logs \
--application-id=1g2i3b4b5o6u7s \
--job-id=latestbash
pipelines logs \
--application-id=1g2i3b4b5o6u7s \
--job-id=latestView logs for a specific job
查看指定作业日志
bash
pipelines logs \
--application-id=1g2i3b4b5o6u7s \
--job-id=job-abc12345bash
pipelines logs \
--application-id=1g2i3b4b5o6u7s \
--job-id=job-abc12345Stream (tail) logs live
实时流式查看日志
bash
pipelines logs \
--application-id=1g2i3b4b5o6u7s \
--job-id=latest \
--tailbash
pipelines logs \
--application-id=1g2i3b4b5o6u7s \
--job-id=latest \
--tailSave logs to file
将日志保存到文件
bash
pipelines logs \
--application-id=1g2i3b4b5o6u7s \
--job-id=latest > pipeline.log 2>&1bash
pipelines logs \
--application-id=1g2i3b4b5o6u7s \
--job-id=latest > pipeline.log 2>&1Listing Jobs
列出作业
bash
pipelines list-jobs 1g2i3b4b5o6u7sOutput lists recent jobs with their IDs, statuses, and branches.
bash
pipelines list-jobs 1g2i3b4b5o6u7s输出会列出近期作业的ID、状态和分支信息。
Terminating a Job
终止作业
Cancel a running job:
bash
pipelines terminate-job \
--application-id=1g2i3b4b5o6u7s \
--job-id=job-abc12345取消运行中的作业:
bash
pipelines terminate-job \
--application-id=1g2i3b4b5o6u7s \
--job-id=job-abc12345Encrypting Pipeline Variables
加密流水线变量
Encrypt sensitive values for use in :
acquia-pipelines.ymlbash
pipelines encryptYou will be prompted for the confidential data. Paste the encrypted output into your file.
acquia-pipelines.yml加密敏感值以在中使用:
acquia-pipelines.ymlbash
pipelines encrypt系统会提示你输入机密数据。将加密后的输出粘贴到文件中。
acquia-pipelines.ymlContainer Configuration
容器配置
Container configuration for Acquia Pipelines is defined in
at the root of your repository. The command picks this file up
automatically — there are no CLI flags for container settings.
acquia-pipelines.ymlpipelines startAcquia Pipelines的容器配置在仓库根目录的文件中定义。命令会自动读取该文件——没有用于容器设置的CLI参数。
acquia-pipelines.ymlpipelines startMinimal configuration structure
最小配置结构
yaml
version: 1.1.0
events:
build:
steps:
- build:
type: script
script:
- composer installyaml
version: 1.1.0
events:
build:
steps:
- build:
type: script
script:
- composer installConfigure the PHP version
配置PHP版本
Use the key to pin the PHP version for the build container:
servicesyaml
version: 1.1.0
services:
- php:
version: 8.2
events:
build:
steps:
- composer:
type: script
script:
- composer install --no-progressSupported versions depend on your Acquia Cloud subscription. Common values: , , .
8.18.28.3使用字段为构建容器指定PHP版本:
servicesyaml
version: 1.1.0
services:
- php:
version: 8.2
events:
build:
steps:
- composer:
type: script
script:
- composer install --no-progress支持的版本取决于你的Acquia Cloud订阅。常见值:、、。
8.18.28.3Add a MySQL service
添加MySQL服务
Include under when your build needs a database:
mysqlservicesyaml
version: 1.0.0
services:
- mysql
events:
build:
steps:
- build:
type: script
script:
- mysql -u root -proot -e "CREATE DATABASE mydb"
- composer install --no-interactionMySQL is available at with credentials .
127.0.0.1:3306root:root当构建需要数据库时,在下添加:
servicesmysqlyaml
version: 1.0.0
services:
- mysql
events:
build:
steps:
- build:
type: script
script:
- mysql -u root -proot -e "CREATE DATABASE mydb"
- composer install --no-interactionMySQL可通过访问,凭据为。
127.0.0.1:3306root:rootSet environment variables
设置环境变量
Declare plain-text variables in the section:
variables.globalyaml
version: 1.1.0
variables:
global:
APP_ENV: ci
PHP_MEMORY_LIMIT: 512M
events:
build:
steps:
- build:
type: script
script:
- composer installFor sensitive values, encrypt first with the CLI then paste the result:
bash
pipelines encrypt在部分声明明文变量:
variables.globalyaml
version: 1.1.0
variables:
global:
APP_ENV: ci
PHP_MEMORY_LIMIT: 512M
events:
build:
steps:
- build:
type: script
script:
- composer install对于敏感值,先使用CLI加密,再粘贴结果:
bash
pipelines encryptPaste your secret value when prompted
提示时输入你的机密值
Copy the output — a long encoded string
复制输出——一段长编码字符串
Then reference it in the YAML:
```yaml
variables:
global:
MY_SECRET:
secure: <paste encrypted output here>The decrypted value is available as inside build steps.
$MY_SECRET
然后在YAML中引用:
```yaml
variables:
global:
MY_SECRET:
secure: <粘贴加密输出>解密后的值可在构建步骤中通过访问。
$MY_SECRETAdd SSH keys for private dependencies
添加SSH密钥用于私有依赖
If your build pulls from private repositories, add an encrypted SSH key:
bash
undefined如果构建需要从私有仓库拉取依赖,添加加密的SSH密钥:
bash
undefinedEncrypt your private key
加密你的私钥
cat ~/.ssh/id_rsa | pipelines encrypt
Reference it in the YAML under `ssh-keys`:
```yaml
version: 1.1.0
ssh-keys:
my-deploy-key:
secure: <encrypted private key>
events:
build:
steps:
- build:
type: script
script:
- composer installThe key is loaded automatically into the build container before steps run.
cat ~/.ssh/id_rsa | pipelines encrypt
在YAML的`ssh-keys`下引用:
```yaml
version: 1.1.0
ssh-keys:
my-deploy-key:
secure: <加密后的私钥>
events:
build:
steps:
- build:
type: script
script:
- composer install密钥会在步骤运行前自动加载到构建容器中。
Multi-service example (PHP + MySQL + Node)
多服务示例(PHP + MySQL + Node)
yaml
version: 1.1.0
services:
- php:
version: 8.2
- mysql
variables:
global:
APP_ENV: ci
DB_URL: mysql://root:root@127.0.0.1:3306/mydb
NPM_TOKEN:
secure: <encrypted token>
events:
build:
steps:
- setup-db:
type: script
script:
- mysql -u root -proot -e "CREATE DATABASE mydb"
- backend:
type: script
script:
- composer install --no-interaction
- frontend:
type: script
script:
- nvm install node
- npm install
- npm run buildyaml
version: 1.1.0
services:
- php:
version: 8.2
- mysql
variables:
global:
APP_ENV: ci
DB_URL: mysql://root:root@127.0.0.1:3306/mydb
NPM_TOKEN:
secure: <加密后的令牌>
events:
build:
steps:
- setup-db:
type: script
script:
- mysql -u root -proot -e "CREATE DATABASE mydb"
- backend:
type: script
script:
- composer install --no-interaction
- frontend:
type: script
script:
- nvm install node
- npm install
- npm run buildValidate your configuration before triggering
触发前验证配置
There is no command. Check for common issues manually:
pipelines validatebash
undefined目前没有命令。手动检查常见问题:
pipelines validatebash
undefinedConfirm the file is valid YAML
确认文件是有效的YAML格式
python3 -c "import yaml,sys; yaml.safe_load(open('acquia-pipelines.yml'))"
&& echo "Valid YAML" || echo "Parse error"
&& echo "Valid YAML" || echo "Parse error"
python3 -c "import yaml,sys; yaml.safe_load(open('acquia-pipelines.yml'))"
&& echo "Valid YAML" || echo "Parse error"
&& echo "Valid YAML" || echo "Parse error"
Confirm it is committed and pushed — pipelines reads from the remote branch
确认文件已提交并推送——pipelines会读取远程分支的内容
git status acquia-pipelines.yml
git push
Then trigger and stream logs to catch runtime errors immediately:
```bash
pipelines start --application-id=<app-id> --tailgit status acquia-pipelines.yml
git push
然后触发作业并流式查看日志,以便立即捕获运行时错误:
```bash
pipelines start --application-id=<app-id> --tailGitHub Integration
GitHub集成
Connect a GitHub repository
连接GitHub仓库
bash
pipelines github:connectbash
pipelines github:connectDisconnect a GitHub repository
断开GitHub仓库连接
bash
pipelines github:disconnectbash
pipelines github:disconnectCI/CD Integration
CI/CD集成
GitHub Actions — trigger and wait
GitHub Actions — 触发并等待
yaml
undefinedyaml
undefined.github/workflows/pipeline.yml
.github/workflows/pipeline.yml
name: Trigger Acquia Pipeline
on:
push:
branches: [main]
jobs:
pipeline:
runs-on: ubuntu-latest
steps:
- name: Install Pipelines CLI
run: |
wget https://cloud.acquia.com/pipelines-client/download -O pipelines
chmod +x pipelines
sudo mv pipelines /usr/local/bin/pipelines
- name: Configure credentials
run: |
echo "${{ secrets.PIPELINES_CONFIG }}" > ~/.pipelines-config
- name: Start pipeline
run: |
pipelines start \
--application-id=${{ vars.ACQUIA_APP_ID }} \
--vcs-path=main \
--tailundefinedname: Trigger Acquia Pipeline
on:
push:
branches: [main]
jobs:
pipeline:
runs-on: ubuntu-latest
steps:
- name: Install Pipelines CLI
run: |
wget https://cloud.acquia.com/pipelines-client/download -O pipelines
chmod +x pipelines
sudo mv pipelines /usr/local/bin/pipelines
- name: Configure credentials
run: |
echo "${{ secrets.PIPELINES_CONFIG }}" > ~/.pipelines-config
- name: Start pipeline
run: |
pipelines start \
--application-id=${{ vars.ACQUIA_APP_ID }} \
--vcs-path=main \
--tailundefinedPoll for status in a script
在脚本中轮询状态
bash
#!/bin/bash
set -e
APP_ID="1g2i3b4b5o6u7s"
BRANCH="main"
echo "Starting pipeline..."
pipelines start --application-id=$APP_ID --vcs-path=$BRANCH
echo "Waiting for job to complete..."
while true; do
STATUS=$(pipelines status \
--application-id=$APP_ID \
--job-id=latest:$BRANCH \
--format=json | python3 -c "import sys,json; print(json.load(sys.stdin)['status'])")
echo "Status: $STATUS"
case "$STATUS" in
succeeded)
echo "Pipeline succeeded!"
exit 0
;;
"build error"|aborted|"system failure")
echo "Pipeline failed: $STATUS"
pipelines logs --application-id=$APP_ID --job-id=latest:$BRANCH
exit 1
;;
esac
sleep 15
donebash
#!/bin/bash
set -e
APP_ID="1g2i3b4b5o6u7s"
BRANCH="main"
echo "Starting pipeline..."
pipelines start --application-id=$APP_ID --vcs-path=$BRANCH
echo "Waiting for job to complete..."
while true; do
STATUS=$(pipelines status \
--application-id=$APP_ID \
--job-id=latest:$BRANCH \
--format=json | python3 -c "import sys,json; print(json.load(sys.stdin)['status'])")
echo "Status: $STATUS"
case "$STATUS" in
succeeded)
echo "Pipeline succeeded!"
exit 0
;;
"build error"|aborted|"system failure")
echo "Pipeline failed: $STATUS"
pipelines logs --application-id=$APP_ID --job-id=latest:$BRANCH
exit 1
;;
esac
sleep 15
doneBest Practices
最佳实践
- Verify before starting — Always run to confirm the app ID before
pipelines list-applications.pipelines start - Use during development — Stream logs immediately so failures surface without a separate
--tailcall.logs - Store credentials securely — Use to store credentials; never hardcode them in env vars or scripts.
pipelines configure - Avoid duplicate runs — Check before re-triggering to avoid redundant builds.
pipelines status --job-id=latest - Encrypt sensitive values — Use for any secrets referenced in
pipelines encrypt.acquia-pipelines.yml
- 启动前验证 — 执行前,务必运行
pipelines start确认应用ID。pipelines list-applications - 开发时使用— 立即流式查看日志,无需单独调用
--tail命令即可发现失败情况。logs - 安全存储凭据 — 使用存储凭据;切勿在环境变量或脚本中硬编码。
pipelines configure - 避免重复运行 — 重新触发前检查,避免冗余构建。
pipelines status --job-id=latest - 加密敏感值 — 中引用的任何机密信息都要使用
acquia-pipelines.yml加密。pipelines encrypt
Troubleshooting
故障排查
| Error | Cause | Solution |
|---|---|---|
| Credentials not configured or expired | Run |
| Missing | Add the build definition file and push |
| Branch not pushed to Acquia remote | Push the branch first: |
| | Commit and push the build file |
| Job ID is invalid or expired | Use |
| 错误 | 原因 | 解决方案 |
|---|---|---|
| 未配置凭据或凭据已过期 | 重新运行 |
| 仓库中缺少 | 添加构建定义文件并推送 |
| 分支未推送到Acquia远程仓库 | 先推送分支: |
| | 提交并推送构建文件 |
| 作业ID无效或已过期 | 使用 |