Create your first pipeline from the CLI
This is a step-by-step guide to using Azure Pipelines from the Azure CLI (command-line interface) to build a GitHub repository. You can use Azure Pipelines to build an app written in any language. For this quickstart, you'll use Java.
A GitHub account, where you can create a repository. If you don't have one, you can create one for free.
An Azure DevOps organization. If you don't have one, you can create one for free. (An Azure DevOps organization is different from your GitHub organization. Give them the same name if you want alignment between them.)
If your team already has one, then make sure you're an administrator of the Azure DevOps project that you want to use.
Azure CLI version 2.0.49 or newer.
To install, see Install the Azure CLI.
To check the version from the command prompt:
The Azure DevOps extension.
- To install from the command prompt:
az extension add --name azure-devops
- To confirm installation from the command prompt:
az extension show --name azure-devops
Make sure your Azure DevOps defaults include the organization and project from the command prompt:
az devops configure --defaults organization=https://dev.azure.com/your-organization project=your-project
Get your first run
From a command prompt, sign in to the Azure CLI.
Fork the following repository into your GitHub account:
After you've forked it, clone it to your dev machine. Learn how: Fork a repo.
Navigate to the cloned directory.
Create a new pipeline:
az pipelines create --name "First-Java.CI"
The repository and branch details are picked up from the git configuration available in the cloned directory.
Enter your GitHub user name and password to authenticate Azure Pipelines.
Enter your GitHub username (Leave blank for using already generated PAT): Contoso Enter your GitHub password:
Provide a name for the service connection created to enable Azure Pipelines to communicate with the GitHub Repository.
Enter a service connection name to create? ContosoPipelineServiceConnection
Select the Maven pipeline template from the list of recommended templates.
Which template do you want to use for this pipeline?  Maven  Maven package Java project Web App to Linux on Azure  Android  Ant  ASP.NET  ASP.NET Core  ASP .NET Core (.NET Framework)  Starter pipeline  C/C++ with GCC  Go  Gradle  HTML  Jekyll site  .NET Desktop  Node.js  Node.js with Angular  Node.js with Grunt  Node.js with gulp  Node.js with React  Node.js with Vue  Node.js with webpack  PHP  Python Django  Python package  Ruby  Universal Windows Platform  Xamarin.Android  Xamarin.iOS  Xcode Please enter a choice [Default choice(1)]:
The pipeline YAML is generated. You can open the YAML in your default editor to view and make changes.
Do you want to view/edit the template yaml before proceeding?  Continue with the generated yaml  View or edit the yaml Please enter a choice [Default choice(1)]:2
Provide where you want to commit the YAML file that is generated.
How do you want to commit the files to the repository?  Commit directly to the master branch.  Create a new branch for this commit and start a pull request. Please enter a choice [Default choice(1)]:
A new run is started. Wait for the run to finish.
Add a status badge to your repository
Many developers like to show that they're keeping their code quality high by displaying a status badge in their repo.
To copy the status badge to your clipboard:
In Azure Pipelines, go to the Pipelines page to view the list of pipelines. Select the pipeline you created in the previous section.
In the context menu for the pipeline, select Status badge.
Copy the sample Markdown from the status badge panel.
Now with the badge Markdown in your clipboard, take the following steps in GitHub:
Go to the list of files and select
Readme.md. Select the pencil icon to edit.
Paste the status badge Markdown at the beginning of the file.
Commit the change to the
Notice that the status badge appears in the description of your repository.
To configure the Allow anonymous access to badges setting:
Navigate to Project Settings
Open the Settings tab under Pipelines
Select the Allow anonymous access to badges checkbox under General
Even in a private project, anonymous badge access is enabled by default. With anonymous badge access enabled, users outside your organization might be able to query information such as project names, branch names, job names, and build status through the badge status API.
Because you just changed the
Readme.md file in this repository, Azure Pipelines automatically builds your code, according to the configuration in the
azure-pipelines.yml file at the root of your repository. Back in Azure Pipelines, observe that a new run appears. Each time you make an edit, Azure Pipelines starts a new run.
You've just learned how to create your first Azure Pipeline. Now you're ready to configure a pipeline for the language of your choice:
Or, you can proceed to customize the pipeline you just created.
To run your pipeline in a container, see Container jobs.
For details about building GitHub repositories, see Build GitHub repositories.
To learn what else you can do in YAML pipelines, see YAML schema reference.
If you created any test pipelines, they are easy to delete when you are done with them.