Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Azure DevOps Services | Azure DevOps Server | Azure DevOps Server 2022 | Azure DevOps Server 2020
This article explains how to create a pipeline in Azure Pipelines by using an existing pipeline as a starting point.
For YAML pipelines, you can copy a YAML pipeline file or code from one pipeline to another. Cloning a YAML pipeline copies only the YAML code. You need to reconfigure any other settings in the new pipeline, such as variables, triggers, options, and security.
For Classic pipelines, if the source pipeline is in the same project as your new pipeline, you can clone it. If it's in a different project, you can export it from that project and import it into your project. Cloning a Classic pipeline also clones its settings, except for security.
To migrate a Classic build pipeline to a YAML pipeline by using Export to YAML, see Migrate from Classic pipelines.
Prerequisites
- An Azure DevOps project where you have permission to create and edit pipelines.
- An existing Azure Pipelines pipeline to base a new pipeline on.
Clone or copy a pipeline
For YAML pipelines, you copy the YAML from the pipeline you want to clone to your new pipeline. Only the YAML is copied. You need to reconfigure any other settings defined outside the YAML, such as variables, triggers, security, and other options.
If your source pipeline and new pipeline use the same source code repository, you can copy the source YAML pipeline definition file to the new pipeline. If the two pipelines are in different repositories or you want to start with a new file, you can copy the YAML code from the source pipeline into the new one.
To clone an existing pipeline definition file:
- Create a New pipeline in your Azure DevOps project.
- On the Configure your pipeline page, select Existing Azure Pipelines YAML file, enter the path and filename for the existing pipeline file, and select Continue.
- Rename and customize the new pipeline as desired, and then select Save and run.
To copy YAML code from a source pipeline into a new pipeline:
Select the pipeline you want to clone from the list on the Pipelines page.
On the pipeline page, select Edit at upper right.
Copy the pipeline YAML code from the editor.
Create a New pipeline in your project.
On the Configure your pipeline page, select Starter pipeline.
On your new pipeline page, replace the contents of the starter file with the copied pipeline YAML.
Name and customize the new pipeline as desired, and then select Save and run.
Note
To copy from a Classic source pipeline to a new YAML pipeline, select View YAML in the source pipeline agent job, and then select Copy to clipboard. Paste the YAML code into your new pipeline. Repeat these actions for each agent job in the pipeline.
Export and import a Classic pipeline
You can create a new Classic pipeline by exporting an existing Classic pipeline and importing it into the new pipeline. Use this process when the source pipeline and new pipeline are in different projects.
Build pipeline
You can export an existing build definition from a project, and then import it into another project.
Select the pipeline you want to clone from the list on the Pipelines page.
On the pipeline page, select the More actions icon at upper right, and then select Export to JSON. Export to JSON is available only for Classic pipelines.
The JSON file downloads to the download directory of your local machine per your browser settings.
In the project where you want your new pipeline, select Pipelines, select the More actions icon at upper right on the Pipelines page, and then select Import a pipeline.
Browse to and select the exported JSON file in your download directory, and then select Import.
The new pipeline opens with -import appended to the name. Rename and configure the pipeline as desired, and then select Save or Save & queue to save the imported pipeline.
Important
Exporting a pipeline strips any project specific data like agent pools and service connections. You have to configure these details for the new imported pipeline.
Release pipeline
The procedure for exporting and importing Classic release pipelines is similar to the Classic build pipeline procedure, but the menus and UI are slightly different.
To export a Classic release pipeline, navigate to Releases, choose the More actions icon, and select Export. The Export item is available only for Classic release pipelines.
To import a Classic release pipeline, navigate to Releases, choose New, and select Import release pipeline.