Skip to content

Latest commit

 

History

History
90 lines (55 loc) · 2.96 KB

build-publish-artifacts-gradle.md

File metadata and controls

90 lines (55 loc) · 2.96 KB
title description ms.reviewer ms.topic ms.date monikerRange recommendations
Build and publish pipeline artifacts with Gradle
Learn how to build and publish your pipeline artifact with Gradle and Azure Pipelines.
dastahel
how-to
02/10/2025
<= azure-devops
true

Build and publish pipeline artifacts with Gradle and Azure Pipelines

[!INCLUDE version-lt-eq-azure-devops]

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'

::: moniker range="azure-devops"

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

::: moniker-end

::: moniker range="< azure-devops"

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

::: moniker-end

::: moniker range="<=azure-devops"

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

::: moniker-end

  1. Select Edit, and then select the + sign to add a new task. Add the Gradle, Copy Files, and Publish Pipeline Artifact tasks to your pipeline definition and configure them as follows:

    1. Gradle: leave the default settings.

    2. Copy Files: set the Target Folder to $(Pipeline.Workspace).

    3. Publish Pipeline Artifact: make sure the File or directory path is set to $(Pipeline.Workspace) and the Artifact publish location is Azure Pipelines.

  2. Select Save & queue when you're done.

  3. You can view your published artifact in your pipeline Summary once the run is complete.

    :::image type="content" source="media\published-artifact.png" alt-text="Screenshot showing the published artifact in the pipeline summary.":::


Tip

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

Related content