Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
G Guides
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • ios-general
  • Guides
  • Wiki
  • automated slack builds

Last edited by Artem Kalmykov May 09, 2017
Page history

automated slack builds

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. Screen_Shot_2017-01-31_at_3.53.31_PM
  • Select "Build" in the upper right corner.
  • Create or select appropriate application.
  • 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 appropriate application.
  • Select "Slash commands".
  • Specify command name following the convention /build-proj_name-platform-configuration, 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: Screen_Shot_2017-01-30_at_18.34.45
  • Go to Runners configuration.
  • Find macOS runner and click "Enable for this project".

4. Configure the project

  • Enable automatic signing.
  • Go to Build Settings.
  • Find Code Signing Identity Field and select iOS 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.

  • Runfastlane 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.
  • (Optional) If you have several build configurations, you need to copy-paste lane configuration and make appropriate changes. To sign with development profile, use export_method: "development".
  • Commit those changes to the repository.

6. Export signing resources

  • Open Keychain access application on your mac.
  • Go to Certificates and find yours.
  • Right-click on it and Export it.
  • Expand the certificate and right-click on your name.
  • Click Export, save it somewhere appropriate and enter a password.
  • Go to https://developer.apple.com/ and download required provisioning profiles.

7. Setup our server configuration

  • Connect to vnc://macos.faifly.com (Ask someone from the management for the password).
  • Find SlackBuilderConfiguration.plist on the desktop and open it for editing.
  • Based on other entries, setup yours one by specifying all the fields.
  • Copy your signing resources to the server by dragging them on VNC's window.
  • Install your signing resources and remove their files.
  • Open Slack and run your slash command.
  • Keep server window open until it prompts for keychain access. This happens only once per certificate access.

8. Automatic version increment

  • Make sure automatic incremented is properly configured.
  • Add Gitlab Pusher (gitlab_pusher) user to your repository. Make sure it has enough access rights to write to develop branch. If you don't have enough permissions for that - ask your supervisor.
  • Add the following line to before_all section of fastfile:
sh("git remote add gitlab git@gitlab.faifly.com/group/proj.git || true")

Replace the URL with SSH link to your repository.

  • Add the following lines to the end of your lane's configuration:
sh("git commit -o ../Proj/Info.plist -m \"[ci skip] Incremented build version.\"")
sh("git push gitlab HEAD:develop")

Replace Proj with your project's name. Make sure that is a correct path to your Info.plist file (keep in mind, that current directory is fastlane's folder).

  • Commit those changes to the repository and test.
Clone repository
  • Swift Code Style
  • automated slack builds
  • continuous integration
  • Home
  • jenkins auto build
  • shared localization
  • versioning rules