Search code examples
gitjenkinsjenkins-git-plugin

Jenkins Git Publish fails when pushing a branch; no stderror shown


Our build includes a local shell command creating a local git branch based on the parameter that starts the build. After copying the files to their destination the goal is to push the new branch to the repository so that if there are future updates to that branch they can be pulled. In the post build I create and the branch to push and both end in error with the following

using GIT_ASKPASS to set credentials PAT (****)
 > /usr/bin/git push *GITURL* HEAD:UAT-sprint-20-96 -f # timeout=10
ERROR: Failed to push branch UAT-sprint-20-96 to origin
hudson.plugins.git.GitException: Command "/usr/bin/git push *GIT_URL* HEAD:UAT-sprint-20-96 -f" returned status code 128:
stdout: 
stderr: 
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$8.execute(CliGitAPIImpl.java:2536)
    at hudson.plugins.git.GitPublisher.perform(GitPublisher.java:316)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:804)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:753)
    at hudson.model.Build$BuildExecution.post2(Build.java:177)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:698)
    at hudson.model.Run.execute(Run.java:1932)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
Build step 'Git Publisher' marked build as failure

(The GIT_URL is just my replacement of the actual URL for privacy) There's no actual error in the stderr so its hard to figure out what happens when it fails. Running the actual command in the server CLI works ok, asking username and password. This server doesn't have an actual public IP; its Internet access is through our company's network. The fact that I can clone the repository suggests that this isn't a connectivity issue, but I could be wrong. I've looked around to see if anyone has had this issue but what I find relates to Pipeline jobs (which this is not). We also tried to push the branch using the "Run a shell script" option, but it fails spectacularly, even when including the username and token into the URL. Has anyone come across this? We use Azure Dev Ops as our git. Any insight will be helpful. Thank you.


Solution

  • This turned out to be a configuration error on my part. The Jenkins configuration, for some reason that eludes me, was passing or concatenating earlier values into the branch name which results in a Git branch (UAT-sprint-20-96) that didn't exist.