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 |
[!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.
-
Sign in to your Azure DevOps organization, and then navigate to your project.
-
Select Pipelines, and then select your pipeline definition.
-
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"
- Sign in to your Azure DevOps organization, and then navigate to your project.
::: moniker-end
::: moniker range="< azure-devops"
- Sign in to your Azure DevOps collection, and then navigate to your project.
::: moniker-end
::: moniker range="<=azure-devops"
- Select Pipelines, and then select your pipeline definition.
::: moniker-end
-
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:-
Gradle: leave the default settings.
-
Copy Files: set the Target Folder to $(Pipeline.Workspace).
-
Publish Pipeline Artifact: make sure the File or directory path is set to $(Pipeline.Workspace) and the Artifact publish location is Azure Pipelines.
-
-
Select Save & queue when you're done.
-
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.