问题
Error Message
[Pipeline] Start of Pipeline
[Pipeline] sh [Pipeline]
End of Pipeline
org.jenkinsci.plugins.workflow.steps.MissingContextVariableException: Required context class hudson.FilePath is missing Perhaps you forgot to surround the code with a step that provides this, such as: node
My file Android SDK path on my Mac
/Users/bhanukaisuru/Library/Android/sdk
I also download android sdk tool only. Path is:
/Users/bhanukaisuru/Library
Environment Variable Config Jenkins > Configure System Name: ANDROID_HOME Value: /Users/don/Library
Full Pipeline // I commented above code, because of for check the issue
def home = sh(script: "echo $ANDROID_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:app/wtc.git'
// // 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 from GCP', apkFilesPattern: '**/*-release.apk', trackName: 'alpha'
// }
// stage('Cleanup Credential') {
// sh "rm app/key.jks"
// }
I printed path: It's printed
echo "$ANDROID_HOME"
output is :
echo /Users/bhanukaisuru/Library
回答1:
now, It's working. Is there any way to fix the above issue. please let me kow
node('master') {
//Existing same code
}
来源:https://stackoverflow.com/questions/60067843/required-context-class-hudson-filepath-is-missing-perhaps-you-forgot-to-surround