This commit is contained in:
2025-10-12 18:16:36 +08:00
parent c9412702df
commit 1b65c1de45

View File

@@ -12,29 +12,35 @@ steps:
- echo "Hello, World!" > hello.txt - echo "Hello, World!" > hello.txt
- name: upload-hello-txt - name: upload-hello-txt
image: /bin/zsh image: /bin/zsh
environment: environment:
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID} AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY} AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION} AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
S3_BUCKET: ${S3_BUCKET} S3_BUCKET: ${S3_BUCKET}
S3_ENDPOINT: ${S3_ENDPOINT} S3_ENDPOINT: ${S3_ENDPOINT}
commands: commands:
- | - |
set -e set -e
if [[ -n "$AWS_ACCESS_KEY_ID" && -n "$AWS_SECRET_ACCESS_KEY" && -n "$S3_BUCKET" ]]; then echo "=== 调试信息 ==="
echo "Uploading hello.txt to S3..." echo "AWS_ACCESS_KEY_ID is set: $([[ -n "$AWS_ACCESS_KEY_ID" ]] && echo 'YES' || echo 'NO')"
# 设置 plugin-s3 环境变量 echo "AWS_SECRET_ACCESS_KEY is set: $([[ -n "$AWS_SECRET_ACCESS_KEY" ]] && echo 'YES' || echo 'NO')"
export PLUGIN_SOURCE="hello.txt" echo "S3_BUCKET is set: $([[ -n "$S3_BUCKET" ]] && echo 'YES' || echo 'NO')"
export PLUGIN_BUCKET="$S3_BUCKET" echo "S3_ENDPOINT value: ${S3_ENDPOINT:-'NOT SET'}"
export PLUGIN_TARGET="woodpecker-test/" echo "================"
[[ -n "$S3_ENDPOINT" ]] && export PLUGIN_ENDPOINT="$S3_ENDPOINT" && export PLUGIN_PATH_STYLE=true
plugin-s3 if [[ -n "$AWS_ACCESS_KEY_ID" && -n "$AWS_SECRET_ACCESS_KEY" && -n "$S3_BUCKET" ]]; then
echo " hello.txt uploaded successfully!" echo "Uploading hello.txt to S3..."
else export PLUGIN_SOURCE="hello.txt"
echo "⚠️ No S3 credentials found. Skipping upload." export PLUGIN_BUCKET="$S3_BUCKET"
fi export PLUGIN_TARGET="woodpecker-test/"
[[ -n "$S3_ENDPOINT" ]] && export PLUGIN_ENDPOINT="$S3_ENDPOINT" && export PLUGIN_PATH_STYLE=true
plugin-s3
echo "✅ hello.txt uploaded successfully!"
else
echo "⚠️ No S3 credentials found. Skipping upload."
fi
- name: s3-upload-demo - name: s3-upload-demo
image: /bin/zsh image: /bin/zsh
environment: environment: