# qcloud-cos-upload **Repository Path**: CodeinChad/qcloud-cos-upload ## Basic Information - **Project Name**: qcloud-cos-upload - **Description**: Jenkins pipeline上传资源到腾讯云COS - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2021-05-26 - **Last Updated**: 2023-08-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # qcloud-cos-upload ## 简介 利用Jenkins Pipeline将资源上传到腾讯云COS ## 快速开始 #### 打包插件 - 在项目根目录下运行`./pkg.sh`或者执行`mvn clean -Dmaven.test.skip=true package` - 会生成 `target/qcloud-cos-upload.hpi`文件 #### 安装插件 - Jenkins -> Manage Jenkins -> Manage Plugins -> Advanced -> Upload Plugin - 上传上一步生成的 hpi 文件 #### 在Jenkins中配置COS访问密钥 - Manage Jenkins -> Manage Credentials -> Add Credentials - Kind选择 `username with password` - `id`为`qcloud-jenkines`,`username`为secretId,password为secretKey #### Pipeline使用qcloudCosUpload ``` withCredentials([usernamePassword(credentialsId: 'qcloud-jenkins', passwordVariable: 'secretKey', usernameVariable: 'secretId')]) { qcloudCosUpload secretId: "${secretId}", secretKey: "${secretKey}", region: "ap-shanghai", bucket: "your bucket id", fileName: 'your cos file name', file: 'jenkins file absoulte path' } ``` - secretId: 腾讯云COS访问ID - secretKey: 腾讯云COS访问密钥 - region:COS桶所在区域简码,可查看 [区域简码](https://cloud.tencent.com/document/product/436/6224) - bucket: COS存储桶ID - fileName: 文件上传到COS后的文件名 - file: Jenkins本地资源的绝对路径 - prefixPath: 如果fileName为空,使用 `prefixPath/随机名` 存储;如果fileName不为空,忽略此参数