1. Setup Slack integration
- Make sure you have admin access to your Slack team.
- Open Slack application, select your team's name and select Apps & Integrations.
- Select "Build" in the upper right corner.
- Select "Make a custom integration".
- Select "Incoming webhooks".
- Select a channel you want to post in and click "Add incoming WebHooks integration".
- Configure integration (optional) and save WebHook URL for future use.
2. Setup slash command
- Go to Slack configuration panel again.
- Select "Build" in the upper right corner.
- Select "Make a custom integration".
- Select "Slash commands".
- Specify command name following the convention /build-<proj_name>--, e.g. /build-myproj-ios-qa
- Click "Add Slash Command Integration".
- Enter
http://macos.faifly.com:8181/slack-commands/trigger-build
as URL, add custom name and setup autocomplete. - Save the changes.
3. Setup Gitlab CI for the project
- Go to http://gitlab.faifly.com/ and select your project.
- Click "Setup CI" button.
- Copy-paste the following code:
stages:
- diawi
diawi_build:
stage: diawi
script:
- fastlane ios ${FASTLANE_CONFIGURATION} slack_response_url:"${SLACK_RESPONSE_URL}"
only:
- triggers
- Click "Commit Changes".
- Go to project settings (in Gitlab) and select "Triggers".
- Add trigger.
- Make a note of new trigger's token and project's ID. Project ID can be found here:
4. Configure the project
- Enable automatic signing.
- Go to Build Settings.
- Find
Code Signing Identity
Field and selectiOS Distribution
for your distribution configuration. - Make sure
Development Team
is correctly selected for your distribution configuration. - Go to https://developer.apple.com/ and generate AdHoc provisioning profiles for your project and make sure you have a correct signing identity to use them.
5. Setup fastlane for the project.
- Run
fastlane init
and follow the instructions. - Open
Fastfile
for editing and copy-paste the following code:
default_platform :ios
platform :ios do
before_all do
ENV["SLACK_URL"] = "http://slack_url.com"
clear_derived_data
end
error do |lane, exception|
slack(
message: exception.message,
success: false
)
end
lane :diawi_build do |options|
update_project_codesigning(path: "MyApp.xcodeproj", use_automatic_signing: false)
gym(scheme: "MyAppScheme", configuration: "Release", export_method: "ad-hoc", xcargs: "PROVISIONING_PROFILE_SPECIFIER='PROV_PROFILE_NAME'", output_name: "build.ipa")
sh("./diawi_resp.sh '#{options[:slack_response_url]}'")
end
end
- Replace
http://slack_url.com
with your Webhook URL, created at step #1. - Replace
MyApp.xcodeproj
with your Xcode project's filename (even if you use workspace). - Replace
MyAppScheme
with your app's scheme name. - Make sure configuration name matches yours.
- Replace
PROV_PROFILE_NAME
with your provisioning profile's name. - Copy this file to fastlane folder in your project's root: diawi_resp.sh
- (Optional) You may want to run
fastlane ios diawi_build
to make sure everything is setup correctly.