Skip to main content

Commit and Push in Job

This tutorial explains how to make code changes in build job, and push committed change back to OneDev server

  1. Make sure your account has code push permission over current project. Switch to my access token page and copy the value to clipboard

    Copy Access Token

  2. Edit project build setting to add a job secret using the value copied above

    Define Job Secret

  3. Configure checkout step of the job to retrieve source with http(s) credential, and choose job secret created above as access token

    Use Customized Clone Credential

  4. Add shell/batch step to call appropriate git commands to commit and push, for instance:

    Define Build Step

    Commands used in this example step:

    git config --global "Your Name"
    git config --global ""

    # Fetch and checkout master as OneDev by default clones
    # code up to current commit
    git fetch origin master:master
    git checkout master

    echo @build_number@ > build_number.txt
    git add build_number.txt
    git commit -m "Update build number"
    git push origin master:master
  5. In case you configured the job to fire automatically upon branch update, you will need to exclude files changed during job in the job trigger to avoid infinite loop. In this case we exclude build_number.txt as shown below: