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.

Prerequisites

  • 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.

    az --version
    
  • 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

  1. From a command prompt, sign in to the Azure CLI.

    az login
    
  2. Fork the following repository into your GitHub account:

    https://github.com/MicrosoftDocs/pipelines-java
    

    After you've forked it, clone it to your dev machine. Learn how: Fork a repo.

  3. Navigate to the cloned directory.

  4. 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.

  5. 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:
    
  6. 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
    
  7. Select the Maven pipeline template from the list of recommended templates.

    Which template do you want to use for this pipeline?
    [1] Maven
    [2] Maven package Java project Web App to Linux on Azure
    [3] Android
    [4] Ant
    [5] ASP.NET
    [6] ASP.NET Core
    [7] ASP .NET Core (.NET Framework)
    [8] Starter pipeline
    [9] C/C++ with GCC
    [10] Go
    [11] Gradle
    [12] HTML
    [13] Jekyll site
    [14] .NET Desktop
    [15] Node.js
    [16] Node.js with Angular
    [17] Node.js with Grunt
    [18] Node.js with gulp
    [19] Node.js with React
    [20] Node.js with Vue
    [21] Node.js with webpack
    [22] PHP
    [23] Python Django
    [24] Python package
    [25] Ruby
    [26] Universal Windows Platform
    [27] Xamarin.Android
    [28] Xamarin.iOS
    [29] Xcode
    Please enter a choice [Default choice(1)]:
    
  8. 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?
    [1] Continue with the generated yaml
    [2] View or edit the yaml
    Please enter a choice [Default choice(1)]:2
    
  9. Provide where you want to commit the YAML file that is generated.

    How do you want to commit the files to the repository?
    [1] Commit directly to the master branch.
    [2] Create a new branch for this commit and start a pull request.
    Please enter a choice [Default choice(1)]:
    
  10. 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.

Status badge shows Azure pipeline succeeded

To copy the status badge to your clipboard:

  1. In Azure Pipelines, go to the Pipelines page to view the list of pipelines. Select the pipeline you created in the previous section.

  2. In the context menu for the pipeline, select Status badge.

  3. Copy the sample Markdown from the status badge panel.

Now with the badge Markdown in your clipboard, take the following steps in GitHub:

  1. Go to the list of files and select Readme.md. Select the pencil icon to edit.

  2. Paste the status badge Markdown at the beginning of the file.

  3. Commit the change to the master branch.

  4. Notice that the status badge appears in the description of your repository.

To configure the Allow anonymous access to badges setting:

  1. Navigate to Project Settings

  2. Open the Settings tab under Pipelines

  3. Select the Allow anonymous access to badges checkbox under General

Note

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.

Next steps

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.

Clean up

If you created any test pipelines, they are easy to delete when you are done with them.

To delete a pipeline, navigate to the summary page for that pipeline, and choose Delete from the ... menu at the top-right of the page. Type the name of the pipeline to confirm, and choose Delete.

Delete pipeline