Sự kiện
21 giờ 17 thg 3 - 10 giờ 21 thg 3
Tham gia chuỗi buổi gặp gỡ để xây dựng các giải pháp AI có thể mở rộng dựa trên các trường hợp sử dụng trong thế giới thực với các nhà phát triển và chuyên gia đồng nghiệp.
Đăng ký ngayTrình duyệt này không còn được hỗ trợ nữa.
Hãy nâng cấp lên Microsoft Edge để tận dụng các tính năng mới nhất, bản cập nhật bảo mật và hỗ trợ kỹ thuật.
Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019
You can use a pipeline to automatically:
If you're working on an Android project, see Build, test, and deploy Android apps.
To run the following example, you must have:
Fork the following repo to your GitHub account:
https://github.com/MicrosoftDocs/pipelines-java
Sign in to your Azure DevOps organization and go to your project.
Go to Pipelines, and then select New pipeline or Create pipeline if creating the first pipeline in the project.
Perform the steps of the wizard by first selecting GitHub as the location of your source code. You might be redirected to GitHub to sign in. If so, enter your GitHub credentials.
Select your repo. You might be redirected to GitHub to install the Azure Pipelines app. If so, select Approve & install.
When you see the Configure your pipeline tab, select Maven, Gradle, or Ant depending on how you want to build your code.
A azure-pipelines.yml
file containing your pipeline definition is created in your repo and opened in the YAML editor. You can customize the pipeline by adding more tasks or modifying the existing tasks. For more information about the build tasks, see Build your code.
When you're finished editing the azure-pipelines.yml
, select Save and run.
To commit the azure-pipelines.yml
file to your repo, select Save and run again.
Select Job to watch your pipeline in action.
Go to your collection and select your project.
Select Pipelines, and then select New pipeline or Create pipeline if creating the first pipeline in the project.
Perform the steps of the wizard by first selecting GitHub Enterprise Server as the location of your source code.
Use an existing GitHub service connection or create a new one.
To create a service connection:
Select your repository. You might be redirected to GitHub to install the Azure Pipelines app. If so, select Approve & install.
When you see the Configure your pipeline tab, select Maven, Gradle, or Ant depending on how you want to build your code.
An azure-pipelines-yml
file containing your pipeline definition is created in your repo and opened in the YAML editor. You can customize the pipeline by adding more tasks or modifying the existing tasks. For more information about the build tasks, see Build your code.
When you're finished editing the azure-pipelines.yml
, select Save and run.
To commit the azure-pipelines.yml
file to your repo, select Save and run again.
You can select Job to watch your pipeline in action.
You now have a working YAML pipeline (azure-pipelines.yml
) in your repo that's ready for you to customize! To make changes to your pipeline, select it in the Pipelines page, and then Edit the azure-pipelines.yml
file.
You can use Azure Pipelines to build Java apps without needing to set up any infrastructure of your own. You can build on Windows, Linux, or macOS images. The Microsoft-hosted agents in Azure Pipelines have modern JDKs and other tools for Java preinstalled. To know which versions of Java are installed, see Microsoft-hosted agents.
To select the appropriate image, update the following snippet in your azure-pipelines.yml
file.
pool:
vmImage: 'ubuntu-latest' # other options: 'macOS-latest', 'windows-latest'
See Microsoft-hosted agents for a complete list of images.
As an alternative to using Microsoft-hosted agents, you can set up self-hosted agents with Java installed. You can also use self-hosted agents to save more time if you have a large repo or you run incremental builds.
Your builds run on a self-hosted agent. Make sure that you have Java and the tools necessary to build with your chosen method installed on the agent's host.
You can select your agent pool and the agent capabilities in the Agent pool and Agent Specification sections of the Options tab in the pipeline editor.
For example to specify the agent pool and an agent with the Maven capability, add the following snippet to your azure-pipelines.yml
file.
pool:
name: MyPool
demands: maven
You can build your Java app with Maven, Gradle, Ant, or a script. The following sections show you how to add a build step to your pipeline for each method.
With your Maven build, the following tasks are added to your azure-pipelines.yml
file. Replace the values to match your project. For more information about the task options, see the Maven task.
steps:
- task: Maven@4
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: 'default'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/TEST-*.xml'
goals: 'package'
For Spring Boot, you can use the Maven task as well. Make sure that your mavenPomFile
value reflects the path to your pom.xml
file. For example, if you're using the Spring Boot sample repo, your path is complete/pom.xml
.
Adjust the mavenPomFile
value if your pom.xml
file isn't in the root of the repo. The file path value should be relative to the root of the repo, such as IdentityService/pom.xml
or $(system.defaultWorkingDirectory)/IdentityService/pom.xml
.
Set the goals value to a space-separated list of goals for Maven to execute, such as clean package
. For details about common Java phases and goals, see Apache's Maven documentation.
With the Gradle build, the following task is added to your azure-pipelines.yml
file. For more information about these options, see the Gradle task.
steps:
- task: Gradle@2
inputs:
workingDirectory: ''
gradleWrapperFile: 'gradlew'
gradleOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: 'default'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/TEST-*.xml'
tasks: 'build'
You need to have a gradlew
file in your repo. If you don't have one, you can generate it by running gradle wrapper
in your project's root directory. For information about creating a Gradle wrapper, see the Gradle.
The version of Gradle installed on the agent machine is used unless your repo's gradle/wrapper/gradle-wrapper.properties
file has a distributionUrl
property that specifies a different Gradle version to download and use during the build.
Adjust the workingDirectory
value if your gradlew
file isn't in the root of the repo.
The directory value should be relative to the root of the repo, such as IdentityService
or $(system.defaultWorkingDirectory)/IdentityService
.
Adjust the gradleWrapperFile
value if your gradlew
file isn't in the root of the repo. The file path value should be relative to the root of the repo, such as IdentityService/gradlew
or $(system.defaultWorkingDirectory)/IdentityService/gradlew
.
Adjust the tasks value for the tasks that Gradle should execute, such as build
or check
. For more information about common Java Plugin tasks for Gradle, see Gradle's documentation.
With Ant build, add the following task to your azure-pipelines.yml
file. Change values, such as the path to your build.xml
file, to match your project configuration. For more information about these options, see the Ant task. If using the sample repo, you need to provide a build.xml
file in your repo.
steps:
- task: Ant@1
inputs:
workingDirectory: ''
buildFile: 'build.xml'
javaHomeOption: 'JDKVersion'
jdkVersionOption: 'default'
jdkArchitectureOption: 'x64'
publishJUnitResults: false
testResultsFiles: '**/TEST-*.xml'
To build with a command line or script, add one of the following snippets to your azure-pipelines.yml
file.
The script:
step runs an inline script using Bash on Linux and macOS and Command Prompt on Windows. For details, see the Bash or Command line task.
steps:
- script: |
echo Starting the build
mvn package
displayName: 'Build with Maven'
This task runs a script file that is in your repo. For details, see the Shell Script, Batch script, or PowerShell task.
steps:
- task: ShellScript@2
inputs:
scriptPath: 'build.sh'
You can publish your build output to your pipeline. You can package and publish your app in a Maven package or a .war/jar file to be deployed to a web application.
Learn more about creating a CI/CD pipeline for your deployment target:
Sự kiện
21 giờ 17 thg 3 - 10 giờ 21 thg 3
Tham gia chuỗi buổi gặp gỡ để xây dựng các giải pháp AI có thể mở rộng dựa trên các trường hợp sử dụng trong thế giới thực với các nhà phát triển và chuyên gia đồng nghiệp.
Đăng ký ngayĐào tạo
Lộ trình học tập
Xây dựng ứng dụng với đường dẫn tìm hiểu Azure DevOps - Training
Trong lộ trình học tập này, hãy tìm hiểu cách cộng tác với những người khác để liên tục xây dựng, kiểm tra và xác minh các ứng dụng của bạn bằng Azure Pipelines và GitHub.
Chứng chỉ
Chứng chỉ của Microsoft: Chuyên gia Kỹ sư DevOps - Certifications
Chứng chỉ này đo lường khả năng của bạn để hoàn thành các nhiệm vụ kỹ thuật sau: Thiết kế và thực hiện các quy trình và thông tin liên lạc, thiết kế và thực hiện một chiến lược kiểm soát nguồn, thiết kế và thực hiện quy trình xây dựng và phát hành, phát triển một kế hoạch bảo mật và tuân thủ, và thực hiện một chiến lược thiết bị.
Tài liệu
Build, test, and deploy with Apache Maven (task version 3).
Azure Pipelines documentation - Azure DevOps
Configure and manage continuous integration and continuous delivery (CI/CD) for the app and platform of your choice.
Build and deploy to a Java web app on Linux - Azure Pipelines
Continuous integration and deployment (CI/CD) to a Java web app on Linux.