简体   繁体   中英

Jenkins Android groovy.lang.MissingPropertyException: No such property: HOME for class: groovy.lang.Binding

I am very beginning to Jenkins. I followed this tutorial for automated publish app to play store. https://medium.com/mindorks/automating-android-app-play-store-publishing-via-jenkins-a6c30dbc59dd

I got this error message very beginning.

groovy.lang.MissingPropertyException: No such property: HOME for class: groovy.lang.Binding

def home = sh(script: "echo $HOME",returnStdout: true).trim()
        def SDKPath = "$home/Android/SDK"
        stage("Preparing SDK"){
            // Check SDK Downloaded
            def isSDKDownloaded = sh(script: "test -e sdk-tools-linux-4333796.zip && echo true || echo false",returnStdout: true).trim()
            if(isSDKDownloaded == "false"){
                // Download SDK
                sh "wget 'https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip'"
            }
            // Check if SDK is Extracted
            def isExtracted = sh(script: "test -e $SDKPath/tools && echo true || echo false",returnStdout: true).trim()
            if(isExtracted == "false"){
                sh "mkdir -p $SDKPath"
                //Unzip SDK
                sh "unzip sdk-tools-linux-4333796.zip -d $SDKPath"
            }
// Install SDK Tools
            sh "yes | $SDKPath/tools/bin/sdkmanager 'build-tools;28.0.3' 'platform-tools' 'platforms;android-27'"
sh "ls $SDKPath/licenses"
            // See installed And Available SDK
            sh "$SDKPath/tools/bin/sdkmanager --list"
            // Accept All SDK Licences
            sh "yes | $SDKPath/tools/bin/sdkmanager --licenses"
        }

def selectedBranch = SELECTED_RELEASE_BRANCH
         stage('Checkout') {
             git branch: selectedBranch, url: 'git@gitlab.com:...'
            // Remove Existing local properties
            sh 'rm local.properties ||:'
            // Write sdk.dir Path into local properties file
            sh "echo 'sdk.dir=$SDKPath' >> local.properties"
         }

         stage('Setup Tools') {
             withCredentials([file(credentialsId: 'android_keystore', variable: 'KEYFILE')]) {
                 sh "cp \$KEYFILE app/key.jks"
             }   
         }

         stage('Build Release APK') {
             sh "./gradlew clean assembleRelease"
         }

         stage('Upload to Play Store') {
            androidApkUpload googleCredentialsId: 'P12 KEY added to here', apkFilesPattern: '**/*-release.apk', trackName: 'alpha'
         }

         stage('Cleanup Credential') {
             sh "rm app/key.jks"
         }

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

更改路径名ANDROID_HOME而不是HOME

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM