Commit 0ecc03de authored by 快乐石头111's avatar 快乐石头111

移除写死的oss参数,改为动态读取jenkis全局环境变量

parent 3c84a50d
......@@ -45,6 +45,7 @@ plugins {
id 'java'
id 'maven-publish'
id "org.jetbrains.kotlin.jvm" version "1.4.10"
id "maven"
}
apply plugin: "com.whl.gradle-publish-plugin"
......@@ -250,7 +251,7 @@ task hot{
}
group 'com.qmai.android.plugin'
version '1.99.4'
version '1.100'
gradlePublish {
......@@ -271,6 +272,14 @@ gradlePublish {
}*/
}
uploadArchives {
repositories.mavenDeployer {
repository(url: uri('/Users/leiwang/project/gradleplugin')) // 本地仓库路径
pom.groupId = "com1.qmai.android.plugin"// 唯一标识(通常为模块包名,也可以任意)
pom.artifactId = "GradlePlugin" // 项目名称(通常为类库模块名称,也可以任意)
pom.version = "0.0.1" // 版本号
}
}
/* userName USER_NAME
userPassword USER_PASSWORD
......
fdeee701682d36a45a9254d7c938a3ee
\ No newline at end of file
2512bd438049f35aeba0edbe85af038a09df266c
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>ccom.qmai.android.plugin</groupId>
<artifactId>CpPluginPlugin</artifactId>
<version>0.0.1</version>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>2.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp-urlconnection</artifactId>
<version>2.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>1.4.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.4.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.android.tools.build</groupId>
<artifactId>gradle</artifactId>
<version>7.0.3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.aliyun.dpa</groupId>
<artifactId>oss-android-sdk</artifactId>
<version>2.9.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.10.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>1.4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<version>1.4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
43c08d3095add737d015d050658ff4e1
\ No newline at end of file
95bcbe688c42b27c82b6df4735a545c69569155f
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>ccom.qmai.android.plugin</groupId>
<artifactId>CpPluginPlugin</artifactId>
<versioning>
<release>0.0.1</release>
<versions>
<version>0.0.1</version>
</versions>
<lastUpdated>20230626082952</lastUpdated>
</versioning>
</metadata>
d4f47a6de462d70ff82648bed3861f59
\ No newline at end of file
2fc9d6c210e76962adde118a0c770e2545b2de85
\ No newline at end of file
fdeee701682d36a45a9254d7c938a3ee
\ No newline at end of file
2512bd438049f35aeba0edbe85af038a09df266c
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>ccom.qmai.android.plugin</groupId>
<artifactId>GradlePlugin</artifactId>
<version>0.0.1</version>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>2.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp-urlconnection</artifactId>
<version>2.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>1.4.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.4.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.android.tools.build</groupId>
<artifactId>gradle</artifactId>
<version>7.0.3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.aliyun.dpa</groupId>
<artifactId>oss-android-sdk</artifactId>
<version>2.9.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.10.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>1.4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<version>1.4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
1f67da6cf227373f6e83535ff5d89a6e
\ No newline at end of file
139ae764d00ae40f5a6e1f1fc3d83832e66b27cd
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>ccom.qmai.android.plugin</groupId>
<artifactId>GradlePlugin</artifactId>
<versioning>
<release>0.0.1</release>
<versions>
<version>0.0.1</version>
</versions>
<lastUpdated>20230626083048</lastUpdated>
</versioning>
</metadata>
b74d8a9877e85e4ba8125e93b9744291
\ No newline at end of file
73a003e0dab8c731a8dfc4a1a020d85cb1f7da32
\ No newline at end of file
fdeee701682d36a45a9254d7c938a3ee
\ No newline at end of file
2512bd438049f35aeba0edbe85af038a09df266c
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.qmai.android.plugin</groupId>
<artifactId>GradlePlugin</artifactId>
<version>0.0.1</version>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>2.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp-urlconnection</artifactId>
<version>2.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>1.4.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.4.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.android.tools.build</groupId>
<artifactId>gradle</artifactId>
<version>7.0.3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.aliyun.dpa</groupId>
<artifactId>oss-android-sdk</artifactId>
<version>2.9.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.10.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>1.4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<version>1.4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
01a77af9a7c103dba87ebe4aeb24be45
\ No newline at end of file
73eaf5b04c446f2a42e13802e0a6cd7f2ba605ec
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.qmai.android.plugin</groupId>
<artifactId>GradlePlugin</artifactId>
<versioning>
<release>0.0.1</release>
<versions>
<version>0.0.1</version>
</versions>
<lastUpdated>20230626083106</lastUpdated>
</versioning>
</metadata>
8740223dff24f8f8979491a09c64c467
\ No newline at end of file
d31c586b2bdcc27c9ac99ae914af14cd2ef2b087
\ No newline at end of file
fdeee701682d36a45a9254d7c938a3ee
\ No newline at end of file
2512bd438049f35aeba0edbe85af038a09df266c
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com1.qmai.android.plugin</groupId>
<artifactId>GradlePlugin</artifactId>
<version>0.0.1</version>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>2.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp-urlconnection</artifactId>
<version>2.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>1.4.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.4.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.android.tools.build</groupId>
<artifactId>gradle</artifactId>
<version>7.0.3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.aliyun.dpa</groupId>
<artifactId>oss-android-sdk</artifactId>
<version>2.9.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.10.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>1.4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<version>1.4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
1d84ebd5287a1eb9cc32bdaa8d631bce
\ No newline at end of file
831603166664be96c282c8da27da82be5f4f47d5
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com1.qmai.android.plugin</groupId>
<artifactId>GradlePlugin</artifactId>
<versioning>
<release>0.0.1</release>
<versions>
<version>0.0.1</version>
</versions>
<lastUpdated>20230626083432</lastUpdated>
</versioning>
</metadata>
70c89a7e779809570b6388b0dae6b3a3
\ No newline at end of file
772f160a9dcfa9d529055a73557b4a5438acacc1
\ No newline at end of file
package com.qmai.android.plugin;
import java.io.Serializable;
class OssParamsBean implements Serializable {
String app_oss_endpoint ;
String app_oss_accessKeyId ;
String app_oss_accessKeySecret ;
String app_oss_path ;
String app_oss_bucketName;
@Override
public String toString() {
return "OssParamsBean{" +
"app_oss_endpoint='" + app_oss_endpoint + '\'' +
", app_oss_accessKeyId='" + app_oss_accessKeyId + '\'' +
", app_oss_accessKeySecret='" + app_oss_accessKeySecret + '\'' +
", app_oss_path='" + app_oss_path + '\'' +
", app_oss_bucketName='" + app_oss_bucketName + '\'' +
'}';
}
}
......@@ -4,6 +4,7 @@ package com.qmai.android.plugin
import com.aliyun.oss.OSS
import com.aliyun.oss.OSSClientBuilder
import com.aliyun.oss.model.PutObjectRequest
import com.android.tools.r8.internal.S
import com.google.gson.Gson
import okhttp3.MediaType
import okhttp3.OkHttpClient
......@@ -43,13 +44,14 @@ class OssUploadTask extends DefaultTask {
@TaskAction
void upload() {
println("-----------开始上传了")
OssParamsBean ossParamsBean = getOssInfo()
println("-----------开始上传了 ")
def fileName = file.getName()
// yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。
String endpoint = "https://oss-cn-shanghai.aliyuncs.com"
String endpoint = ossParamsBean.app_oss_endpoint
// 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
String accessKeyId = "LTAI5t8xR8NRFcxCXhj31FkU"
String accessKeySecret = "GaoC3mqQCz9rX9q8rtBQuEaXZOYn4g"
String accessKeyId = ossParamsBean.app_oss_accessKeyId
String accessKeySecret = ossParamsBean.app_oss_accessKeySecret
// 创建OSSClient实例。
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret)
......@@ -63,20 +65,21 @@ class OssUploadTask extends DefaultTask {
// metadata.setObjectAcl(CannedAccessControlList.Private);
// putObjectRequest.setMetadata(metadata);
String ossPath = ossParamsBean.app_oss_path
String bucketName = ossParamsBean.app_oss_bucketName
// 上传文件。
try {
println("file name= " + file.name)
println("file path= " + file.absolutePath + " " + file.getCanonicalPath())
println("file access= " + file.canRead())
println("begin upload " + file.exists())
PutObjectRequest putObjectRequest = new PutObjectRequest("qmaicn", ossPath + fileName, file)
// println("begin upload " + file.exists())
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, ossPath + fileName, file)
ossClient.putObject(putObjectRequest)
println("--------------------------------------------------------------------------")
println("---------" + fileName + "--------上传完成")
println("下载地址为: " + "https://files.qmai.cn/" + ossPath + fileName)
println("--------------------------------------------------------------------------")
} catch (Exception e) {
println("uploadOssError= " + e.getMessage() + "E" + e)
println("上传失败: " + e.getMessage() + "E" + e)
}
// 关闭OSSClient。
ossClient.shutdown()
......@@ -147,4 +150,15 @@ class OssUploadTask extends DefaultTask {
return ""
}
@Input
OssParamsBean getOssInfo(){
OssParamsBean ossParamsBean = new OssParamsBean()
Map<String,String> params = System.getenv()
ossParamsBean.app_oss_endpoint = params.get("app_oss_endpoint")
ossParamsBean.app_oss_accessKeyId = params.get("app_oss_accessKeyId")
ossParamsBean.app_oss_accessKeySecret = params.get("app_oss_accessKeySecret")
ossParamsBean.app_oss_path = params.get("app_oss_path")
ossParamsBean.app_oss_bucketName = params.get("app_oss_bucketName")
return ossParamsBean
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment