【发布时间】:2020-08-10 05:51:37
【问题描述】:
我想使用 Jenkinsfile 将我的成功构建工件发布到 AWS S3 存储桶。
请帮助我,我是一只新蜜蜂。
通过谷歌搜索,我知道我们必须为此使用 S3 发布者插件。但现在确定如何编写一个 groovy 脚本。
问候, 亚布拉曼尼亚L
【问题讨论】:
标签: amazon-web-services jenkins amazon-s3 jenkins-pipeline jenkins-plugins
我想使用 Jenkinsfile 将我的成功构建工件发布到 AWS S3 存储桶。
请帮助我,我是一只新蜜蜂。
通过谷歌搜索,我知道我们必须为此使用 S3 发布者插件。但现在确定如何编写一个 groovy 脚本。
问候, 亚布拉曼尼亚L
【问题讨论】:
标签: amazon-web-services jenkins amazon-s3 jenkins-pipeline jenkins-plugins
node {
stage('Upload') {
dir('path/to/your/project/workspace'){
withAWS(region:'your-S3-bucket-region',credentials:'newly-created-credentials-ID') {
def identity=awsIdentity();
// Upload files from working directory to project workspace
s3Upload(bucket:"use-S3", workingDir:'your-working-dir', includePathPattern:'**/*');
}
};
}
}
【讨论】:
s3Upload(bucket:"my-bucket", path:'path/to/targetFolder/', includePathPattern:'**/*.txt', workingDir:'/var/lib/jenkins/workspace/<project-name>/<dir-where-files-exist>') 例如 2. 包括除特定扩展名之外的所有文件:s3Upload(bucket:"my-bucket", path:'path/to/targetFolder/', includePathPattern:'**/*', workingDir:'/var/lib/jenkins/workspace/<project-name>/<dir-where-files-exist>', excludePathPattern:'**/*.txt') 3. jenkins 插件文档:plugins.jenkins.io/pipeline-aws/#s3upload