2

I am using App Center as CI for my application. I have to configure all the branches manually against which I need to build.

What I Want

If somebody creates a feature branch from develop/master and pushes the code, then App Center should start running automatically like CircleCI build etc.

Is this not possible in App Center?

Ajay S
  • 48,003
  • 27
  • 91
  • 111

1 Answers1

0

Yes, that's possible. You need to use app center fastlane plugin. You need to use appcenter_upload function. SSH has nothing to do with the whole process.

In your FastFile you need to configure a lane in following manner:

  desc 'Deploy a new version to the AppCenter'
  lane :upload_to_appcenter do |options|
    config = fetch_configuration(for_release_type: options[:release_type], for_project_dir: ENV['PROJECT_DIR'])

    gradle(
      task: 'assemble',
      build_type: 'Release',
      properties: {
        "AppCenterEnvironment" => options[:release_type],
        "android.injected.signing.store.file" => ENV['KEYSTORE'],
        "android.injected.signing.store.password" => ENV['KEYSTORE_PASSWORD'],
        "android.injected.signing.key.alias" => ENV['KEYALIAS'],
        "android.injected.signing.key.password" => ENV['KEYALIAS_PASSWORD'],
        "VersionPatchNumber" => config['app_version_patch_number']
      })

    perform_backup

    appcenter_upload(
      app_name: config['appcenter_name'],
      file: lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH],
      destinations: '*',
      release_notes: default_changelog,
      notify_testers: true,
      mapping: 'app/build/outputs/mapping/release/mapping.txt'
    )
  end

In your CI pipeline yaml you'll have to have something line this:

 - script: bundle exec fastlane upload_to_appcenter
    displayName: Upload to AppCenter
    condition: eq(variables['Build.SourceBranch'], 'refs/heads/development')
    env:
      APPCENTER_TOKEN: $(APPCENTER_API_TOKEN)
      APPCENTER_OWNER_NAME: $(APPCENTER_OWNER)
      RSYNC_PASSWORD: $(RSYNC_PASSWORD)

This will push version for every change of the head of development.

Please look at the repo guide how you can provide ENV variable, also look at your CI how you can pass params from the yaml to FastLane.

Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148
  • This is to publish your build to appcenter. I am using appcenter ci where I need to configure each branches where I need to run CI. My question Is there any way to automate this ? – Ajay S Apr 29 '22 at 06:20
  • Any way to trigger build pipelines automatically when you push code in app center ? – Ajay S Sep 20 '22 at 04:50