Azure Pipeline run tasks based on the designated android flavor

Viewed 740

I have a pipeline that ones running perfectly when my application wasn't flavored. it was building, signing and releasing the application to the firebase distribution.

Now I have the application flavored and I want on each push to development to release the app whether on com.example_flavor1 or com.example_flavor2

the gradle task and the firebase app id should change according to the flavor but i'm not knowing how to do so, can you help please

Here's my pipeline

trigger:
- development

variables:
- group: 'Variables'


stages:
- stage: Build
  displayName: Build & Archive
  jobs:
- job: build
  displayName: build
  pool: 
    vmImage: $(vmImage)  
  steps: 
  - task: Gradle@2
    inputs:
      workingDirectory: ''
      gradleWrapperFile: 'gradlew'
      gradleOptions: '-Xmx3072m'
      jdkVersionOption: '1.8'
      jdkArchitectureOption: 'x64'
      publishJUnitResults: false
      testResultsFiles: '**/TEST-*.xml'
      tasks: 'assembleRelease --stacktrace'
  
  - task: DownloadSecureFile@1
    displayName: Retrieving the Keystore
    inputs:
      secureFile: 'keystore.keystore'

  - task: AndroidSigning@3
    displayName: Signing the Release 2
    inputs:
      apkFiles: '**/*.apk'
      apksign: true
      apksignerKeystoreFile: 'keystore.keystore'
      apksignerKeystorePassword: '$(KeyStorePassword)'
      apksignerKeystoreAlias: '$(KeyAlias)'
      apksignerKeyPassword: '$(KeyPassword)'
      apksignerArguments: --out $(Build.SourcesDirectory)/app/build/outputs/apk/release/app-$(MajorVersion).$(MinorVersion).$(Build.BuildID)-release.apk
      zipalign: false

  - task: CopyFiles@2
    displayName: Archive APKs 
    inputs:
      contents: '**/*.apk'
      targetFolder: '$(build.artifactStagingDirectory)/apk'

  - task: CopyFiles@2
    displayName: Archive AABs 
    inputs:
      contents: '**/*.aab'
      targetFolder: '$(build.artifactStagingDirectory)/aab'

  - task: PublishBuildArtifacts@1
    displayName: Publish build artifacts
    inputs: 
      pathToPublish: '$(build.artifactStagingDirectory)'
      artifactName: '$(MajorVersion).$(MinorVersion).$(Build.BuildID)'

- stage: Publish
  displayName: Publish
 condition: succeeded()
  jobs:
  - deployment:
displayName: Firebase Tools install and deploy
pool:
  vmImage: $(vmImage)
environment: Dev
strategy:
  runOnce:
    deploy:
      steps:            
      - task: NodeTool@0
        inputs:
          versionSpec: '10.x'
        displayName: 'Install Node.js'

      - task: DownloadBuildArtifacts@0
        inputs:
          buildType: 'current'
          artifactName: '$(MajorVersion).$(MinorVersion).$(Build.BuildID)'
          downloadPath: '$(System.ArtifactsDirectory)'

      - script: |
          cd $(Pipeline.Workspace)
          npm install -g firebase-tools
          firebase appdistribution:distribute $(System.ArtifactsDirectory)/$(MajorVersion).$(MinorVersion).$(Build.BuildID)/apk/app/build/outputs/apk/release/app-$(MajorVersion).$(MinorVersion).$(Build.BuildID)-release.apk --project $(firebase-project-id) --app $(firebase-android-app-id) --token $(firebase-token) --testers "$(firebase-testers-emails)" --groups "$(firebase-testers-groups)" --release-notes "$(release-notes)" --debug
        displayName: 'npm install and distribute'
1 Answers
Related