Welcome to Your First Azure Pipeline
Azure Pipelines is a cloud service that you can use to automate building, testing, and deploying your code to any cloud or on-premises. This guide will walk you through the essential steps to create and run your first pipeline.
What You'll Need
- An Azure DevOps organization. If you don't have one, you can create it for free.
- A Git repository (e.g., GitHub, Azure Repos, Bitbucket) with your code.
- An Azure subscription if you plan to deploy to Azure.
Creating Your First Pipeline
Connect to Your Repository
Navigate to your Azure DevOps project, then select "Pipelines" from the left-hand menu. Click "Create Pipeline". You'll be prompted to choose where your code is located. Select your Git provider and authorize Azure DevOps to access your repositories.
Once authorized, select the repository containing your project code.
Configure Your Pipeline
Azure Pipelines will analyze your repository and suggest a starter pipeline configuration. For most .NET or Node.js applications, it will detect the appropriate template. You can choose to start with a recommended template or configure it from scratch.
For this tutorial, let's assume you have a simple Node.js application. Select "Starter pipeline" if prompted, or a Node.js template.
Understand the YAML Pipeline Definition
Pipelines are defined using YAML. A basic pipeline includes sections for:
- trigger: When the pipeline should run (e.g., on commits to the main branch).
- pool: The agent pool where the job will run.
- steps: A sequence of tasks to execute.
Here's an example of a simple Node.js pipeline:
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '18.x'
displayName: 'Use Node.js 18.x'
- script: |
npm install
npm run build
displayName: 'Install dependencies and build'
- script: |
npm test
displayName: 'Run tests'
condition: succeeded()
Save and Run Your Pipeline
Once you've reviewed or customized your YAML file, click "Save and run". You can commit the YAML file directly to your repository or save it as a pull request. Azure Pipelines will then start executing the defined steps.
Monitor the pipeline's progress in the "Pipelines" section. You can view logs for each step to troubleshoot any issues.
Next Steps
Congratulations! You've created and run your first Azure Pipeline.
- Explore Triggers: Learn about different triggers like scheduled runs, PR triggers, and more.
- Add Stages and Jobs: Break down your pipeline into logical stages for building, testing, and deploying.
- Integrate with Azure: Set up deployment jobs to deploy your application to Azure App Services, AKS, or other services.
- Manage Variables: Use pipeline variables for configuration and secrets.
- Artifacts: Publish build artifacts and download them in subsequent stages or pipelines.