89

I'm currently using GitHub with a basic Jenkins integration (with the GitHub plugin): each time I push something, my Jenkins tests are triggered and the status is reported to GitHub.

For some dirty reasons (and I know the root cause is here), my tests could randomly fail and then report a failed status to GitHub (which blocked the possibility to merge the PR: and that's the expected behavior).

Do you know if it's possible to relaunch the tests without pushing a new commit? Because I know if I relaunch the tests, they will pass.

ZygD
  • 22,092
  • 39
  • 79
  • 102
Labynocle
  • 4,062
  • 7
  • 22
  • 24

6 Answers6

83

Update: you can also push an empty commit to your branch to re-trigger status checks: git commit -m "retrigger checks" --allow-empty and then git push <branchname>

You can do this by closing and then re-opening the Pull Request. This will cause all status checks to run again on the same commit.

Adil B
  • 14,635
  • 11
  • 60
  • 78
  • 2
    It seems to work ! But I wonder if there was a better to do this :) – Labynocle Sep 20 '18 at 09:35
  • True! This does feel like a strange way to do it :) – Adil B Sep 20 '18 at 14:59
  • 1
    In my case with AWS CodeBuild, it looks as if closing and reopening the PR doesn't work, but in fact it does. Just need to wait for a few minutes for the status to update. The yellow progress indicator is not being shown. –  Jul 10 '19 at 07:32
  • Currently with github actions this does launch a new check, but even if it succeeds, the previous failed status checks are not removed, preventing merging if passing is required. Georgi's git amend method above causes the checks to fully reset. – Roman Scher Dec 04 '19 at 02:33
43

Doing git commit --amend and force pushing makes github retrigger all checks. Not perfect but better than closing then reopening the PR.

Georgi Sabev
  • 431
  • 4
  • 2
  • 4
    Just make sure no one has pulled your last commit before force-pushing or you're all going to have a bad time. – Scott Schupbach Dec 07 '20 at 23:10
  • 2
    For what its worth, this method works because commit date/time are inputs for the commit hash. Therefore, Git (and GitHub) will recognize this commit as new, even though file contents have not changed. – t-mart Feb 28 '21 at 06:07
13

There's now a button in the Github UI to rerun checks. Not sure if it works for Jenkins, but it worked for my situation.

enter image description here

DharmaTurtle
  • 6,858
  • 6
  • 38
  • 52
10

If you open a PR that failed, under Checks tab you will see the list of all checks that were performed on your PR. Next to the failed ones, there will be a clickable text that says "Re-run"

enter image description here

Igor
  • 1,349
  • 12
  • 25
2

Depending on how you have integrated Github with Jenkins and what plugin you have have used, the method might vary. But usually you have support for "magic"-sentences that will retrigger Jenkins if added as a comment on Github.

For example commenting "test this please" or "retest this please" in Github might retrigger Jenkins.

Cleared
  • 2,490
  • 18
  • 35
  • 1
    do you have any example to suggest ? I'm using a basic Jenkins integration (with the Github plugin) – Labynocle Oct 30 '18 at 17:56
  • If I'm not mistaken there is a separate Jenkins plugin for Pull Request in Github, I suggest you start by looking into that. I'm thinking about https://wiki.jenkins.io/plugins/servlet/mobile?contentId=63930613#content/view/63930613, but it looks like there is a newer version of it. – Cleared Oct 31 '18 at 18:07
-3

Seems like closing and re-opening the PR could be an option.