Create a multi-platform pipeline

Azure Pipelines

This is a step-by-step guide to using Azure Pipelines to build on macOS, Linux, and Windows.

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.

Get the sample code

You can use Azure Pipelines to build an app on written in any language, on multiple platforms at the same time.

  1. Go to https://github.com/MicrosoftDocs/pipelines-javascript.

  2. Fork the repo into your own GitHub account.

You should now have a sample app in your GitHub account.

Add a pipeline

In the sample repo, there's no pipeline yet. You're going to add jobs that run on three platforms.

  1. Go to your fork of the sample code on GitHub.

  2. Choose 'Create new file'. Name the file azure-pipelines.yml, and give it the contents below.

# Build NodeJS Express app using Azure Pipelines
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript?view=azure-devops
strategy:
  matrix:
    linux:
      imageName: 'ubuntu-16.04'
    mac:
      imageName: 'macos-10.13'
    windows:
      imageName: 'vs2017-win2016'

pool:
  vmImage: $(imageName)

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '8.x'

- script: |
    npm install
    npm test

- task: PublishTestResults@2
  inputs:
    testResultsFiles: '**/TEST-RESULTS.xml'
    testRunTitle: 'Test results for JavaScript'

- task: PublishCodeCoverageResults@1
  inputs: 
    codeCoverageTool: Cobertura
    summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml'
    reportDirectory: '$(System.DefaultWorkingDirectory)/**/coverage'

- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
    includeRootFolder: false

- task: PublishBuildArtifacts@1

At the bottom of the GitHub editor, select Commit changes.

Each job in this example runs on a different VM image. By default, the jobs run at the same time in parallel.

Note: script runs in each platform's native script interpreter: Bash on macOS and Linux, CMD on Windows. See multi-platform scripts to learn more.

Create the pipeline

Now that you've configured your GitHub repo with a pipeline, you're ready to build it.

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

  2. In your project, go to the Pipelines page, and then select New pipeline.

  3. Select GitHub as the location of your source code.

    Select GitHub

  4. For Repository, select Authorize and then Authorize with OAuth.

  5. You might be redirected to GitHub to sign in. If this happens, then enter your GitHub credentials. After you're redirected back to Azure Pipelines, select the sample app repository.

  6. For the Template, Azure Pipelines analyzes the code in your repository. If your repository already contains an azure-pipelines.yml file (as in this case), then this step is skipped. Otherwise, Azure Pipelines recommends a starter template based on the code in your repository.

  7. Azure Pipelines shows you the YAML file that it will use to create your pipeline.

  8. Select Save and run, and then select the option to Commit directly to the master branch.

  9. The YAML file is pushed to your GitHub repository, and a new build is automatically started. Wait for the build to finish.

Next steps

You've just learned the basics of using multiple platforms with Azure Pipelines. From here, you can learn more about:

For details about building GitHub repositories, see Build GitHub repositories.