Fastlane - how to pass value to another step

I have fastlane script, which calculates my app version and build number. And I need to pass it outside of fastlane step somehow (I’m going to use them on set-xcode-build-number step)
Is the any way to save values into envs using fastlane (ruby) script and use it in another step? Or any other approach?

Hi @ViktorO!

Could you try using envman to assign those values to a variable? The usage is fairly simple:

envman add --key MY_TEST_ENV_KEY --value 'test value for test key'

Hi @bitce
That was the first thing, which I tried to do

Since flutter is ruby lng, I wrapped commands in system:

system("envman add --key APP_CURRENT_VERSION --value ", version)
system("envman add --key APP_CURRENT_BUILD --value ", next_build)

No success. Received No build_version specified! in set-xcode-build-number step

Step yml:

- set-xcode-build-number@1:
    inputs:
    - build_short_version_string: "$APP_CURRENT_VERSION"
    - build_version_offset: ''
    - build_version: "$APP_CURRENT_BUILD"
    - plist_path: iOS/Info.plist

Hi @ViktorO! I see, that possibly isn’t gonna work that way. Can you send us a build URL for instance where we could see how this is being used exactly? Thanks!

Sure

Link to app: https://app.bitrise.io/app/48c3625a1e9973f8
Link to its latest build: https://app.bitrise.io/build/381fa56e6d81ff0b

Thanks! I see now that all of this is meant to be executed from a single fastlane step, so this doesn’t provide us access to the contents of the Script. Is that something you could share here?

Fastlane lane:

lane :build_version_last do

  version = get_version_number(
    xcodeproj: "TestCI.xcodeproj",
    target: "TestCI",
    configuration: ENV['TG_CONFIGURATION']
  )

  build = latest_testflight_build_number(
    app_identifier: ENV['TG_BUNDLE'],
    version: version
  )

  next_build = (build + 1).to_s

  # Export envs here

end

Thanks, that’s helpful too for sure, but what I really want to see is the ruby script where you define the variables, is that something you could share too? :slight_smile:

If you mean envs, then instead of # Export envs here part I tried:

Raw: ENV['APP_CURRENT_VERSION'] = version - definitely doesn’t work.

Envman command both raw and wrapped in system (like in this message - Fastlane - how to pass value to another step)

Hi @ViktorO,

Could you try this command for exporting the env var?
system("envman add --key APP_CURRENT_VERSION --value '#{version}'")

Let us know how it goes! :nerd_face:

1 Like

It works! :tada::handshake:

The problem was in passing parameters into “system” string value

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.