Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Jenkins 2.46 package apk to generate download QR code

2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

The premise of this article is that in cases where apk can already be built and successfully packaged through gradle, it only introduces uploading packaged apk using dandelion's application hosting platform (https://www.pgyer.com/) and generating QR codes in the current construction history.

1. Register the "dandelion" account, needless to say.

2. View and record API information: view it in the account settings in the upper right corner, as shown in the figure:

3, enter Jenkins to install plug-ins: description setter plugin other basic not to say, this is you can modify the description of build in order to generate QR code.

4. Set Markup Formatter to "safe html" in "system Management"-"Configure Global Security" of Jenkins, otherwise the image cannot be displayed in the description, as shown in the figure:

5. According to the "dandelion" document, you can know how to upload your application through the command line.

Curl-F "file=@/path/myapp.apk"-F "uKey=5bdxxxxx26da5xxxxxxd2d9219ba8"-F "_ api_key=0431xxxxxxxcf919be4c9f33xxxxxxxa3" https://www.pgyer.com/apiv1/app/upload

File is followed by the application of absolute path. UKey is the previously saved UserKey, and _ api_key is the previously saved API Key.

The details of the application will be returned after uploading:

{"code": 0, "message": "", "data": {"appKey": "556xxxxxx9150d94xxxxxe7", "userKey": "5bxxxxx26da5f49xxxxxd9219ba8", "appType": "2", "appIsLastest": "1", "appFileSize": "18748109", "appName": "u6xxx\ uxxx\ u9xxx\ u8bfb", "appVersion": "2.0.0.0503", "appVersionNo": "15", "appBuildVersion": "4", "appIdentifier": "com.xxxxx.xxxx", "appIcon": "xxxxxxxx319d57ce265xxxxxxd521" "appDescription": "\ n\ u624b\ u673a\ u770b\ u4e66\ u795e\ u5668\ uff0c\ u8d76\ u7d27\ u8f7d\ u6765\ u770b\ uff01\ n\ u6765\ uxxxx\ u9605\ u8bfb\ uff0c\ u8d85\ u4e07\ u7528\ u9009\ u62e9\ u4f7f\ u7528\ u9605\ u8bfbAPP\ u3002\ n\ uxxxx0\ u7528\ u6527\ u6570\ u636e\ uff0c\ u7cbe\ u51c6\ u63a8\ u8350\ u5408\ u4f60\ u53e3\ u5473\ u7684\ u7528\ u7528\ u6570\ u636e\ u7b97\ uff0c\ u7cbe\ u63a8\ u8350\ u5408\ u4f60\ u53e3\ u5473\ u7684\ u7528\ u6570\ u636e\ u7b97\ uff0c\ u7cbe\ u63a8\ u8350\ u5408\ u4f60\ u53e3\ u5473\ u7684\ u7528\ u752\ n\ uxxxx0\ u7528\ u6527\ u6570\ u636e\ uff0c\ u7cbe\ u63a8\ u8350\ u5408\ u4f60\ u53e3\ u5473\ u7684\ u7528\ u7 Uff0c\ u4ece\ u6b64\ u518d\ u4e5f\ u4e0d\ u4e66\ u8352\ uxxxx\ n\ u3010\ u4f18\ u8d28\ u5185\ u5bb9\ u3011\ n\ u8a00\ u60c5\ u3001\ u90fd\ uxxxx\ u7384\ u5e7b\ u3001\ u60ac\ u7591\ u3001\ u6050\ u6016\ u3001\ u519b\ u4e8b\ uxxxx\ u5386\ u53f2\ u3001\ u4eba\ uff0c\ u5343\ u4e07\ u4f18\ u8d28\ uxxxx\ u521b\ u5185\ u5bb9\ u6781\ u901f\ u5448. \ u795e\ u7684\ u7ecf\ u5178\ u8457\ u4f5c\ u3002\ n " "appUpdateDescription": "", "appScreenshots": "1cfe0bc3a2xxxxxxxcde894ad2d3f91b5077ecxxxxxxxx20470943No d4a40cdafcfxxxxxx0176f4e54bd26xxxxxxxf7cb1b8bdaf7dm40dd8xxxx09ffd238c2da6da6da8be8j3b0733144f4f82b47a1a14a14a19c1", "appShortcutUrl": "kigK", "appCreated": "2017-07", "appUpdated": "2017-07", "appQRCodeURL": https: / / www.pgyer.com\ / app\ qrcodeHistory / 9f838d1f85e7afb720be8adcxxxxxxxx4a5bc15d5400c3c9xxxxxx42616f} "

To protect privacy, I use xxx instead of some of the characters above, and we can see that there is an appQRCodeURL: https://xxxxx at the end.

That's right! This url is the QR code picture link returned by dandelion! You can take out the link in your own way, and then print the link to the log built by Jenkins (I'll talk about why later). I took it out with shell and awk for reference.

6. Add the post-build step "execute shell" to the configuration of job, as shown in the figure:

7. You can see that I took out the URL in three steps, and then echo it to the built log.

Curl-F "file=@/var/lib/jenkins/workspace/android_laikan/app/build/outputs/apk/app-laikan-release.apk"-F "uKey=5bxxxxxxxxxxxxxxxxxxxxxa8"-F "_ api_key=04xxxxxxxxxxxxxxxxxxxxxxba3" https://www.pgyer.com/apiv1/app/upload > / tmp/upload_app.txt

Url=$ (cat / tmp/upload_app.txt | awk-F'"'{print $(NF-1)}'| sed's #\\ # g')

Echo "download_URL:

"

The above method is for reference only, there are many ways. The final string printed to the log is similar to the following:

Download_URL:

8. Why print it to the log? Because the plug-in description setter plugin we installed above takes the string from the log through regular expression and adds it to the description of build. Let's do something about it.

9. Still in the configuration of job, adding "post-build operation"-"set build description" will not appear until the plug-in is installed. Then add to "Regular expression"

Download_URL (. *)

Compared with what is printed in the shell above, and based on the regular expression basis, we can know that what we want to filter is the printed line, and the content enclosed in parentheses is what is to be put into the build description, that is,

If you have a bit of html foundation, you can know that this is the code for inserting pictures in the web page. Since we have changed the build description to html format in step 4, the QR code will appear in the description. Let's take a look at the output:

You can see the output after the shell execution

Download_URL:

And then

Description set:

Finally, let's look at the results:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report