Jenkins
Keep the token in Jenkins credentials and add a stage after the build. The agent needs Node 18 or newer, installed on the machine or through the NodeJS plugin.
1. Add your token
Create an API token under Dashboard, Settings, API tokens (Pro and Team). Manage Jenkins, Credentials, add a Secret text credential with the token, for example with the id appforshare-token. The CLI reads it from the APPFORSHARE_TOKEN environment variable.
2. Jenkinsfile
withCredentials puts the token in the environment only for this step, and Jenkins masks it in the log.
pipeline {
agent any
stages {
stage('Build') {
steps {
sh './gradlew assembleRelease'
}
}
stage('Share with testers') {
steps {
withCredentials([string(credentialsId: 'appforshare-token', variable: 'APPFORSHARE_TOKEN')]) {
sh 'npx --yes appforshare upload app/build/outputs/apk/release/app-release.apk --notes "$(git log -1 --pretty=%B)" --channel beta'
}
}
}
}
}Good to know
- On a macOS agent, export the .ipa with xcodebuild -exportArchive (ad hoc or enterprise) and upload that path instead.
- Add --channel beta to keep one stable link for testers, and --fail-on blocked to stop the pipeline when the store readiness check finds a blocker (exit code 2; the build stays uploaded).
- The command prints the install link. Add --json for url, slug, version and channel as JSON. All options are on Upload from CI.
Questions
- Our Jenkins has no internet access. Can it upload?
- It needs outbound https to appforshare.io, and to the npm registry the first time npx fetches the CLI. You can install the CLI once with npm install -g appforshare and call appforshare directly.
- Can a failed readiness check fail the build?
- Yes. With --fail-on blocked the command exits with code 2, which marks the stage as failed.
Other CI systems
GitHub Actions and FastlaneCircleCIGitLab CIBitbucket PipelinesAzure PipelinesXcode CloudCodemagicBitriseExpo EAS