Search code examples
rubyfastlane

How to call Fastlane lane which is stored in variable from another lane


This may be a noob Ruby question.

I have several iOS apps in the same repo. Hence, I have quite a few lanes. And I have a lane which uses tty to choose which lane/s I would like to run..

So, say the user selects lane1 – how do I call this lane? :D

I could use backticks and use `fastlane %{userSelectedLane}`. However, this launches a new fastlane runner and doesn't show the output.

Instead I would like to achieve the same result as you have when you call other lanes from the current one - i.e. full fastlane output.

Here is my setup:

lane :chooseLanes do |options|
    prompt = TTY::Prompt.new

    lanes = %w(lane1 lane2)

    lanesChosen = prompt.multi_select("Select lane?", lanes)

    for lane in lanesChosen do
        #How do I call this lane???
    end
end

lane :lane1 do |options|
end

lane :lane2 do |options|
end

Solution

  • Ok, figured it out:

    lane :chooseLanes do |options|
        prompt = TTY::Prompt.new
    
        lanes = %w(lane1 lane2)
    
        lanesChosen = prompt.multi_select("Select lane?", lanes)
    
        for lane in lanesChosen do
            send(lane) #This does the trick!
        end
    end
    
    lane :lane1 do |options|
    end
    
    lane :lane2 do |options|
    end