Add CreatePullRequestStep as a built-in CI/CD step (like CreateBranchStep) #2714
Zak Siddiqui opened 4 months ago

Problem

Currently, OneDev has a built-in CreateBranchStep that can be used in CI/CD jobs to automatically create a branch when an issue transitions to a certain state. This is great.

However, there is no equivalent CreatePullRequestStep. To auto-create a pull request after the branch is created, you have to write a CommandStep with a curl call to the REST API (POST /~api/pulls), which requires:

  • Setting up access tokens and job secrets
  • Hardcoding or looking up project IDs
  • Manually constructing JSON payloads
  • Figuring out the correct API authentication

This is unnecessarily complex for what should be a basic workflow.

Desired Solution

Add a CreatePullRequestStep as a first-class built-in step type (just like CreateBranchStep), with the following fields:

  • Source Branch - supporting variables like @suggested_issue_branch@
  • Target Branch - defaulting to the project's default branch (e.g., main)
  • Title - supporting variables like Issue @issue_number@ - @issue_title@
  • Description - supporting variables, defaulting to something like fix #@issue_number@
  • Merge Strategy - dropdown (Create Merge Commit, Squash, Rebase)
  • Reviewer IDs - optional
  • Assignee IDs - optional

Use Case

The ideal workflow that many teams expect (and that GitLab CE provides with one click) is:

  1. Create an issue
  2. Transition issue to "In Progress"
  3. Branch is auto-created ✅ (already possible with CreateBranchStep)
  4. Pull request is auto-created ❌ (this is the missing piece)
  5. Developer works on the branch and commits with fix #123
  6. PR is merged → issue auto-closes

Example Build Spec (Desired)

jobs:
- name: Auto Create Issue Branch and PR
  steps:
  - type: CreateBranchStep
    name: Create Branch
    branchName: '@suggested_issue_branch@'
    branchRevision: main
  - type: CreatePullRequestStep
    name: Create Pull Request
    sourceBranch: '@suggested_issue_branch@'
    targetBranch: main
    title: '@issue_number@ - @issue_title@'
    description: 'fix #@issue_number@'
    mergeStrategy: CREATE_MERGE_COMMIT
  triggers:
  - type: IssueInStateTrigger
    state: In Progress

Why This Matters

  • The CreateBranchStep was a fantastic addition - this is the natural next step
  • The REST API workaround is fragile and requires managing secrets/tokens
  • GitLab CE offers this as a one-click workflow out of the box
  • This would make OneDev's issue → branch → PR → merge → close workflow fully seamless without any API hacking

Thank you for considering this. OneDev's CI/CD flexibility is already incredibly powerful - this would complete the picture and allow us to migrate away from OneDev GitLab

  • Robin Shen changed fields 4 months ago
    Name Previous Value Current Value
    Type
    Question
    New Feature
  • BCVerdouw commented 3 months ago

    I would like to see this as well, this seems like very desirable functionality, but I do believe that step 4 and 5 in the use case should be reversed. As far as I know it's not possible to create a Pull request if there are no differences between source and target branch.

  • Robin Shen commented 3 months ago

    Plan to get this into next major release.

  • OneDev commented 3 months ago

    State changed as build OD-7256 (15.0.0) is successful

  • OneDev changed state to 'Closed' 3 months ago
    Previous Value Current Value
    Open
    Closed
  • Zak Siddiqui commented 1 month ago

    THANKYOU THANKYOU THANKYOU THANKYOU THANKYOU THANKYOU THANKYOU THANKYOU THANKYOU !!!!!!!!!!!!!!!!!!!!!

  • Zak Siddiqui commented 2 weeks ago

    I would like to see this as well, this seems like very desirable functionality, but I do believe that step 4 and 5 in the use case should be reversed. As far as I know it's not possible to create a Pull request if there are no differences between source and target branch.

    I now agree @bcverdouw. I did not know this at the time of creating the original post. (I came from GitLab where it is possible to do this and it's actually part of the regular workflow to create the branch and the merge request at the same time).

  • Zak Siddiqui commented 2 weeks ago

    Thanks @robin

1/1
Type
New Feature
Priority
Normal
Assignee
Labels
No labels
Issue Votes (0)
Watchers (4)
Reference
OD-2714
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover