无法将构建构件复制到 S3 存储桶



我试图使用cp命令将代码构建期间生成的文件复制到S3 bucket。我可以看到文件,但当我试图复制文件时,它说文件不存在。我仍然很困惑为什么我不能复制这个文件。请检查下面的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"

相关内容

最新更新