Setting up remote tracking in Jenkins / Git

With Jenkins, I check out a project that later builds with SBT. But when he tries to execute the sbt-release plugin, he complains:

No tracking branch is set up. Either configure a remote tracking branch, or remove the pushChanges release part 

This is my Jenkins GIT plugin configuration:

  • Repository URL: points to a .git file
  • Name: empty
  • Refspec: blank
  • Branches to build / branch specifier (empty by default): develop (the branch I create)
  • Checkout / merge into a local branch (optional): develop

I installed these elements in accordance with the manual that answers this question .

I think the SBT-release plugin needs remote tracking to make a tag on a branch.

+6
source share
4 answers

To solve this problem, I have no choice but to create a command line script:

 git checkout develop || git checkout -b develop git reset --hard origin/develop git branch --set-upstream-to=origin/develop develop git pull 

and execute it before assembling the SBT.

+6
source

Assuming you want to build from a wizard.

In the Jenkins section of the GIT section, select:

 Branches to build: master 

also add:

 Additional Behaviours: Check out to specific local branch: master 

Build step

Run shell:

 git branch --set-upstream-to=origin/master master 

Then add SBT build step

 sbt "release with-defaults" 
+8
source

In my case, the remote was missing. To solve this problem, I used the following command lines before invoking Build using sbt.

 git remote add origin git@foo /bar.git || git remote -v git checkout master git reset --hard origin/master 
0
source

The .git/config file needs the following three lines:

 [branch "master"] remote = origin merge = refs/heads/master 

both other answers add them, but you can just add them manually

0
source

Source: https://habr.com/ru/post/945201/


All Articles