在cloudbuild.yaml文件中添加一小段bash脚本代码,可以用以下的示例代码来实现:
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/my-app', '.']
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/my-app']
- name: 'gcr.io/cloud-builders/docker'
args: ['run', 'gcr.io/$PROJECT_ID/my-app']
- name: 'bash'
entrypoint: 'bash'
args:
- '-c'
- |
echo "Hello World!"
echo "This is a small bash script added to cloudbuild.yaml."
这段代码在执行完前面的Docker相关的步骤之后,再执行一段bash脚本代码,实现在云环境中运行bash脚本的功能。