无法将构建工件复制到 S3 存储桶
Can't copy build artifact to S3 bucket
我试图使用 cp 命令将代码构建期间生成的文件复制到 S3 存储桶。我可以看到该文件,但是当我尝试复制该文件时,它说文件不存在。我仍然很困惑为什么我不能复制文件。请检查下面的Buildspec.yml。
version: 0.2
phases:
install:
commands:
- echo Installing MySQL
- apt update
- apt-get install mysql-client -y
- mysqldump --version
- mysqldump -h ***** -u $User -p****--no-data --routines --triggers -f testdb > ./backup.sql
- ls
- aws s3 cp backup.sql s3://dev-test --recursive --acl public-read --cache-control "max-age=100"
post_build:
commands:
- echo Build completed on `date`
请检查 AWS Codebuild 生成的日志。
Logs:
[Container] 2021/04/26 02:55:41 Running command mysqldump -h ***** -u $User -p****--no-data --routines --triggers -f testdb > ./backup.sql
[Container] 2021/04/26 02:55:43 Running command ls
Jenkinsfile
README.md
backup.sql
buildspec.yml
utils.groovy
[Container] 2021/04/26 02:55:43 Running command aws s3 cp backup.sql s3://dev-test --recursive --acl public-read --cache-control "max-age=100"
warning: Skipping file /codebuild/output/src985236234/src/backup.sql/. File does not exist.
Completed 0 file(s) with ~0 file(s) remaining (calculating...)
[Container] 2021/04/26 02:55:44 Command did not exit successfully aws s3 cp backup.sql s3://dev-test --recursive --acl public-read --cache-control "max-age=100" exit status 2
[Container] 2021/04/26 02:55:44 Phase complete: INSTALL State: FAILED
[Container] 2021/04/26 02:55:44 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: aws s3 cp backup.sql s3://dev-test --recursive --acl public-read --cache-control "max-age=100". Reason: exit status 2```
您正在上传 单个文件 backup.sql
,但 --recursive
会将其视为目录。
应该是:
aws s3 cp backup.sql s3://dev-test --acl public-read --cache-control "max-age=100"
我试图使用 cp 命令将代码构建期间生成的文件复制到 S3 存储桶。我可以看到该文件,但是当我尝试复制该文件时,它说文件不存在。我仍然很困惑为什么我不能复制文件。请检查下面的Buildspec.yml。
version: 0.2
phases:
install:
commands:
- echo Installing MySQL
- apt update
- apt-get install mysql-client -y
- mysqldump --version
- mysqldump -h ***** -u $User -p****--no-data --routines --triggers -f testdb > ./backup.sql
- ls
- aws s3 cp backup.sql s3://dev-test --recursive --acl public-read --cache-control "max-age=100"
post_build:
commands:
- echo Build completed on `date`
请检查 AWS Codebuild 生成的日志。
Logs:
[Container] 2021/04/26 02:55:41 Running command mysqldump -h ***** -u $User -p****--no-data --routines --triggers -f testdb > ./backup.sql
[Container] 2021/04/26 02:55:43 Running command ls
Jenkinsfile
README.md
backup.sql
buildspec.yml
utils.groovy
[Container] 2021/04/26 02:55:43 Running command aws s3 cp backup.sql s3://dev-test --recursive --acl public-read --cache-control "max-age=100"
warning: Skipping file /codebuild/output/src985236234/src/backup.sql/. File does not exist.
Completed 0 file(s) with ~0 file(s) remaining (calculating...)
[Container] 2021/04/26 02:55:44 Command did not exit successfully aws s3 cp backup.sql s3://dev-test --recursive --acl public-read --cache-control "max-age=100" exit status 2
[Container] 2021/04/26 02:55:44 Phase complete: INSTALL State: FAILED
[Container] 2021/04/26 02:55:44 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: aws s3 cp backup.sql s3://dev-test --recursive --acl public-read --cache-control "max-age=100". Reason: exit status 2```
您正在上传 单个文件 backup.sql
,但 --recursive
会将其视为目录。
应该是:
aws s3 cp backup.sql s3://dev-test --acl public-read --cache-control "max-age=100"