'How do I return string from fastlane to jenkins groovy variable?

Have a lane in fastlane as

lane :ipa_path do |options|
 “<ipa path>.ipa”
end

How to store string returned by ipa_path lane in groovy script variable?



Solution 1:[1]

In your Fastlane/fastfile

    # Your lane in your fastfile.
    lane :ipa_path do |options|
        ENV["SOME_VAR"] = options[:my_passed_in_option]
        # After calling build_app action to compile/create IPA
        # this lane context value will exist: IPA_OUTPUT_PATH    
        ENV["MY_IPA_PATH"] = lane_context[SharedValues::IPA_OUTPUT_PATH]
    end

In your Jenkinsfile ...

    // Use this in Jenkinsfile.
    stage('Test IPA Path') {
        steps {
           sh "bundle exec ipa_path my_passed_in_option:"some_string_value" --env jenkins"
           sh "echo 'IPA Path is: ${MY_IPA_PATH}" // path_to_IPA_file.IPA
           IPA_PATH = MY_IPA_PATH
           sh "echo 'Some Var is: ${SOME_VAR}" // some_string_value
           SOME_VARIABLE = SOME_VAR
        }
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 duncwa