How to realize the systematic Packaging of android Project
1. Demand
Realize the systematic packaging of android project and the archiving management of each version of apk and upload it to dandelion platform automatically through dandelion platform API
two。 Mode of realization
Jenkins slave node installs android sdk and gradle
3. Pipeline
Node ('slave-201') {stage ("pull code from gitlab") {checkout ([$class:' GitSCM', branches: [[name:'* *], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'certified ID'] Url: 'project address']])} stage ("replace update configuration file and signature file") {sh''/ usr/bin/cd ${WORKSPACE} / usr/bin/rm-rf ${WORKSPACE} / app/build.gradle / usr/bin/cp / root/jenkins/android/build.gradle ${WORKSPACE} / app''} stage ("compile Package and sign package ") {sh''export JAVA_HOME=/usr/local/jdk8 export ANDROID_HOME=/usr/local/android export GRADLE_HOME=/usr/local/gradle cd app/ usr/local/gradle/bin/gradle clean / usr/local/gradle/bin/gradle assembleRelease'''} stage (" Archive ") {archiveArtifacts artifacts:' app/build/outputs/apk/release/app-release.apk' Fingerprint: true} stage ('publish to dandelion platform') {sh'''curl-F 'file=@app/build/outputs/apk/release/app-release.apk'-F' _ api_key=apikey'-F "buildInstallType=2"-F "buildPassword=password" https://www.pgyer.com/apiv2/app/upload''}}
4. Construction result