Git Product home page Git Product logo

azure-devops-create-pr-task's Introduction

Build Release Extension
Build Status Release Status Extnesion

Azure DevOps Create Pull Request Task

An easy way to automatically create a Pull Request from your Build or Release Pipeline.

You can create a Pull Request to an Azure DevOps (Repos) repository or to a GitHub repository.

Support multi target branch (PR from one source branch to many target branches) and Draft Pull Request.

Choose title, description, reviewers and more.

Get the extension from the Azure DevOps marketplace.

Prerequisites

  • The task currently only works on Windows machines.

For Azure DevOps Repository:

  • You need to enable the "Allow scripts to access the OAuth token":

    • If you use the classic editor, go to the Agent job options, scroll down and check the checkbox "Allow scripts to access the OAuth token":

      Oauth

    • If you use yaml build, you need to map the variable in the task:

      env:
        System_AccessToken: $(System.AccessToken)
  • You need to give permissions to the build users:

    In Microsoft hosted agent is "Build Service (user-name)" and "Project Collection Build Service (Project)" (Sometimes the last only show up if you type the UUID (8837...) on "Search for user or groups".)

    Permissions

For GitHub Repository:

Usage

In the classic editor:

Task

  • Git repository type: Azure DevOps (Repos) or GitHub. When you choose GitHub you need to choose from the list the GitHub service connection (that use PAT authorization.)

  • GitHub Connection (authorized with PAT): When you choose GitHub in Git repository type you need to specify here the GitHub service connection.

  • Repository to use: The method for selecting the Git repository:

    • In Azure DevOps: 'Current build' will use the repository for which the current build is configured. 'Select' will allow you to select an Azure DevOps Repository from your account.

    • In GitHub: The default will be $(Build.Repository.Name) - the current build repo, but you can select other repos from the drop down list.

  • Is Forked Repository: [For Azure DevOps] If checked, it means the source branch it from a forked repository and not from the original. the target repo will be the currnet build repo.

  • Source branch name: The source branch that will be merged. The default value is the build source branch - $(Build.SourceBranch).

  • Target branch name: The target branch name that the source branch will be merge to him. For example: master.
    Supports also multi target branch with * - for example: test/*, or with ; - for example: master;test.

  • Title: The Pull Request title.

  • Description: The Pull Request description. (Optional).

  • Reviewers: The Pull Request reviewers (Optional):
    For Azure DevOps - one or more email address or team name separated by semicolon. For example: [email protected];MyTeamName.
    To make the reviewer required in Azure DevOps add 'req:' - e.g. req:[email protected]
    For GitHub - one or more usernames separated by semicolon. For example: user1;user2.

  • Create Draft Pull Request: If checked the pull request will be a Draft Pull Request. (Default: false)
    For Azure DevOps: see here more info.
    For GitHub: see here more info.

  • Link Work Items: If checked, all the work items that linked to the commits will be linked also to the PullRequest.

  • Pass Pull Request ID back to Azure DevOps as a variable: If checked, the Pull Request ID will be passed back to Azure DevOps for use in other pipeline tasks. The variable can be referenced as $(pullRequestId).

  • Set Auto Complete: Only for Azure DevOps. If checked the pull request will close once all branch policies are met.

    Complete options:

    • Merge Strategy: Specify the strategy used to merge the pull request during completion, see here more info.

      • Merge (No fast-forward) - noFastForward in yaml:

        A two-parent, no-fast-forward merge. The source branch is unchanged. This is the default behavior.

      • Squash commit - squash in yaml:

        Put all changes from the pull request into a single-parent commit.

      • Rebase and fast-forward - rebase in yaml:

        Rebase the source branch on top of the target branch HEAD commit, and fast-forward the target branch. The source branch is updated during the rebase operation.

      • Rebase and not fast-forward - rebaseMerge in yaml:

        Rebase the source branch on top of the target branch HEAD commit, and create a two-parent, no-fast-forward merge. The source branch is updated during the rebase operation.

    • Delete Source Branch: If true, the source branch of the pull request will be deleted after completion.

    • Commit Message: If set, this will be used as the commit message of the merge commit. if empty the default will be used.

    • Complete Associated Work Items: If true, we will attempt to transition any work items linked to the pull request into the next logical state (i.e. Active -> Resolved).

In yaml piepline:

- task: CreatePullRequest@1
  inputs:
    repoType: Azure DevOps / GitHub
    githubEndpoint: 'my-github' # When you choose GitHub in `repoType` you need to specify here the GitHub service connection
    # When you choose GitHub in `repoType`
    # you can also put here each repo from your GitHub account, for example: user/myrepo
    # If you not specify anything the default will be "$(Build.Repository.Name)".
    githubRepository: # Default: $(Build.Repository.Name).
    # When you choose Azure DevOps in `repoType` - by default the PR will be for the current repository
    # You can select another repository from this project or another project in your account
    # For this, specify `select` in `repositorySelectionMethod` and put the project id & git repo id
    repositorySelectionMethod: select
    projectId: '7fcdaf44-b831-4faa-b2fe-8k7a19a1d1af'
    gitRepositoryId: 'a743g5c4-85ec-4a4e-bf42-78964d551234'
    isForked: false / true (Default: false)
    sourceBranch: '$(Build.SourceBranch)'
    targetBranch: 'master' # Could be also "release/*" or "master;release"
    title: 'Test'
    description: 'Test' # Optional
    reviewers: For Azure DevOps: '[email protected];MyTeam'. For GitHub: `username;username2` # Optional
    # To make the reviewer required in Azure DevOps add 'req:' - e.g. 'req:[email protected]'
    isDraft: false / true (Default: false)
    linkWorkItems: false / true (Default: true)
    passPullRequestIdBackToADO: false / true (Default: false)
    autoComplete: false / true (Default: false)
    mergeStrategy: 'noFastForward (default) / squash / rebase / rebaseMerge'
    deleteSourch:  false / true (Default: false) # Optional
    commitMessage: 'Test Comment' # Optional
    transitionWorkItems:  false / true (Default: false) # Optional
  env:
    System_AccessToken: $(System.AccessToken)

Known issue(s)

  • In TFS 2018 you can't use reviewers. still can create a PR without it.

Release Notes

1.2.186

  • Support also TFS 2018 RTW + Update 1 versions.

1.2.180

  • Support also Azure DevOps forks repsitores (to create PR from the forked repo to the original repo)

1.2.158

  • Support also multi-target branch separated with a semicolon, for example: master;release

1.2.144

  • Support also Azure DevOps groups as reviewers (not also users and teams).

1.2.140

  • Return the Pull Request ID as a variable for use in the sequences tasks.

1.2.130

  • Now you can add also required reviewers. (for Azure DevOps).

1.2.123

  • Ability to choose other repos from your GitHub account. As a result, you can also create GitHub PR from a Release pipeline.

1.2.89

  • Throw a warning when there are no commits in the source branch, instead of create a PR (for Azure DevOps).

1.2.76

  • Create PR for other repositories - not only for the current build repo (for Azure DevOps)

1.2.48

  • Link associated work items to the PR (for Azure DevOps)

1.2.36

  • Add complete options like Merge Strategy and more in auto completion (for Azure DevOps).

1.2.30

  • Support also a Team as reviewers (for Azure DevOps).

1.2.24

  • Set Auto Complete the Pull Request (for Azure DevOps).

1.2.18

  • Bug fix: Now you can add reviewers also in TFS 2018 and Azure DevOps Server 2019.

1.2.15

  • Draft Pull Request option.

1.2.0

  • Support also GitHub repositories!

1.0.31

  • Multi target branch (For example: feature/*)

1.0.0

  • First version.

azure-devops-create-pr-task's People

Contributors

berreek avatar cbsreshimvse avatar daxaar avatar deadlydog avatar shayki5 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.