javagitgithubherokuheroku-cli

Heroku - Error during git push/deployment, The same version of this code has already been built


I have a problem deploying my springboot application to Heroku. After running git push heroku master, I am encountering the error below:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  9.350 s
[INFO] Finished at: 2020-12-22T06:33:14Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project audit: Fatal error compiling: invalid target release: 11 -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :audit
remote:  !     Push rejected, failed to compile Java app.
remote: 
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built:             31199a7acec03a3cb614ebaaf6c7720cee6684bd
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 31199a7acec03a3cb614ebaaf6c7720cee6684bd
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code     from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote: 
remote: Verifying deploy...
remote: 
remote: !   Push rejected to tesda8app.

I am clueless into why this error occurred. I have two remote repositories on which I push my code, one from Heroku and one in Github. I have tried the command below based from the answer from this question, Heroku: If you are developing on a branch and deploying via git you must run:

git push heroku master:main

But still the error persists. Is there any command that I could try on the Heroku CLI to solve this problem?


Solution

  • After some few tries, I was thinking that the cause of the problem was maybe an interrupted git push heroku master command, which was then proceeded by a re-execution of the same command, causing the error below:

    remote:  !     Push failed
    remote:  !
    remote:  ! ## Warning - The same version of this code has already been built:             31199a7acec03a3cb614ebaaf6c7720cee6684bd
    remote:  !
    remote:  ! We have detected that you have triggered a build from source code with version 31199a7acec03a3cb614ebaaf6c7720cee6684bd
    remote:  ! at least twice. One common cause of this behavior is attempting to deploy         code     from a different branch.
    remote:  !
    

    So what I did was, I pushed another commit, then retried the same command git push heroku master, which resulted to a successful deployment.

    Also, shoutout to RainXCat's answer and insights, now I know Heroku does not allow two git repositories on the same directory/folder.