java.io.IOException: Failed checkout branch: Command "/usr/bin/git checkout -b release-0.2.2" returned status code 128: stdout: stderr: fatal: A branch named 'release-0.2.2' already exists.

JFrog JIRA | Ryan Maki | 3 years ago
  1. 0

    The Artifactory Release process can leave invalid branches in the local Git repository when it fails. When a release build fails I expect to see: {noformat} [RELEASE] Deleting local git branch: release-0.2 [RELEASE] Deleting remote branch 'release-0.2' on 'git@test-repo.git [RELEASE] Deleting local tag: 0.2 [RELEASE] Deleting remote tag '0.2' from 'git@test-repo.git' [RELEASE] Reverting git working copy back to initial commit: 111ece6c5ec424c42edd0c4175a1044a59511866 {noformat} But this didn't happen for the following failure when the artifact was mistakenly released to a snapshot repository and rejected: {noformat} * What went wrong: Execution failed for task ':artifactoryPublish'. > Failed to deploy file: HTTP response code: 409. HTTP response message: Conflict ... ERROR: [RELEASE] Failed on build completion java.io.IOException: Failed checkout branch: Command "/usr/bin/git checkout develop" returned status code 1: stdout: stderr: error: Your local changes to the following files would be overwritten by checkout: gradle.properties Please, commit your changes or stash them before you can switch branches. Aborting at org.jfrog.hudson.release.scm.git.GitManager$CheckoutBranchCallable.invoke(GitManager.java:234) at org.jfrog.hudson.release.scm.git.GitManager$CheckoutBranchCallable.invoke(GitManager.java:199) at hudson.FilePath.act(FilePath.java:865) at hudson.FilePath.act(FilePath.java:838) at org.jfrog.hudson.release.scm.git.GitManager.checkoutBranch(GitManager.java:60) at org.jfrog.hudson.release.scm.git.GitCoordinator.buildCompleted(GitCoordinator.java:142) at org.jfrog.hudson.gradle.ArtifactoryGradleConfigurator$ReleaseRunListener.onCompleted(ArtifactoryGradleConfigurator.java:660) at org.jfrog.hudson.gradle.ArtifactoryGradleConfigurator$ReleaseRunListener.onCompleted(ArtifactoryGradleConfigurator.java:630) at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:199) at hudson.model.Run.execute(Run.java:1625) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:237) {noformat} The build exited without cleaning up the repo. Subsequent release builds also fail because the local branch exists: {noformat} [RELEASE] Release build triggered FATAL: Failed checkout branch: Command "/usr/bin/git checkout -b release-0.2.2" returned status code 128: stdout: stderr: fatal: A branch named 'release-0.2.2' already exists. java.io.IOException: Failed checkout branch: Command "/usr/bin/git checkout -b release-0.2.2" returned status code 128: stdout: stderr: fatal: A branch named 'release-0.2.2' already exists. at org.jfrog.hudson.release.scm.git.GitManager$CheckoutBranchCallable.invoke(GitManager.java:234) at org.jfrog.hudson.release.scm.git.GitManager$CheckoutBranchCallable.invoke(GitManager.java:199) at hudson.FilePath.act(FilePath.java:865) at hudson.FilePath.act(FilePath.java:838) at org.jfrog.hudson.release.scm.git.GitManager.checkoutBranch(GitManager.java:60) at org.jfrog.hudson.release.scm.git.GitCoordinator.beforeReleaseVersionChange(GitCoordinator.java:80) at org.jfrog.hudson.release.gradle.GradleReleaseWrapper.setUp(GradleReleaseWrapper.java:139) at org.jfrog.hudson.gradle.ArtifactoryGradleConfigurator.setUp(ArtifactoryGradleConfigurator.java:358) at hudson.model.Build$BuildExecution.doRun(Build.java:154) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:580) at hudson.model.Run.execute(Run.java:1575) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:237) {noformat} In this case {{release-0.2.2}} only exists on the Jenkins build machine. I need to know this and wipe the workspace in order for the build to proceed. I've tried to use the Git plugin option to "Prune remote branches before build" but that didn't help. This situation is easy to get into and takes some level of investigation to correct.

    JFrog JIRA | 3 years ago | Ryan Maki
    java.io.IOException: Failed checkout branch: Command "/usr/bin/git checkout -b release-0.2.2" returned status code 128: stdout: stderr: fatal: A branch named 'release-0.2.2' already exists.
  2. 0

    The Artifactory Release process can leave invalid branches in the local Git repository when it fails. When a release build fails I expect to see: {noformat} [RELEASE] Deleting local git branch: release-0.2 [RELEASE] Deleting remote branch 'release-0.2' on 'git@test-repo.git [RELEASE] Deleting local tag: 0.2 [RELEASE] Deleting remote tag '0.2' from 'git@test-repo.git' [RELEASE] Reverting git working copy back to initial commit: 111ece6c5ec424c42edd0c4175a1044a59511866 {noformat} But this didn't happen for the following failure when the artifact was mistakenly released to a snapshot repository and rejected: {noformat} * What went wrong: Execution failed for task ':artifactoryPublish'. > Failed to deploy file: HTTP response code: 409. HTTP response message: Conflict ... ERROR: [RELEASE] Failed on build completion java.io.IOException: Failed checkout branch: Command "/usr/bin/git checkout develop" returned status code 1: stdout: stderr: error: Your local changes to the following files would be overwritten by checkout: gradle.properties Please, commit your changes or stash them before you can switch branches. Aborting at org.jfrog.hudson.release.scm.git.GitManager$CheckoutBranchCallable.invoke(GitManager.java:234) at org.jfrog.hudson.release.scm.git.GitManager$CheckoutBranchCallable.invoke(GitManager.java:199) at hudson.FilePath.act(FilePath.java:865) at hudson.FilePath.act(FilePath.java:838) at org.jfrog.hudson.release.scm.git.GitManager.checkoutBranch(GitManager.java:60) at org.jfrog.hudson.release.scm.git.GitCoordinator.buildCompleted(GitCoordinator.java:142) at org.jfrog.hudson.gradle.ArtifactoryGradleConfigurator$ReleaseRunListener.onCompleted(ArtifactoryGradleConfigurator.java:660) at org.jfrog.hudson.gradle.ArtifactoryGradleConfigurator$ReleaseRunListener.onCompleted(ArtifactoryGradleConfigurator.java:630) at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:199) at hudson.model.Run.execute(Run.java:1625) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:237) {noformat} The build exited without cleaning up the repo. Subsequent release builds also fail because the local branch exists: {noformat} [RELEASE] Release build triggered FATAL: Failed checkout branch: Command "/usr/bin/git checkout -b release-0.2.2" returned status code 128: stdout: stderr: fatal: A branch named 'release-0.2.2' already exists. java.io.IOException: Failed checkout branch: Command "/usr/bin/git checkout -b release-0.2.2" returned status code 128: stdout: stderr: fatal: A branch named 'release-0.2.2' already exists. at org.jfrog.hudson.release.scm.git.GitManager$CheckoutBranchCallable.invoke(GitManager.java:234) at org.jfrog.hudson.release.scm.git.GitManager$CheckoutBranchCallable.invoke(GitManager.java:199) at hudson.FilePath.act(FilePath.java:865) at hudson.FilePath.act(FilePath.java:838) at org.jfrog.hudson.release.scm.git.GitManager.checkoutBranch(GitManager.java:60) at org.jfrog.hudson.release.scm.git.GitCoordinator.beforeReleaseVersionChange(GitCoordinator.java:80) at org.jfrog.hudson.release.gradle.GradleReleaseWrapper.setUp(GradleReleaseWrapper.java:139) at org.jfrog.hudson.gradle.ArtifactoryGradleConfigurator.setUp(ArtifactoryGradleConfigurator.java:358) at hudson.model.Build$BuildExecution.doRun(Build.java:154) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:580) at hudson.model.Run.execute(Run.java:1575) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:237) {noformat} In this case {{release-0.2.2}} only exists on the Jenkins build machine. I need to know this and wipe the workspace in order for the build to proceed. I've tried to use the Git plugin option to "Prune remote branches before build" but that didn't help. This situation is easy to get into and takes some level of investigation to correct.

    JFrog JIRA | 3 years ago | Ryan Maki
    java.io.IOException: Failed checkout branch: Command "/usr/bin/git checkout -b release-0.2.2" returned status code 128: stdout: stderr: fatal: A branch named 'release-0.2.2' already exists.
  3. 0

    Jenkins + Git + Artifactory Release Staging

    Stack Overflow | 3 years ago | user2684301
    java.io.IOException: Failed checkout branch: Command "git checkout master" returned status code 1: stdout: stderr: error: pathspec 'master' did not match any file(s) known to git.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    We are using Atlassian Stash as SCM, jenkins as CI-Server and Artifactory as binary version control. I have a job setup to pull from stash (with private/public ssh key pair), build and publish to artifactory. This build runs smoothly. But when i try to stage a release build with the artifactory plugin form within the jenkins job, i get the following errors at the end of the build: {code}[RELEASE] Committing release version on branch 'release/project-0.0.2' [RELEASE] Creating tag 'project-0.0.2' [RELEASE] Pushing branch 'release/project-0.0.2' to 'ssh://git@gitserver:7999/test/project_main.git' Failure in post build SCM action: Failed to push: Command "git push ssh://git@gitserver:7999/test/project_main.git refs/heads/release/project-0.0.2" returned status code 128: stdout: stderr: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ERROR: [RELEASE] Failed on build completion java.io.IOException: Failed checkout branch: Command "git checkout develop" returned status code 1: stdout: stderr: error: pathspec 'develop' did not match any file(s) known to git. at org.jfrog.hudson.release.scm.git.GitManager$CheckoutBranchCallable.invoke(GitManager.java:234) at org.jfrog.hudson.release.scm.git.GitManager$CheckoutBranchCallable.invoke(GitManager.java:199) at hudson.FilePath.act(FilePath.java:914) at hudson.FilePath.act(FilePath.java:887) at org.jfrog.hudson.release.scm.git.GitManager.checkoutBranch(GitManager.java:60) at org.jfrog.hudson.release.scm.git.GitCoordinator.buildCompleted(GitCoordinator.java:137) at org.jfrog.hudson.release.maven.MavenReleaseWrapper$ReleaseRunListener.onCompleted(MavenReleaseWrapper.java:308) at org.jfrog.hudson.release.maven.MavenReleaseWrapper$ReleaseRunListener.onCompleted(MavenReleaseWrapper.java:276) at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:199) at hudson.model.Run.execute(Run.java:1720) at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:519) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:231) Finished: FAILURE {code} When i change the authentication with Stash to username and password i get a different error just saying "authentication failed". So the plugin seems to fetch the credentials from the git client plugin. But for some reasing it can't push anyways. The user has the necessary rights inside stash. Can anybody point me in the right direction, how to solve this issue or at least, where i could go on searching for the root cause. Thanks in advance

    Jenkins JIRA | 3 years ago | Christopher Timm
    java.io.IOException: Failed checkout branch: Command "git checkout develop" returned status code 1: stdout: stderr: error: pathspec 'develop' did not match any file(s) known to git.
  6. 0

    We are using Atlassian Stash as SCM, jenkins as CI-Server and Artifactory as binary version control. I have a job setup to pull from stash (with private/public ssh key pair), build and publish to artifactory. This build runs smoothly. But when i try to stage a release build with the artifactory plugin form within the jenkins job, i get the following errors at the end of the build: {code}[RELEASE] Committing release version on branch 'release/project-0.0.2' [RELEASE] Creating tag 'project-0.0.2' [RELEASE] Pushing branch 'release/project-0.0.2' to 'ssh://git@gitserver:7999/test/project_main.git' Failure in post build SCM action: Failed to push: Command "git push ssh://git@gitserver:7999/test/project_main.git refs/heads/release/project-0.0.2" returned status code 128: stdout: stderr: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ERROR: [RELEASE] Failed on build completion java.io.IOException: Failed checkout branch: Command "git checkout develop" returned status code 1: stdout: stderr: error: pathspec 'develop' did not match any file(s) known to git. at org.jfrog.hudson.release.scm.git.GitManager$CheckoutBranchCallable.invoke(GitManager.java:234) at org.jfrog.hudson.release.scm.git.GitManager$CheckoutBranchCallable.invoke(GitManager.java:199) at hudson.FilePath.act(FilePath.java:914) at hudson.FilePath.act(FilePath.java:887) at org.jfrog.hudson.release.scm.git.GitManager.checkoutBranch(GitManager.java:60) at org.jfrog.hudson.release.scm.git.GitCoordinator.buildCompleted(GitCoordinator.java:137) at org.jfrog.hudson.release.maven.MavenReleaseWrapper$ReleaseRunListener.onCompleted(MavenReleaseWrapper.java:308) at org.jfrog.hudson.release.maven.MavenReleaseWrapper$ReleaseRunListener.onCompleted(MavenReleaseWrapper.java:276) at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:199) at hudson.model.Run.execute(Run.java:1720) at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:519) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:231) Finished: FAILURE {code} When i change the authentication with Stash to username and password i get a different error just saying "authentication failed". So the plugin seems to fetch the credentials from the git client plugin. But for some reasing it can't push anyways. The user has the necessary rights inside stash. Can anybody point me in the right direction, how to solve this issue or at least, where i could go on searching for the root cause. Thanks in advance

    Jenkins JIRA | 3 years ago | Christopher Timm
    java.io.IOException: Failed checkout branch: Command "git checkout develop" returned status code 1: stdout: stderr: error: pathspec 'develop' did not match any file(s) known to git.

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.io.IOException

      Failed checkout branch: Command "/usr/bin/git checkout -b release-0.2.2" returned status code 128: stdout: stderr: fatal: A branch named 'release-0.2.2' already exists.

      at org.jfrog.hudson.release.scm.git.GitManager$CheckoutBranchCallable.invoke()
    2. org.jfrog.hudson
      GitManager$CheckoutBranchCallable.invoke
      1. org.jfrog.hudson.release.scm.git.GitManager$CheckoutBranchCallable.invoke(GitManager.java:234)
      2. org.jfrog.hudson.release.scm.git.GitManager$CheckoutBranchCallable.invoke(GitManager.java:199)
      2 frames
    3. Hudson
      FilePath.act
      1. hudson.FilePath.act(FilePath.java:865)
      2. hudson.FilePath.act(FilePath.java:838)
      2 frames
    4. org.jfrog.hudson
      ArtifactoryGradleConfigurator.setUp
      1. org.jfrog.hudson.release.scm.git.GitManager.checkoutBranch(GitManager.java:60)
      2. org.jfrog.hudson.release.scm.git.GitCoordinator.beforeReleaseVersionChange(GitCoordinator.java:80)
      3. org.jfrog.hudson.release.gradle.GradleReleaseWrapper.setUp(GradleReleaseWrapper.java:139)
      4. org.jfrog.hudson.gradle.ArtifactoryGradleConfigurator.setUp(ArtifactoryGradleConfigurator.java:358)
      4 frames
    5. Hudson
      Executor.run
      1. hudson.model.Build$BuildExecution.doRun(Build.java:154)
      2. hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:580)
      3. hudson.model.Run.execute(Run.java:1575)
      4. hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      5. hudson.model.ResourceController.execute(ResourceController.java:88)
      6. hudson.model.Executor.run(Executor.java:237)
      6 frames