Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
GradlePlugin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gradle
GradlePlugin
Commits
0fb2d509
Commit
0fb2d509
authored
Oct 14, 2022
by
王雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改支持上传到oss并且飞书通知
parent
9096c81d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
138 deletions
+5
-138
build.gradle
build.gradle
+1
-1
OssUploadTask.groovy
src/main/groovy/com/qmai/android/plugin/OssUploadTask.groovy
+3
-3
PygerUploadTask.groovy
...ain/groovy/com/qmai/android/plugin/PygerUploadTask.groovy
+1
-1
PygerUploadTask2.groovy
...in/groovy/com/qmai/android/plugin/PygerUploadTask2.groovy
+0
-133
No files found.
build.gradle
View file @
0fb2d509
...
@@ -250,7 +250,7 @@ task hot{
...
@@ -250,7 +250,7 @@ task hot{
}
}
group
'com.qmai.android.plugin'
group
'com.qmai.android.plugin'
version
'1.9
1
'
version
'1.9
2
'
gradlePublish
{
gradlePublish
{
...
...
src/main/groovy/com/qmai/android/plugin/OssUploadTask.groovy
View file @
0fb2d509
...
@@ -85,16 +85,16 @@ class OssUploadTask extends DefaultTask {
...
@@ -85,16 +85,16 @@ class OssUploadTask extends DefaultTask {
.
writeTimeout
(
60
,
TimeUnit
.
SECONDS
)
.
writeTimeout
(
60
,
TimeUnit
.
SECONDS
)
.
build
()
.
build
()
Request
request2
=
new
Request
.
Builder
()
Request
request2
=
new
Request
.
Builder
()
.
url
(
"https://o
api.dingtalk.com/robot/send?access_token=9839926e22043a7d391747e3cb14cc4e0dab7add001ce60f0d184f82e50301bc
"
)
.
url
(
"https://o
pen.feishu.cn/open-apis/bot/v2/hook/64bff42a-a12a-4978-8456-ccabeb25858a
"
)
.
post
(
requestBody
)
.
post
(
requestBody
)
.
build
()
.
build
()
try
{
try
{
Response
response2
=
client
.
newCall
(
request2
).
execute
()
Response
response2
=
client
.
newCall
(
request2
).
execute
()
String
value
=
response2
.
body
().
string
()
String
value
=
response2
.
body
().
string
()
println
(
"send
dingding
response = "
+
value
)
println
(
"send
fs
response = "
+
value
)
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
println
(
"send
dingding
error = "
+
e
.
message
)
println
(
"send
fs
error = "
+
e
.
message
)
}
}
}
}
...
...
src/main/groovy/com/qmai/android/plugin/PygerUploadTask.groovy
View file @
0fb2d509
...
@@ -72,7 +72,7 @@ class PygerUploadTask extends DefaultTask {
...
@@ -72,7 +72,7 @@ class PygerUploadTask extends DefaultTask {
String
content
=
file
.
name
+
": 下载地址: "
+
" https://www.pgyer.com/"
+
String
content
=
file
.
name
+
": 下载地址: "
+
" https://www.pgyer.com/"
+
payInfoBean
.
data
.
buildShortcutUrl
+
" \n二维码地址: "
+
payInfoBean
.
data
.
buildQRCodeURL
+
" \n 当前环境: "
+
buildType
+
"\n 当前分支:"
+
branch
payInfoBean
.
data
.
buildShortcutUrl
+
" \n二维码地址: "
+
payInfoBean
.
data
.
buildQRCodeURL
+
" \n 当前环境: "
+
buildType
+
"\n 当前分支:"
+
branch
println
(
"
dingding
content = ${content}"
)
println
(
"
fs
content = ${content}"
)
MediaType
JSON
=
MediaType
.
parse
(
"application/json; charset=utf-8"
);
MediaType
JSON
=
MediaType
.
parse
(
"application/json; charset=utf-8"
);
try
{
try
{
def
fsText
=
new
FsDetailInfoModel
(
content
)
def
fsText
=
new
FsDetailInfoModel
(
content
)
...
...
src/main/groovy/com/qmai/android/plugin/PygerUploadTask2.groovy
deleted
100644 → 0
View file @
9096c81d
package
com.qmai.android.plugin
import
com.google.gson.Gson
import
okhttp3.*
import
org.gradle.api.DefaultTask
import
org.gradle.api.tasks.Input
import
org.gradle.api.tasks.OutputFile
import
org.gradle.api.tasks.TaskAction
import
org.json.JSONException
import
org.json.JSONObject
import
javax.inject.Inject
import
java.util.concurrent.TimeUnit
class
PygerUploadTask2
extends
DefaultTask
{
@OutputFile
File
file
;
@Input
String
buildType
;
@Input
String
key
;
@Inject
PygerUploadTask2
(
File
file
,
String
buildType
,
String
key
)
{
this
.
file
=
file
this
.
buildType
=
buildType
this
.
key
=
key
setGroup
(
"pyger"
)
}
@TaskAction
public
void
upload
()
{
println
(
"-------执行upload"
)
MultipartBody
.
Builder
bodyBuilder
=
new
MultipartBody
.
Builder
().
setType
(
MultipartBody
.
FORM
)
//add part
bodyBuilder
.
addFormDataPart
(
"_api_key"
,
key
)
//add file
bodyBuilder
.
addFormDataPart
(
"file"
,
file
.
getName
(),
RequestBody
.
create
(
MediaType
.
parse
(
"*/*"
),
file
))
//request
Request
request
=
new
Request
.
Builder
()
.
url
(
"https://www.pgyer.com/apiv2/app/upload"
)
.
post
(
bodyBuilder
.
build
())
.
build
()
OkHttpClient
client
=
new
OkHttpClient
.
Builder
()
.
callTimeout
(
60
,
TimeUnit
.
SECONDS
)
.
readTimeout
(
60
,
TimeUnit
.
SECONDS
)
.
connectTimeout
(
60
,
TimeUnit
.
SECONDS
)
.
writeTimeout
(
60
,
TimeUnit
.
SECONDS
)
.
build
()
try
{
println
(
"开始上传蒲公英"
)
Response
response
=
client
.
newCall
(
request
).
execute
()
String
result
=
response
.
body
().
string
()
Gson
gson
=
new
Gson
()
PygerInfoBean
payInfoBean
=
gson
.
fromJson
(
result
,
PygerInfoBean
.
class
)
println
(
"下载地址为: downloadUrl:"
+
" https://www.pgyer.com/"
+
payInfoBean
.
data
.
buildShortcutUrl
)
println
(
"二维码地址为:"
+
payInfoBean
.
data
.
buildQRCodeURL
)
System
.
out
.
println
(
"upload result: "
+
result
)
String
content
=
file
.
name
+
": 下载地址: "
+
" https://www.pgyer.com/"
+
payInfoBean
.
data
.
buildShortcutUrl
+
" \n二维码地址: "
+
payInfoBean
.
data
.
buildQRCodeURL
+
" 当前环境: "
+
buildType
+
" 当前分支: "
//+ getBranch()
MediaType
JSON
=
MediaType
.
parse
(
"application/json; charset=utf-8"
);
JSONObject
json
=
new
JSONObject
()
try
{
json
.
put
(
"msgtype"
,
"text:{\"content\":$content}"
)
json
.
put
(
"text"
,
content
)
def
dingDingdetail
=
new
FsDetailInfoModel
(
content
)
def
dingdingInfo
=
new
FsInfoModel
(
dingDingdetail
)
RequestBody
requestBody
=
RequestBody
.
create
(
JSON
,
gson
.
toJson
(
dingdingInfo
))
Request
request2
=
new
Request
.
Builder
()
.
url
(
"https://oapi.dingtalk.com/robot/send?access_token=9839926e22043a7d391747e3cb14cc4e0dab7add001ce60f0d184f82e50301bc"
)
.
post
(
requestBody
)
.
build
()
Response
response2
=
client
.
newCall
(
request2
).
execute
()
String
value
=
response2
.
body
().
string
()
println
(
"value= "
+
value
)
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
()
println
(
"-----------------上传失败----------------"
)
println
(
"错误原因: "
+
e
.
getMessage
())
}
catch
(
Exception
e
)
{
println
(
"-----------------上传失败----------------"
)
println
(
"错误原因: "
+
e
.
getMessage
())
}
}
@Input
boolean
isInJenkins
()
{
Map
<
String
,
String
>
map
=
System
.
getenv
()
if
(
map
==
null
)
{
return
false
}
String
str
=
map
.
get
(
"Path"
)
if
(
str
!=
null
)
{
//it's windows
return
false
}
else
{
str
=
""
Iterator
it
=
map
.
iterator
()
while
(
it
.
hasNext
())
{
str
+=
it
.
next
()
}
return
str
.
contains
(
"jenkins"
)
}
return
false
;
}
//获取当前分支
@Input
String
getBranch
()
{
return
""
;
if
(
isInJenkins
())
{
return
System
.
getenv
().
GIT_BRANCH
}
else
{
def
byteOut
=
new
ByteArrayOutputStream
()
project
.
exec
{
it
.
commandLine
(
"git"
,
"rev-parse"
,
"--abbrev-ref"
,
"HEAD"
)
it
.
standardOutput
=
byteOut
}
def
response
=
new
String
(
byteOut
.
toByteArray
())
return
response
}
return
response
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment