Build and publish pipeline artifacts with Gradle and Azure Pipelines

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019

Gradle is a popular build tool for Java applications and the primary build tool for Android. Using Azure Pipelines, you can build and publish your pipeline artifacts using both YAML and Classic pipelines.

Prerequisites

Build and publish pipeline artifacts

  1. Sign in to your Azure DevOps organization, and then navigate to your project.

  2. Select Pipelines, and then select your pipeline definition.

  3. Select Edit, and then add the following snippet to your YAML pipeline.

    steps:
    - task: Gradle@4
      displayName: 'gradlew build'
    
    - task: CopyFiles@2
      displayName: 'Copy Files to: $(Pipeline.Workspace)'
      inputs:
        TargetFolder: '$(Pipeline.Workspace)'
    
    - task: PublishPipelineArtifact@1
      displayName: 'Publish Pipeline Artifact'
    

Tip

To keep the Gradle daemon running, consider adding org.gradle.daemon=true to your gradle.properties file.