Creating an AAR artifact from code in Azure Devops

Viewed 799

I have code for an android library which was pushed to azure git ,

My main goal is to make an artifact from it to be consumed in a later project , I created a Pipeline which looks like this :

trigger:
   - master
    pool:
  vmImage: 'macos-latest'

steps:
- task: Gradle@2
  inputs:
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx3072m'
    publishJUnitResults: false
    testResultsFiles: '**/TEST-*.xml'
- task: MavenAuthenticate@0
  inputs:
    artifactsFeeds: 'testArt'
    tasks: 'assembleRelease'

But it didn't create anything , any ideas what am I doing wrong here ? I found little information about this specific request

Thanks to all the helpers!

UPDATE :

- task: Gradle@2
  inputs:
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx3072m'
    tasks: 'assembleRelease'
    publishJUnitResults: false
    testResultsFiles: '**/TEST-*.xml'
- task: CopyFiles@2
  inputs:
    contents: '**/*.aar'
    targetFolder: '$(build.artifactStagingDirectory)'
- task: PublishBuildArtifacts@1
  inputs:
   targetPath: $(Build.ArtifactStagingDirectory)
   artifactName: 'FeedName'

- task: UniversalPackages@0
  inputs:
   command: publish
   publishDirectory: $(Build.ArtifactStagingDirectory)
   vstsFeedPublish: 'Project/FeedName'
   vstsFeedPackagePublish: 'com.package'  
   vstsPackageVersion: $(latestVersion)

The new update builds an aar file but I couldn't get to the artifact from android studio , is using UniversalPackages correct (without it Artifact section is empty)? or should I use something else ?

1 Answers

Creating an AAR artifact from code in Azure Devops

To create the AAR artifact, you could to check if you have configured your Gradle task correctly.

  • Adjust the workingDirectory value if your gradlew file isn't in the root of the repository. The directory value should be relative to the root of the repository, such as AndroidApps/MyApp or $(system.defaultWorkingDirectory)/AndroidApps/MyApp.
  • Adjust the gradleWrapperFile value if your gradlew file isn't in the root of the repository. The file path value should be relative to the root of the repository, such as AndroidApps/MyApp/gradlew or $(system.defaultWorkingDirectory)/AndroidApps/MyApp/gradlew.

You could check if that task create any .aar or .apk file from the output log. If not, you may need to share the build log in your question, so that we could check the reason why it not create any artifact.

You could check this document Build, test, and deploy Android apps for some more details.

Besides, if the task Gradle generates artifact, we need to add the Copy Files and Publish Build Artifacts tasks to store your APK with the build record or test and deploy it in subsequent pipelines:

- task: CopyFiles@2
  inputs:
    contents: '**/*.aar'
    targetFolder: '$(build.artifactStagingDirectory)'
- task: PublishBuildArtifacts@1

Hope this helps.

Related