2

I build with fastlane ios lanename but for integration into Jenkins want to override the output file name. By default output names are defined in the Fastfile gym options but I want to add version and build number to the filename in Jenkins.

However this command doesn't cut it:

fastlane ios build_dev_stg output_name:"App_Dev_Staging_2.5.1.3452"

After trying this, the output filename is still the same as defined in the Fastfile. Is there any other way to override this?

BadmintonCat
  • 9,416
  • 14
  • 78
  • 129

2 Answers2

2

You are doing a bit wrong, but the intention was right.

You don't have to pass the param to your lane (build_dev_stg).

You need to pass that option on your gym, inside your lane.

My lane for ex:

lane :buildDev do |options|
  [.... Set nameSuffix, versionName and so on ...]
  ipaName = "MyApp_#{nameSuffix}_#{versionName}_#{buildNumber}.ipa"
  gym(
    configuration: configuration,
    scheme: scheme,
    export_method: export_method,
    output_name: ipaName
  )
end

Hope this helps, any question, be free to ask

Sulfkain
  • 5,082
  • 1
  • 20
  • 38
0

Hereby sharing a sample lane which generates a build name as per the current version and build number. Have used the same for my setup.

# Can be called from other lanes as:
# Build Name
output_build_name = ""
generate_build_name

#Generate the build
build(build_name: output_build_name)

# Lane to create build name using the version
lane :generate_build_name do |options|

# https://github.com/beplus/fastlane-plugin-versioning_ios
# Get version and build number install above plugin
version = get_version_number(target: target)
build_number = get_build_number(xcodeproj: project)
puts "VERSION : #{version}"

current_date = Time.new.strftime('%Y.%m.%d')
build_name = "-Ver-"+ version + "-B-" + build_number + "-" +current_date
output_build_name = app_name + "-" + build_name

# Build name
puts "#{app_name} BUILD NAME : #{output_build_name}" 
// BUILD NAME : AppName-Ver-1.0-B-31-2019.09.16
end

lane :build do |options|
build_app(
  workspace: "MyApp.xcworkspace",
  configuration: "Debug",
  scheme: "MyApp",
  silent: true,
  clean: true,
  output_name: options[:build_name] + ".ipa"
)
Sumit
  • 874
  • 9
  • 10