Pgyer Docs
CI/CD & Dev Tools

Upload via the Jenkins Plugin

Use the official Pgyer Jenkins plugin to upload apk, ipa and hap packages to Pgyer from Pipeline or Freestyle jobs, and get the download page and QR code.

The official Pgyer Jenkins plugin, Upload to PGYER, uploads Android (.apk), iOS (.ipa) and HarmonyOS (.hap) packages to Pgyer after your build, waits until the build is published, and shows its download page and QR code on the build page. It works in both Pipeline and Freestyle jobs: the package is uploaded from the node that built it, and the API key is kept in Jenkins credentials and never appears in the build log.

To compare the API, CLI, CI/CD plugins and other ways to upload, see Automated Uploads and CI/CD Integration.

The plugin requires Jenkins 2.479.3 or newer. If you use version 2.x of the plugin, read Upgrading from 2.x before upgrading.

Overview

Install the plugin: search for Upload to PGYER in the Jenkins plugin manager and install it.

Add your API key: store your Pgyer API key as a Jenkins "Secret text" credential.

Add the upload step: call pgyerUpload in Pipeline jobs, or add the "Upload to PGYER" build step to Freestyle jobs.

Check the result: find the download page and QR code in the build log and on the build page.

Install the plugin

  1. In Jenkins, go to Manage Jenkins → Plugins → Available plugins.
  2. Search for pgyer, select Upload to PGYER and click Install.
  3. When the installation finishes, search for pgyer under Installed plugins to check that the plugin is enabled:

The installed Upload to PGYER plugin

If Jenkins can't reach the plugin site, install the plugin manually:

  1. Download the latest upload-pgyer.hpi from the releases page.
  2. Go to Manage Jenkins → Plugins → Advanced settings, choose the downloaded file under Deploy Plugin and click Deploy.

Deploying the plugin manually

Add your API key

  1. Sign in to Pgyer and copy your API key from the API information page.
  2. In Jenkins, go to Manage Jenkins → Credentials → System → Global credentials and click Add Credentials.
  3. Set Kind to Secret text, paste the API key into Secret, set ID to pgyer-api-key (the examples on this page use this ID) and click Create.

Adding a Secret text credential

If most of your jobs use the same API key, set it as the default under Manage Jenkins → System → PGYER, so jobs don't have to choose a credential:

Setting the default API key

Don't put the API key directly in a Jenkinsfile or job configuration. Credentials are stored encrypted and masked in build logs.

Pipeline jobs

Call pgyerUpload after the build, for example:

Jenkinsfile
pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                sh './gradlew assembleRelease'
            }
        }
        stage('Distribute to PGYER') {
            steps {
                script {
                    def app = pgyerUpload file: 'app/build/outputs/apk/release/*.apk',
                                          credentialsId: 'pgyer-api-key',
                                          updateDescription: "Build #${env.BUILD_NUMBER}"
                    echo "Download page: ${app.appPgyerURL}"
                }
            }
        }
    }
}

If you write the script in Jenkins itself, paste it into Pipeline → Script in the job configuration:

Writing the Pipeline script in the job configuration

You can also generate the call with the built-in Pipeline Syntax page: click Pipeline Syntax on the job page, choose pgyerUpload: Upload a build to PGYER as the Sample Step, fill in the fields and click Generate Pipeline Script.

Generating pgyerUpload with Pipeline Syntax

Parameters

ParameterDescription
fileThe file to upload, as an Ant-style pattern relative to the workspace, such as app/build/outputs/apk/release/*.apk. When empty, any .apk, .ipa or .hap file in the workspace is used. If several files match, the most recently modified one is uploaded.
credentialsIdID of the credential holding the API key. When empty, the PGYER_API_KEY environment variable is used, then the default API key in the system settings.
buildTypeandroid, ios or harmony. Detected from the file extension; only needed when the file isn't an .apk, .ipa or .hap.
installTypeWho can install the build: 1 public, 2 password, 3 invitation only. Keeps the current setting of the app when empty.
passwordInstall password, used with installType: '2'.
descriptionDescription of the app.
updateDescriptionWhat changed in this build.
channelShortcutShort URL of the download channel to publish to.
installStartDate, installEndDateLimit installs to a date range, as yyyy-MM-dd. Set both or neither.
overseatrue to upload through overseas acceleration, false for mainland China. Chosen by IP address when empty.
processingTimeoutSeconds to wait for Pgyer to publish the build after the upload. Default 600.

Return value

pgyerUpload returns a map with everything Pgyer reports about the published build. The most useful fields are:

FieldDescription
appPgyerURLDownload page, such as https://www.pgyer.com/xxxx
buildQRCodeURLURL of the QR code image for the download page
buildName, buildVersion, buildBuildVersionApp name, version and build number
buildKey, buildShortcutUrlBuild key and short URL

Pass them to later steps, for example to post the download link to a team chat. For all fields, see the upload API.

Providing the API key through an environment variable

If you manage credentials with withCredentials, put the API key in the PGYER_API_KEY environment variable and pgyerUpload reads it:

withCredentials([string(credentialsId: 'pgyer-api-key', variable: 'PGYER_API_KEY')]) {
    pgyerUpload file: 'build/*.ipa'
}

Freestyle jobs

  1. Open the job configuration, click Add build step under Build Steps and choose Upload to PGYER:

    Adding the Upload to PGYER build step

  2. Choose the credential you added under API key, keep Directory as ${WORKSPACE}, and set File to the path of your package, such as app/build/outputs/apk/release/*.apk:

    Configuring the upload step

  3. To set the install type, update description and more, click Advanced. Then save the job.

Upload to PGYER is also available as a post-build action. As a post-build action it doesn't upload when the build failed.

The Advanced options match the Pipeline parameters:

OptionParameter
Install typeinstallType
Install passwordpassword
Descriptiondescription
Update descriptionupdateDescription; environment variables such as ${BUILD_NUMBER} are expanded
Channel shortcutchannelShortcut
Install start date, Install end dateinstallStartDate, installEndDate

Using the result in later steps

After the upload, the plugin sets environment variables for the following build steps, such as $appPgyerURL (download page), $buildQRCodeURL (QR code image), $buildShortcutUrl and $buildVersion. The names match the fields of the return value.

For example, add an "Execute shell" step after the upload:

echo "Download page: $appPgyerURL"

Using appPgyerURL in a later step

To skip the upload, add a job parameter isUploadPgyer and set it to false.

Check the result

The build log shows the upload progress, the published build and its download page:

Build log

The build page shows the download link and QR code, so testers can scan it to install:

Download link and QR code on the build page

The download page opened by the QR code:

The download page on a phone

Upgrading from 2.x

Jobs configured with version 2.x keep working after the upgrade without changes, including the environment variables they set and the isUploadPgyer and uploadPgyerTimeout variables they read. What changes:

  • Jobs that build on agents can upload: the plugin reads and uploads the package on the agent.
  • The plugin waits up to 10 minutes for Pgyer to publish the build, so "upload success but synchronizing data fail" no longer happens.
  • HarmonyOS .hap packages are supported, and the build type is detected from the file extension.
  • Downloads keep the original file name of the package.
  • Pipeline jobs should use the pgyerUpload step.

An API key typed into a 2.x job still works, but is marked as deprecated:

The deprecated API key in a 2.x job

Create a credential as described in Add your API key, choose it under API key, then click Change Password to clear the deprecated key and save the job.

FAQ

The upload fails with an error code

ErrorWhat to do
1001, 1002The API key is missing or wrong. Check it on the API information page.
1003Sub-accounts can't use the API. Use the API key of the main account.
1019Complete real-name verification before uploading.
1020Uploading is disabled for this account. Contact Pgyer customer service.
1022Your storage is full or the file is too large. Free up space or upgrade your plan.
PGYER is still processing the build after 600 secondsThe upload finished, but publishing took longer than processingTimeout. The build may still appear in your app list; raise the timeout if this happens often.
None of the PGYER API servers could be reachedThe node running the build can't reach www.pgyer.com. Check its network and Manage Jenkins → System → HTTP Proxy Configuration.

Uploading through a proxy

The plugin uses the HTTP proxy configured in Jenkins, and tries Pgyer's backup domains when www.pgyer.com can't be reached.

If the proxy requires a user name and password, Java doesn't send them for HTTPS connections by default. Start the JVM of the node running the build with -Djdk.http.auth.tunneling.disabledSchemes="".

Feedback

The plugin is open source. Report issues and suggestions on GitHub.

On this page