├── Jenkinsfile
├── images
├── setting-screenshot.png
├── pgyer-app-upload-backdata.png
└── pgyer-app-upload-running-log.png
├── .gitignore
├── src
├── main
│ ├── resources
│ │ ├── index.jelly
│ │ └── ren
│ │ │ └── helloworld
│ │ │ └── upload2pgyer
│ │ │ ├── UploadBuilderV2
│ │ │ ├── help-buildType.html
│ │ │ ├── help-buildUpdateDescription.html
│ │ │ ├── help.html
│ │ │ ├── help-buildInstallType.html
│ │ │ ├── help-buildChannelShortcut.html
│ │ │ ├── help-buildPassword.html
│ │ │ ├── help-apiKey.html
│ │ │ ├── help-wildcard.html
│ │ │ ├── help-scanDir.html
│ │ │ └── config.jelly
│ │ │ └── UploadPublisherV2
│ │ │ ├── help-buildType.html
│ │ │ ├── help-buildUpdateDescription.html
│ │ │ ├── help.html
│ │ │ ├── help-buildChannelShortcut.html
│ │ │ ├── help-buildInstallType.html
│ │ │ ├── help-buildPassword.html
│ │ │ ├── help-apiKey.html
│ │ │ ├── help-wildcard.html
│ │ │ ├── help-scanDir.html
│ │ │ └── config.jelly
│ └── java
│ │ └── ren
│ │ └── helloworld
│ │ └── upload2pgyer
│ │ ├── impl
│ │ └── Message.java
│ │ ├── helper
│ │ ├── PublishEnvVarAction.java
│ │ ├── ProgressRequestBody.java
│ │ ├── PgyerV2Helper.java
│ │ └── CommonUtil.java
│ │ ├── apiv2
│ │ ├── ParamsBeanV2.java
│ │ ├── PgyerTokenBeanV2.java
│ │ ├── PgyerBeanV2.java
│ │ └── PgyerUploadV2.java
│ │ ├── ValidationParameters.java
│ │ ├── UploadBuilderV2.java
│ │ └── UploadPublisherV2.java
└── test
│ └── java
│ └── ren
│ └── helloworld
│ └── upload2pgyer
│ ├── UploadBuilderV2Test.java
│ └── UploadPublisherV2Test.java
├── pom.xml
├── README_cn.md
└── README.md
/Jenkinsfile:
--------------------------------------------------------------------------------
1 | buildPlugin()
--------------------------------------------------------------------------------
/images/setting-screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/upload-pgyer-plugin/HEAD/images/setting-screenshot.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | .idea
3 | target
4 | *.iml
5 | pom.xml.releaseBackup
6 | release.properties
--------------------------------------------------------------------------------
/images/pgyer-app-upload-backdata.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/upload-pgyer-plugin/HEAD/images/pgyer-app-upload-backdata.png
--------------------------------------------------------------------------------
/images/pgyer-app-upload-running-log.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/upload-pgyer-plugin/HEAD/images/pgyer-app-upload-running-log.png
--------------------------------------------------------------------------------
/src/main/resources/index.jelly:
--------------------------------------------------------------------------------
1 |
2 |
3 | This plug-in upload the apk/ipa file to pgyer
4 |
5 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadBuilderV2/help-buildType.html:
--------------------------------------------------------------------------------
1 |
2 | (Optional) App Type is android or ios
3 |
4 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadPublisherV2/help-buildType.html:
--------------------------------------------------------------------------------
1 |
2 | (Optional) App Type is android or ios
3 |
4 |
--------------------------------------------------------------------------------
/src/main/java/ren/helloworld/upload2pgyer/impl/Message.java:
--------------------------------------------------------------------------------
1 | package ren.helloworld.upload2pgyer.impl;
2 |
3 | public interface Message {
4 | void message(boolean needTag, String mesage);
5 | }
6 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadBuilderV2/help-buildUpdateDescription.html:
--------------------------------------------------------------------------------
1 |
2 | (Optional) Version updated description, please pass on an empty string or do not pass anything.
3 |
4 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadPublisherV2/help-buildUpdateDescription.html:
--------------------------------------------------------------------------------
1 |
2 | (Optional) Version updated description, please pass on an empty string or do not pass anything.
3 |
4 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadBuilderV2/help.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadPublisherV2/help.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadBuilderV2/help-buildInstallType.html:
--------------------------------------------------------------------------------
1 |
2 | (Optional)Type of Install, this value is (1,2,3).
3 | 1:Public,
4 | 2:Password,
5 | 3:Restrict.
6 | The default is Public!
7 |
8 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadBuilderV2/help-buildChannelShortcut.html:
--------------------------------------------------------------------------------
1 |
2 | (Optional) The download short link of the specified channel that needs to be updated.
3 | Only one channel can be specified, string type, such as: abcd.
4 |
5 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadPublisherV2/help-buildChannelShortcut.html:
--------------------------------------------------------------------------------
1 |
2 | (Optional) The download short link of the specified channel that needs to be updated.
3 | Only one channel can be specified, string type, such as: abcd.
4 |
5 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadPublisherV2/help-buildInstallType.html:
--------------------------------------------------------------------------------
1 |
2 | (Optional)Type of Install, this value is (1,2,3).
3 | 1:Public,
4 | 2:Password,
5 | 3:Restrict.
6 | The default is Public!
7 |
8 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadBuilderV2/help-buildPassword.html:
--------------------------------------------------------------------------------
1 |
2 | To be safe, the field needs to be encrypted, so it looks that long.
3 | (Optional) Setting App installation password.
4 | If you do not want to set a password, please pass on an empty string or do not pass anything.
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadPublisherV2/help-buildPassword.html:
--------------------------------------------------------------------------------
1 |
2 | To be safe, the field needs to be encrypted, so it looks that long.
3 | (Optional) Setting App installation password.
4 | If you do not want to set a password, please pass on an empty string or do not pass anything.
5 |
6 |
--------------------------------------------------------------------------------
/src/test/java/ren/helloworld/upload2pgyer/UploadBuilderV2Test.java:
--------------------------------------------------------------------------------
1 | package ren.helloworld.upload2pgyer;
2 |
3 | import org.junit.Rule;
4 | import org.junit.Test;
5 | import org.jvnet.hudson.test.JenkinsRule;
6 |
7 | import static org.junit.Assert.assertTrue;
8 |
9 | public class UploadBuilderV2Test {
10 | @Rule
11 | public JenkinsRule j = new JenkinsRule();
12 |
13 | @Test
14 | public void test() {
15 | assertTrue(true);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/test/java/ren/helloworld/upload2pgyer/UploadPublisherV2Test.java:
--------------------------------------------------------------------------------
1 | package ren.helloworld.upload2pgyer;
2 |
3 | import org.junit.Rule;
4 | import org.junit.Test;
5 | import org.jvnet.hudson.test.JenkinsRule;
6 |
7 | import static org.junit.Assert.assertTrue;
8 |
9 | public class UploadPublisherV2Test {
10 | @Rule
11 | public JenkinsRule j = new JenkinsRule();
12 |
13 | @Test
14 | public void test() {
15 | assertTrue(true);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadBuilderV2/help-apiKey.html:
--------------------------------------------------------------------------------
1 |
2 |
To be safe, the field needs to be encrypted, so it looks that long.
3 | (Required) API Key, used to identify the identity of the API caller,
4 | if not specified, each interface needs to contain this parameter.
5 | For the same pgyer registered users, this value is fixed.
6 |
Click to get pgyer api_key
7 |
8 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadPublisherV2/help-apiKey.html:
--------------------------------------------------------------------------------
1 |
2 |
To be safe, the field needs to be encrypted, so it looks that long.
3 | (Required) API Key, used to identify the identity of the API caller,
4 | if not specified, each interface needs to contain this parameter.
5 | For the same pgyer registered users, this value is fixed.
6 |
Click to get pgyer api_key
7 |
8 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadBuilderV2/help-wildcard.html:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadPublisherV2/help-wildcard.html:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadBuilderV2/help-scanDir.html:
--------------------------------------------------------------------------------
1 |
2 | (Required) need to upload ipa or apk file base dir path!
3 | The default is ${WORKSPACE}, It means the path of the current project!
4 | It is using ant's DirectoryScanner class,
click to see DirectoryScanner class
7 | It is equivalent to the parameters of the basedir method in the DirectoryScanner class!
click to see basedir method
10 |
11 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadPublisherV2/help-scanDir.html:
--------------------------------------------------------------------------------
1 |
2 | (Required) need to upload ipa or apk file base dir path!
3 | The default is ${WORKSPACE}, It means the path of the current project!
4 | It is using ant's DirectoryScanner class,
click to see DirectoryScanner class
7 | It is equivalent to the parameters of the basedir method in the DirectoryScanner class!
click to see basedir method
10 |
11 |
--------------------------------------------------------------------------------
/src/main/java/ren/helloworld/upload2pgyer/helper/PublishEnvVarAction.java:
--------------------------------------------------------------------------------
1 | package ren.helloworld.upload2pgyer.helper;
2 |
3 | import hudson.EnvVars;
4 | import hudson.model.AbstractBuild;
5 | import hudson.model.EnvironmentContributingAction;
6 | import hudson.model.InvisibleAction;
7 |
8 | public class PublishEnvVarAction extends InvisibleAction implements EnvironmentContributingAction {
9 | /**
10 | * The environment variable key.
11 | */
12 | private final String key;
13 |
14 | /**
15 | * The environment variable value.
16 | */
17 | private final String value;
18 |
19 | /**
20 | * Constructor.
21 | *
22 | * @param key the environment variable key
23 | * @param value the environment variable value
24 | */
25 | public PublishEnvVarAction(String key, String value) {
26 | this.key = key;
27 | this.value = value;
28 | }
29 |
30 | /* (non-Javadoc)
31 | * @see hudson.model.EnvironmentContributingAction#buildEnvVars(hudson.model.AbstractBuild, hudson.EnvVars)
32 | */
33 | public void buildEnvVars(AbstractBuild, ?> build, EnvVars env) {
34 | env.put(key, value);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadPublisherV2/config.jelly:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/src/main/resources/ren/helloworld/upload2pgyer/UploadBuilderV2/config.jelly:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/src/main/java/ren/helloworld/upload2pgyer/helper/ProgressRequestBody.java:
--------------------------------------------------------------------------------
1 | package ren.helloworld.upload2pgyer.helper;
2 |
3 | import okhttp3.MediaType;
4 | import okhttp3.RequestBody;
5 | import okio.*;
6 |
7 | import java.io.IOException;
8 |
9 | public class ProgressRequestBody extends RequestBody {
10 |
11 | protected Listener listener;
12 | protected RequestBody delegate;
13 | protected CountingSink countingSink;
14 |
15 | public ProgressRequestBody(RequestBody delegate, Listener listener) {
16 | this.delegate = delegate;
17 | this.listener = listener;
18 | }
19 |
20 | @Override
21 | public MediaType contentType() {
22 | return delegate.contentType();
23 | }
24 |
25 | @Override
26 | public long contentLength() {
27 | try {
28 | return delegate.contentLength();
29 | } catch (IOException e) {
30 | e.printStackTrace();
31 | }
32 | return -1;
33 | }
34 |
35 | @Override
36 | public void writeTo(BufferedSink sink) throws IOException {
37 | countingSink = new CountingSink(sink);
38 | BufferedSink bufferedSink = Okio.buffer(countingSink);
39 | delegate.writeTo(bufferedSink);
40 | bufferedSink.flush();
41 | }
42 |
43 | protected final class CountingSink extends ForwardingSink {
44 |
45 | private long bytesWritten = 0;
46 |
47 | public CountingSink(Sink delegate) {
48 | super(delegate);
49 | }
50 |
51 | @Override
52 | public void write(Buffer source, long byteCount) throws IOException {
53 | super.write(source, byteCount);
54 |
55 | bytesWritten += byteCount;
56 | if(listener != null){
57 | listener.onRequestProgress(bytesWritten, contentLength());
58 | }
59 | }
60 | }
61 |
62 | public interface Listener {
63 | void onRequestProgress(long bytesWritten, long contentLength);
64 | }
65 | }
--------------------------------------------------------------------------------
/src/main/java/ren/helloworld/upload2pgyer/apiv2/ParamsBeanV2.java:
--------------------------------------------------------------------------------
1 | package ren.helloworld.upload2pgyer.apiv2;
2 |
3 | public class ParamsBeanV2 {
4 | private String apiKey;
5 | // file start
6 | private String scandir;
7 | private String wildcard;
8 | private String uploadFile;
9 | // file end
10 | private String buildInstallType;
11 | private String buildPassword;
12 | private String buildUpdateDescription;
13 | private String buildType;
14 | private String buildChannelShortcut;
15 |
16 |
17 | public String getApiKey() {
18 | return apiKey;
19 | }
20 |
21 | public void setApiKey(String apiKey) {
22 | this.apiKey = apiKey;
23 | }
24 |
25 | public String getScandir() {
26 | return scandir;
27 | }
28 |
29 | public void setScandir(String scandir) {
30 | this.scandir = scandir;
31 | }
32 |
33 | public String getWildcard() {
34 | return wildcard;
35 | }
36 |
37 | public void setWildcard(String wildcard) {
38 | this.wildcard = wildcard;
39 | }
40 |
41 | public String getUploadFile() {
42 | return uploadFile;
43 | }
44 |
45 | public void setUploadFile(String uploadFile) {
46 | this.uploadFile = uploadFile;
47 | }
48 |
49 | public String getBuildInstallType() {
50 | return buildInstallType;
51 | }
52 |
53 | public void setBuildInstallType(String buildInstallType) {
54 | this.buildInstallType = buildInstallType;
55 | }
56 |
57 | public String getBuildPassword() {
58 | return buildPassword;
59 | }
60 |
61 | public void setBuildPassword(String buildPassword) {
62 | this.buildPassword = buildPassword;
63 | }
64 |
65 | public String getBuildType() {
66 | return buildType;
67 | }
68 |
69 | public void setBuildType(String buildType) {
70 | this.buildType = buildType;
71 | }
72 |
73 | public String getBuildUpdateDescription() {
74 | return buildUpdateDescription;
75 | }
76 |
77 | public void setBuildUpdateDescription(String buildUpdateDescription) {
78 | this.buildUpdateDescription = buildUpdateDescription;
79 | }
80 |
81 | public String getBuildChannelShortcut() {
82 | return buildChannelShortcut;
83 | }
84 |
85 | public void setBuildChannelShortcut(String buildChannelShortcut) {
86 | this.buildChannelShortcut = buildChannelShortcut;
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/src/main/java/ren/helloworld/upload2pgyer/apiv2/PgyerTokenBeanV2.java:
--------------------------------------------------------------------------------
1 | package ren.helloworld.upload2pgyer.apiv2;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | public class PgyerTokenBeanV2 {
6 |
7 | private int code;
8 | private String message;
9 | private DataBean data;
10 |
11 | public int getCode() {
12 | return code;
13 | }
14 |
15 | public void setCode(int code) {
16 | this.code = code;
17 | }
18 |
19 | public String getMessage() {
20 | return message;
21 | }
22 |
23 | public void setMessage(String message) {
24 | this.message = message;
25 | }
26 |
27 | public DataBean getData() {
28 | return data;
29 | }
30 |
31 | public void setData(DataBean data) {
32 | this.data = data;
33 | }
34 |
35 | public static class DataBean {
36 |
37 | private String key;
38 | private String endpoint;
39 | private Params params;
40 |
41 | public String getKey() {
42 | return key;
43 | }
44 |
45 | public void setKey(String key) {
46 | this.key = key;
47 | }
48 |
49 | public String getEndpoint() {
50 | return endpoint;
51 | }
52 |
53 | public void setEndpoint(String endpoint) {
54 | this.endpoint = endpoint;
55 | }
56 |
57 | public Params getParams() {
58 | return params;
59 | }
60 |
61 | public void setParams(Params params) {
62 | this.params = params;
63 | }
64 | }
65 |
66 | public static class Params {
67 | private String key;
68 | private String signature;
69 | @SerializedName("x-cos-security-token")
70 | private String x_cos_security_token;
71 |
72 | public String getKey() {
73 | return key;
74 | }
75 |
76 | public void setKey(String key) {
77 | this.key = key;
78 | }
79 |
80 | public String getSignature() {
81 | return signature;
82 | }
83 |
84 | public void setSignature(String signature) {
85 | this.signature = signature;
86 | }
87 |
88 | public String getX_cos_security_token() {
89 | return x_cos_security_token;
90 | }
91 |
92 | public void setX_cos_security_token(String x_cos_security_token) {
93 | this.x_cos_security_token = x_cos_security_token;
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/ren/helloworld/upload2pgyer/ValidationParameters.java:
--------------------------------------------------------------------------------
1 | package ren.helloworld.upload2pgyer;
2 |
3 | import hudson.util.FormValidation;
4 |
5 | class ValidationParameters {
6 |
7 | public static FormValidation doCheckApiKey(String value) {
8 | if (value.length() == 0) {
9 | return FormValidation.error("Please set a api_key");
10 | }
11 | return FormValidation.ok();
12 | }
13 |
14 | public static FormValidation doCheckScanDir(String value) {
15 | if (value.length() == 0) {
16 | return FormValidation.error("Please set upload ipa or apk file base dir name");
17 | }
18 | return FormValidation.ok();
19 | }
20 |
21 | public static FormValidation doCheckWildcard(String value) {
22 | if (value.length() == 0) {
23 | return FormValidation.error("Please set upload ipa or apk file wildcard");
24 | }
25 | return FormValidation.ok();
26 | }
27 |
28 | public static FormValidation doCheckBuildType(String value) {
29 | if (value.length() == 0) {
30 | return FormValidation.error("Please set upload ipa or apk file buildType");
31 | }
32 | return FormValidation.ok();
33 | }
34 |
35 | public static FormValidation doCheckInstallType(String value) {
36 | try {
37 | int valueInt = Integer.parseInt(value);
38 | if (valueInt < 1 || valueInt > 3) {
39 | return FormValidation.error("application installation, the value is (1,2,3).");
40 | }
41 | return FormValidation.ok();
42 | } catch (Exception e) {
43 | return FormValidation.error("application installation, must be number, the value is (1,2,3).");
44 | }
45 | }
46 |
47 | public static FormValidation doCheckPassword(String installType, String value) {
48 | if (!installType.equals(String.valueOf(2))) {
49 | if (value.length() == 0) {
50 | return FormValidation.ok();
51 | }
52 | return FormValidation.warning("The value of installType is not 2, so the password will be ignored");
53 | } else {
54 | if (value.length() == 0) {
55 | return FormValidation.error("Please set a password");
56 | }
57 | if (value.length() < 6) {
58 | return FormValidation.warning("Isn't the password too short?");
59 | }
60 | return FormValidation.ok();
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | 8
7 | 2.277.1
8 |
9 |
10 |
11 | org.jenkins-ci.plugins
12 | plugin
13 | 4.4
14 |
15 |
16 |
17 | ren.helloworld
18 | upload-pgyer
19 | 2.2-SNAPSHOT
20 | hpi
21 | Upload to pgyer
22 | Upload to pgyer for jenkins plugin
23 |
24 | https://github.com/jenkinsci/upload-pgyer-plugin/blob/master/README.md
25 |
26 |
27 |
28 | MIT License
29 | http://opensource.org/licenses/MIT
30 | repo
31 |
32 |
33 |
34 |
35 |
36 | myroid
37 | fan yang
38 | myroid@foxmail.com
39 | https://iamfan.net
40 |
41 |
42 |
43 | manongxiaoyun
44 | xiaoyun
45 | 562007588@qq.com
46 |
47 |
48 |
49 |
50 |
51 | repo.jenkins-ci.org
52 | https://repo.jenkins-ci.org/public/
53 |
54 |
55 |
56 |
57 |
58 | repo.jenkins-ci.org
59 | https://repo.jenkins-ci.org/public/
60 |
61 |
62 |
63 |
64 |
65 | org.jenkins-ci.plugins
66 | structs
67 | 1.20
68 |
69 |
70 |
71 | org.apache.ant
72 | ant
73 | 1.10.12
74 |
75 |
76 |
77 | com.google.code.gson
78 | gson
79 | 2.9.0
80 |
81 |
82 |
83 | com.squareup.okhttp3
84 | okhttp-urlconnection
85 | 4.10.0
86 |
87 |
88 | org.jetbrains.kotlin
89 | kotlin-stdlib-common
90 |
91 |
92 |
93 |
94 |
95 |
96 | scm:git:ssh://github.com/jenkinsci/upload-pgyer-plugin.git
97 | scm:git:ssh://git@github.com/jenkinsci/upload-pgyer-plugin.git
98 | https://github.com/jenkinsci/upload-pgyer-plugin
99 | HEAD
100 |
101 |
102 |
--------------------------------------------------------------------------------
/README_cn.md:
--------------------------------------------------------------------------------
1 | [](http://opensource.org/licenses/MIT)
2 | 
3 | 
4 |
5 | ### 简单介绍
6 |
7 | [蒲公英官网文档](https://www.pgyer.com/doc/view/jenkins_plugin)
8 |
9 | 蒲公英平台可以让开发者和企业将应用上传到网站,生成安装链接和二维码用户在手机上打开安装链接,或扫码二维码,即可开始安装!
10 |
11 | 因此,这款upload-pgyer的Jenkins插件可以让开发者将apk/ipa文件上传到蒲公英平台!**并且这款插件可以将蒲公英平台返回的应用信息解析后注入到Jenkins的全局变量中,这样你就可以很方便的在其他构建步骤中使用这些返回的信息**。
12 |
13 | ### 安装插件
14 |
15 | - 推荐的安装方式
16 |
17 | `Manage Jenkins` -> `Manage Plugins` -> `Available` -> `Search ` -> *输入* `Upload to pgyer` -> `install`
18 |
19 | - 备用的安装方式
20 |
21 | 1. 点击 [这里](https://updates.jenkins-ci.org/latest/upload-pgyer.hpi) 下载最新的版本
22 |
23 | 2. `Manage Jenkins` -> `Manage Plugins` -> `Advanced` -> `Upload Plugin` -> `Choose file` -> *选择刚才下载的* `upload-pgyer.hpi` -> `Upload`
24 |
25 | ### 构建参数
26 |
27 | 在2.1版本中删除了两个构建参数,分别是`isUploadPgyer`和`uploadPgyerTimeout`,将构建参数`buildName`更改为`buildType`并且`buildType`为必填项
28 | ### 使用指南
29 |
30 | 你可以在Jenkins的job配置页面的`构建`和`构建后操作`这两个操作中点击添加构建步骤选择`upload to pgyer with apiV2`。然后你就可以看到类似下面图片的操作界面:
31 |
32 |
33 | 
34 |
35 | ### 参数介绍
36 | 需要填写的字段|字段的解释
37 | ----:|:----------
38 | pgyer api_key|(必填) API Key,用来识别API调用者的身份,
如不特别说明,每个接口中都需要含有此参数。
对于同一个蒲公英的注册用户来说,这个值在固定的。
[点击获取_api_key](https://www.pgyer.com/account/api)
39 | scandir|`(必填)` 需要上传的apk/ipa文件所在的文件夹或者父文件夹,
当前默认路径是`${WORKSPACE}`,它代表了当前项目的绝对路径。
这个功能的实现使用了ant框架的DirectoryScanner类,[点击查看DirectoryScanner类](https://ant.apache.org/manual/api/org/apache/tools/ant/DirectoryScanner.html),
这个字段就是DirectoryScanner类中的basedir方法的参数[点击查看basedir方法](https://ant.apache.org/manual/api/org/apache/tools/ant/DirectoryScanner.html#basedir)
40 | file wildcard|`(必填)` 需要上传的apk/ipa文件的名字,支持通配符,
就像这样: \*\*/\*.apk
或者像这样: \*\*/Test?/\*_sign.apk,
这个功能的实现使用了ant框架的DirectoryScanner类,[点击查看DirectoryScanner类](https://ant.apache.org/manual/api/org/apache/tools/ant/DirectoryScanner.html),
这个字段就是DirectoryScanner类中的includes方法的参数,[点击查看includes方法](https://ant.apache.org/manual/api/org/apache/tools/ant/DirectoryScanner.html#includes)
41 | buildType|`(必填)` 需要上传应用程序类型,支持,
如: android
如: ios
默认值是: android
42 | installType|`(选填)` 应用安装方式,值为(1,2,3)。
1:公开,2:密码安装,3:邀请安装。
默认为1公开
43 | password|`(选填)` 设置App安装密码,如果不想设置密码,请传空字符串,或不传。
44 | updateDescription|`(选填)` 版本更新描述,请传空字符串,或不传。
45 | channelShortcut|`(选填)` 所需更新的指定渠道的下载短链接,只可指定一个渠道,字符串型,如:abcd
46 |
47 | ### 运行截图
48 | 
49 |
50 | 当你的应用上传成功后,在Jenkins中你就能看到上面图片中的信息。同时,你就可以在其他构建步骤中使用蒲公英返回来的信息,例如我的经验:
51 |
52 | 
53 |
54 | ### Change Log
55 |
56 | 版本 2.1(2022-10-26)
57 | - **最低兼容Jenkins: [2.277.1](http://mirrors.jenkins.io/war-stable/2.277.1)**
58 | - 移除apiv1的相关配置
59 | - 删除' isUploadPgyer '构建参数
60 | - 删除' uploadPgyerTimeout '构建参数
61 | - 删除' buildName '构建参数
62 | - 添加' buildType '构建参数(必填项)
63 | - api变化
64 | - 升级Gson 2.9.0
65 | - 升级OkHttp3 4.10.0
66 | - 优化代码以提高稳定性
67 |
68 |
69 | 版本 1.34(2020-08-15)
70 |
71 | - **最低兼容Jenkins: [2.164.1](http://mirrors.jenkins.io/war-stable/2.164.1)**
72 | - 添加 `isUploadPgyer` 构建参数
73 | - 添加 `uploadPgyerTimeout` 构建参数
74 | - 升级蒲公英API,添加 `channelShortcut` 参数
75 | - `installType` 默认值设置为1
76 | - 优化参数校验
77 | - 升级Gson 2.8.6
78 | - 升级Ant 1.10.8
79 | - 升级OkHttp3 3.14.9
80 | - 优化代码,提升稳定性
81 |
82 | 版本 1.33(2019-09-07)
83 |
84 | - 修复[SECURITY-1044](https://issues.jenkins-ci.org/browse/SECURITY-1044)
85 | - 升级Gson 2.8.5
86 |
87 | 版本 1.31(2018-05-07)
88 |
89 | - 升级Gson 2.8.4
90 | - 优化上传日志
91 | - 更换readme.md图片地址
92 |
93 | 版本 1.30(2018-04-16)
94 |
95 | - 移除Jsoup,并引入okhttp作为网络库
96 | - 增加文件上传进度
97 | - 增加蒲公英[APIV2](https://www.pgyer.com/doc/view/api#uploadApp)
--------------------------------------------------------------------------------
/src/main/java/ren/helloworld/upload2pgyer/helper/PgyerV2Helper.java:
--------------------------------------------------------------------------------
1 | package ren.helloworld.upload2pgyer.helper;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.reflect.TypeToken;
5 | import hudson.model.AbstractBuild;
6 | import hudson.model.BuildListener;
7 | import ren.helloworld.upload2pgyer.apiv2.ParamsBeanV2;
8 | import ren.helloworld.upload2pgyer.apiv2.PgyerBeanV2;
9 | import ren.helloworld.upload2pgyer.apiv2.PgyerUploadV2;
10 | import ren.helloworld.upload2pgyer.impl.Message;
11 |
12 | import java.io.IOException;
13 | import java.util.Map;
14 |
15 | public class PgyerV2Helper {
16 | /**
17 | * @param build build
18 | * @param listener listener
19 | * @param paramsBeanV2 uploadBean
20 | * @return success or failure
21 | * @throws IOException IOException
22 | * @throws InterruptedException InterruptedException
23 | */
24 | public static boolean upload(AbstractBuild, ?> build, final BuildListener listener, ParamsBeanV2 paramsBeanV2) throws IOException, InterruptedException {
25 | Message message = new Message() {
26 | @Override
27 | public void message(boolean needTag, String mesage) {
28 | listener.getLogger().println((needTag ? CommonUtil.LOG_PREFIX : "") + mesage);
29 | }
30 | };
31 |
32 | if (CommonUtil.isBuildFailed(build, message)) {
33 | return true;
34 | }
35 |
36 | if (CommonUtil.isSkipUpload(build.getEnvironment(listener), message)) {
37 | return true;
38 | }
39 |
40 | // expand params
41 | paramsBeanV2.setApiKey(build.getEnvironment(listener).expand(paramsBeanV2.getApiKey()));
42 | paramsBeanV2.setScandir(build.getEnvironment(listener).expand(paramsBeanV2.getScandir()));
43 | paramsBeanV2.setWildcard(build.getEnvironment(listener).expand(paramsBeanV2.getWildcard()));
44 | paramsBeanV2.setBuildPassword(build.getEnvironment(listener).expand(paramsBeanV2.getBuildPassword()));
45 | paramsBeanV2.setBuildInstallType(build.getEnvironment(listener).expand(paramsBeanV2.getBuildInstallType()));
46 | paramsBeanV2.setBuildUpdateDescription(build.getEnvironment(listener).expand(paramsBeanV2.getBuildUpdateDescription()));
47 | paramsBeanV2.setBuildType(build.getEnvironment(listener).expand(paramsBeanV2.getBuildType()));
48 | paramsBeanV2.setBuildChannelShortcut(build.getEnvironment(listener).expand(paramsBeanV2.getBuildChannelShortcut()));
49 |
50 | // upload
51 | PgyerBeanV2 pgyerBeanV2 = PgyerUploadV2.upload2Pgyer(build.getEnvironment(listener), true, paramsBeanV2, message);
52 | if (pgyerBeanV2 == null) {
53 | return false;
54 | }
55 |
56 | // http://jenkins-ci.361315.n4.nabble.com/Setting-an-env-var-from-a-build-step-td4657347.html
57 | message.message(true, "The Jenkins environment variable is being set.");
58 | String data = new Gson().toJson(pgyerBeanV2.getData());
59 | Map maps = new Gson().fromJson(data, new TypeToken