Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-24082

Be able to force push for branch on git publisher

    Details

    • Similar Issues:

      Description

      We can't force push when pushing to a remote branch.

        Attachments

          Issue Links

            Activity

            guilhem Guilhem Lettron created issue -
            markewaite Mark Waite made changes -
            Field Original Value New Value
            Link This issue is related to JENKINS-22601 [ JENKINS-22601 ]
            Hide
            markewaite Mark Waite added a comment -

            Force push from a Jenkins job seems like a very dangerous option.

            Can you describe further why you want a Jenkins job to be able to delete history from a repository?

            The Jenkins plugin can merge, and can push that merge result, so long as no intervening commit has been pushed to the destination branch in the central repository. If an intervening commit has been pushed to the destination branch, then the Jenkins job is not allowed to push the merge result because it would overwrite the intervening commit with that forced push.

            Show
            markewaite Mark Waite added a comment - Force push from a Jenkins job seems like a very dangerous option. Can you describe further why you want a Jenkins job to be able to delete history from a repository? The Jenkins plugin can merge, and can push that merge result, so long as no intervening commit has been pushed to the destination branch in the central repository. If an intervening commit has been pushed to the destination branch, then the Jenkins job is not allowed to push the merge result because it would overwrite the intervening commit with that forced push.
            Hide
            guilhem Guilhem Lettron added a comment -

            Yes, of course force push is really dangerous.

            But in our case it's needed, for example, we are using https://gemfury.com/ service.
            With this we can push code to be build directly with git: http://devcenter.gemfury.com/articles/git-push-package.html

            But, as we have to always push on remote master branch, it's needed to force push.

            For example:
            we have 2 current branch for our software 2.4 and master (future 3.0).
            we are pushing master to master for building 3.0.0-dev version and then push --force 2.4 to master for building 2.4.0-dev.

            It's really awesome.

            I already have a wroking branch here: https://github.com/guilhem/git-plugin/tree/forceOption
            Just need to fix credentials :/ (don't know how to do...)

            Show
            guilhem Guilhem Lettron added a comment - Yes, of course force push is really dangerous. But in our case it's needed, for example, we are using https://gemfury.com/ service. With this we can push code to be build directly with git: http://devcenter.gemfury.com/articles/git-push-package.html But, as we have to always push on remote master branch, it's needed to force push. For example: we have 2 current branch for our software 2.4 and master (future 3.0). we are pushing master to master for building 3.0.0-dev version and then push --force 2.4 to master for building 2.4.0-dev. It's really awesome. I already have a wroking branch here: https://github.com/guilhem/git-plugin/tree/forceOption Just need to fix credentials :/ (don't know how to do...)
            Show
            guilhem Guilhem Lettron added a comment - Here is a PR https://github.com/jenkinsci/git-plugin/pull/248
            Hide
            wannessels Wannes Sels added a comment -

            Here's our use case:

            We have multiple jobs for feature branches. Often somebody wants to push their changes to have them built by Jenkins, but not yet merged/pushed to team/release branch. Instead of removing the push configuration from the job (and having to add it again afterwards, very error prone), we separate the job in 2 jobs: 1 build job and 1 push job. The developers can then disable/enable the push job at will.

            The build job merges with bugfix/current-release/next-release branches, and pushes that merge commit (after a successful build) to a temporary branch <jenkins/feature-branch>. The push job then pushes that to the next-release branch. If that merge commit doesn't make it to next-release branch (push job was disabled, or someone else pushed to next-release branch first), that merge commit is essentially useless. The next run the build job creates a new merge commit, but can't push to <jenkins/feature-branch> because the new merge commit is non-fast-forward to the old commit. We need a force push to overwrite the old commit on the temporary branch

            Show
            wannessels Wannes Sels added a comment - Here's our use case: We have multiple jobs for feature branches. Often somebody wants to push their changes to have them built by Jenkins, but not yet merged/pushed to team/release branch. Instead of removing the push configuration from the job (and having to add it again afterwards, very error prone), we separate the job in 2 jobs: 1 build job and 1 push job. The developers can then disable/enable the push job at will. The build job merges with bugfix/current-release/next-release branches, and pushes that merge commit (after a successful build) to a temporary branch <jenkins/feature-branch>. The push job then pushes that to the next-release branch. If that merge commit doesn't make it to next-release branch (push job was disabled, or someone else pushed to next-release branch first), that merge commit is essentially useless. The next run the build job creates a new merge commit, but can't push to <jenkins/feature-branch> because the new merge commit is non-fast-forward to the old commit. We need a force push to overwrite the old commit on the temporary branch
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Wannes Sels
            Path:
            src/test/java/hudson/plugins/git/GitPublisherTest.java
            http://jenkins-ci.org/commit/git-plugin/b14f6f4398c0ccfb88392dfda8baaf2ef9e3a2c8
            Log:
            added testcase for force push JENKINS-24082

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Wannes Sels Path: src/test/java/hudson/plugins/git/GitPublisherTest.java http://jenkins-ci.org/commit/git-plugin/b14f6f4398c0ccfb88392dfda8baaf2ef9e3a2c8 Log: added testcase for force push JENKINS-24082
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Guilhem Lettron
            Path:
            src/test/java/hudson/plugins/git/GitPublisherTest.java
            http://jenkins-ci.org/commit/git-plugin/ef6bc1856202a8d7a936ce881b083517bc1e28a3
            Log:
            Merge pull request #1 from wannessels/forceOption

            added testcase for force push JENKINS-24082

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Guilhem Lettron Path: src/test/java/hudson/plugins/git/GitPublisherTest.java http://jenkins-ci.org/commit/git-plugin/ef6bc1856202a8d7a936ce881b083517bc1e28a3 Log: Merge pull request #1 from wannessels/forceOption added testcase for force push JENKINS-24082
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Wannes Sels
            Path:
            src/main/java/hudson/plugins/git/GitPublisher.java
            src/main/resources/hudson/plugins/git/GitPublisher/config.jelly
            src/test/java/hudson/plugins/git/GitPublisherTest.java
            http://jenkins-ci.org/commit/git-plugin/cebb9da131fa6c9e07ec9e6ff71ec89aa58fdd6f
            Log:
            Merge pull request #248 from guilhem/forceOption

            [FIXED JENKINS-24082] Add a force option to push command

            Compare: https://github.com/jenkinsci/git-plugin/compare/adc96942cd67...cebb9da131fa

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Wannes Sels Path: src/main/java/hudson/plugins/git/GitPublisher.java src/main/resources/hudson/plugins/git/GitPublisher/config.jelly src/test/java/hudson/plugins/git/GitPublisherTest.java http://jenkins-ci.org/commit/git-plugin/cebb9da131fa6c9e07ec9e6ff71ec89aa58fdd6f Log: Merge pull request #248 from guilhem/forceOption [FIXED JENKINS-24082] Add a force option to push command Compare: https://github.com/jenkinsci/git-plugin/compare/adc96942cd67...cebb9da131fa
            scm_issue_link SCM/JIRA link daemon made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Wannes Sels
            Path:
            src/test/java/hudson/plugins/git/GitPublisherTest.java
            http://jenkins-ci.org/commit/git-plugin/db14f9f5659794a146ee4850e7f63795f6b10e77
            Log:
            fixed GitPublisherTest.testForcePush , was not deterministic JENKINS-24082

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Wannes Sels Path: src/test/java/hudson/plugins/git/GitPublisherTest.java http://jenkins-ci.org/commit/git-plugin/db14f9f5659794a146ee4850e7f63795f6b10e77 Log: fixed GitPublisherTest.testForcePush , was not deterministic JENKINS-24082
            Hide
            markewaite Mark Waite added a comment -

            Fixed in git plugin 2.2.6, released 20 Sep 2014

            Show
            markewaite Mark Waite added a comment - Fixed in git plugin 2.2.6, released 20 Sep 2014
            markewaite Mark Waite made changes -
            Status Resolved [ 5 ] Closed [ 6 ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 156955 ] JNJira + In-Review [ 207924 ]

              People

              • Assignee:
                ndeloof Nicolas De Loof
                Reporter:
                guilhem Guilhem Lettron
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: