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

ReviewBot can't apply the diff and failed to patch file

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • None
    • Jenkins ver. 1.575
      jenkins-reviewbot 2.0
      Review Board 2.0.5
      git version 1.9.1
      Ubuntu 14.04.1 LTS

      Hello!

      Please help to find solution for the following issue (bug?):
      ReviewBot can't apply diff and patch file if modifications has been done in the middle of the file (Jenkins build failed).
      In case of addition modifications only to the new line in the END of the file - all is OK. (Jenkins build passed).

      Here are details:

      1. I've added only one word "#comment" at 3rd line:
      1: #!/bin/bash
      2: echo "Hello"
      3: echo "I am script# 1" #comment <--Only word "#comment" has been added.
      4: exit
      Then git commit and git push.

      2. See git log from GIT client:
      root@sochi-1:/opt/git_client# git log -p -1 dev
      commit f4d46f33fe2f4c5cd41cb938d5152fcff896d473
      Author: akoryag
      Date: Mon Aug 18 18:17:23 2014 +0400

      reviewgroup #review-grouprefs #11: only comment added

      diff --git a/_ak.sh b/_ak.sh
      index 87295da..39ab760 100644
      — a/_ak.sh
      +++ b/_ak.sh
      @@ -1,4 +1,4 @@
      #!/bin/bash
      echo "Hello"
      -echo "I am script# 1"
      +echo "I am script# 1" #comment
      exit
      \ No newline at end of file

      3. Check git diff:
      root@sochi-1:/opt/git_client# git diff 87295da 39ab760
      diff --git a/87295da b/39ab760
      index 87295da..39ab760 100644
      — a/87295da
      +++ b/39ab760
      @@ -1,4 +1,4 @@
      #!/bin/bash
      echo "Hello"
      -echo "I am script# 1"
      +echo "I am script# 1" #comment
      exit
      \ No newline at end of file

      4. Check generated diff file from ReviewBoard "rb17.patch" (the same as above):
      diff --git a/_ak.sh b/_ak.sh
      index 87295daca19ff8d315fc6079bc2e9628e88b83ca..39ab7607fb59590e2e16e26fcbd77c58a2c27a6a 100644
      — a/_ak.sh
      +++ b/_ak.sh
      @@ -1,4 +1,4 @@
      #!/bin/bash
      echo "Hello"
      -echo "I am script# 1"
      +echo "I am script# 1" #comment
      exit
      \ No newline at end of file

      5. Jenkins try to build this small script, but fails due to "Failed to apply patch":

      Started by command line by anonymous
      Building in workspace /opt/jenkins-1.575-0/apps/jenkins/jenkins_home/jobs/freestylesoftwareproject/workspace
      Cloning the remote Git repository
      Cloning repository git@192.168.207.26:/opt/git/mera-ci-test.git
      > /usr/bin/git init /opt/jenkins-1.575-0/apps/jenkins/jenkins_home/jobs/freestylesoftwareproject/workspace # timeout=10
      Fetching upstream changes from git@192.168.207.26:/opt/git/mera-ci-test.git
      > /usr/bin/git --version # timeout=10
      > /usr/bin/git fetch --tags --progress git@192.168.207.26:/opt/git/mera-ci-test.git +refs/heads/:refs/remotes/origin/
      > /usr/bin/git config remote.origin.url git@192.168.207.26:/opt/git/mera-ci-test.git # timeout=10
      > /usr/bin/git config remote.origin.fetch +refs/heads/:refs/remotes/origin/ # timeout=10
      > /usr/bin/git config remote.origin.url git@192.168.207.26:/opt/git/mera-ci-test.git # timeout=10
      Fetching upstream changes from git@192.168.207.26:/opt/git/mera-ci-test.git
      > /usr/bin/git fetch --tags --progress git@192.168.207.26:/opt/git/mera-ci-test.git +refs/heads/:refs/remotes/origin/
      > /usr/bin/git rev-parse refs/remotes/origin/dev^

      {commit} # timeout=10
      > /usr/bin/git rev-parse refs/remotes/origin/origin/dev^{commit}

      # timeout=10
      Checking out Revision f4d46f33fe2f4c5cd41cb938d5152fcff896d473 (refs/remotes/origin/dev)
      > /usr/bin/git config core.sparsecheckout # timeout=10
      > /usr/bin/git checkout -f f4d46f33fe2f4c5cd41cb938d5152fcff896d473
      > /usr/bin/git rev-list 8751e4151bd8839df9ac93b75b7995aa10ed546d # timeout=10
      Applying the diff
      Failed to apply patch due to:
      java.io.IOException: Failed to patch /opt/jenkins-1.575-0/apps/jenkins/jenkins_home/jobs/freestylesoftwareproject/workspace/_ak.sh
      at org.jenkinsci.plugins.jenkinsreviewbot.ReviewboardParameterValue$ApplyTask.invoke(ReviewboardParameterValue.java:250)
      at org.jenkinsci.plugins.jenkinsreviewbot.ReviewboardParameterValue$ApplyTask.invoke(ReviewboardParameterValue.java:240)
      at hudson.FilePath.act(FilePath.java:922)
      at hudson.FilePath.act(FilePath.java:895)
      at org.jenkinsci.plugins.jenkinsreviewbot.ReviewboardParameterValue.applyPatch(ReviewboardParameterValue.java:183)
      at org.jenkinsci.plugins.jenkinsreviewbot.ReviewboardParameterValue.access$200(ReviewboardParameterValue.java:51)
      at org.jenkinsci.plugins.jenkinsreviewbot.ReviewboardParameterValue$ReviewboardBuildWrapper.setUp(ReviewboardParameterValue.java:227)
      at hudson.model.Build$BuildExecution.doRun(Build.java:154)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:535)
      at hudson.model.Run.execute(Run.java:1740)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:88)
      at hudson.model.Executor.run(Executor.java:234)
      Caused by: com.cloudbees.diff.PatchException: Cannot apply hunk @@ 4
      at com.cloudbees.diff.ContextualPatch.applyHunk(ContextualPatch.java:228)
      at com.cloudbees.diff.ContextualPatch.applyPatch(ContextualPatch.java:155)
      at com.cloudbees.diff.ContextualPatch.patch(ContextualPatch.java:108)
      at org.jenkinsci.plugins.jenkinsreviewbot.ReviewboardParameterValue$ApplyTask.invoke(ReviewboardParameterValue.java:246)
      ... 12 more
      FATAL: Failed to patch /opt/jenkins-1.575-0/apps/jenkins/jenkins_home/jobs/freestylesoftwareproject/workspace/_ak.sh
      java.io.IOException: Failed to patch /opt/jenkins-1.575-0/apps/jenkins/jenkins_home/jobs/freestylesoftwareproject/workspace/_ak.sh
      at org.jenkinsci.plugins.jenkinsreviewbot.ReviewboardParameterValue$ApplyTask.invoke(ReviewboardParameterValue.java:250)
      at org.jenkinsci.plugins.jenkinsreviewbot.ReviewboardParameterValue$ApplyTask.invoke(ReviewboardParameterValue.java:240)
      at hudson.FilePath.act(FilePath.java:922)
      at hudson.FilePath.act(FilePath.java:895)
      at org.jenkinsci.plugins.jenkinsreviewbot.ReviewboardParameterValue.applyPatch(ReviewboardParameterValue.java:183)
      at org.jenkinsci.plugins.jenkinsreviewbot.ReviewboardParameterValue.access$200(ReviewboardParameterValue.java:51)
      at org.jenkinsci.plugins.jenkinsreviewbot.ReviewboardParameterValue$ReviewboardBuildWrapper.setUp(ReviewboardParameterValue.java:227)
      at hudson.model.Build$BuildExecution.doRun(Build.java:154)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:535)
      at hudson.model.Run.execute(Run.java:1740)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:88)
      at hudson.model.Executor.run(Executor.java:234)
      Caused by: com.cloudbees.diff.PatchException: Cannot apply hunk @@ 4
      at com.cloudbees.diff.ContextualPatch.applyHunk(ContextualPatch.java:228)
      at com.cloudbees.diff.ContextualPatch.applyPatch(ContextualPatch.java:155)
      at com.cloudbees.diff.ContextualPatch.patch(ContextualPatch.java:108)
      at org.jenkinsci.plugins.jenkinsreviewbot.ReviewboardParameterValue$ApplyTask.invoke(ReviewboardParameterValue.java:246)
      ... 12 more

      Interesting thing that if I'll add something ONLY in the END of the script, job will be build successfully.

      6. I've added only last string "#last line - OK" at 5th line:
      1: #!/bin/bash
      2: echo "Hello"
      3: echo "I am script# 1" #comment
      4: exit
      5: #last line - OK <--Only last string "#last line - OK" has been added.
      Then git commit and git push.

      7. Check git log after last line has been added:
      root@sochi-1:/opt/git_client# git log -p -1 dev
      commit 6bf3ca934255fa75b71efd7eb970919fb068ece0
      Author: akoryag
      Date: Mon Aug 18 18:34:30 2014 +0400

      reviewgroup #review-grouprefs #11: last line

      diff --git a/_ak.sh b/_ak.sh
      index 39ab760..641a134 100644
      — a/_ak.sh
      +++ b/_ak.sh
      @@ -1,4 +1,5 @@
      #!/bin/bash
      echo "Hello"
      echo "I am script# 1" #comment
      -exit
      \ No newline at end of file
      +exit
      +#last line - OK
      \ No newline at end of file

      8. Check git diff:
      root@sochi-1:/opt/git_client# git diff 39ab760 641a134
      diff --git a/39ab760 b/641a134
      index 39ab760..641a134 100644
      — a/39ab760
      +++ b/641a134
      @@ -1,4 +1,5 @@
      #!/bin/bash
      echo "Hello"
      echo "I am script# 1" #comment
      -exit
      \ No newline at end of file
      +exit
      +#last line - OK
      \ No newline at end of file

      9. Check generated diff file from ReviewBoard "rb18.patch" (the same as above):
      diff --git a/_ak.sh b/_ak.sh
      index 39ab7607fb59590e2e16e26fcbd77c58a2c27a6a..641a134e7f84f225706511a3ce26a52c90e1f6eb 100644
      — a/_ak.sh
      +++ b/_ak.sh
      @@ -1,4 +1,5 @@
      #!/bin/bash
      echo "Hello"
      echo "I am script# 1" #comment
      -exit
      \ No newline at end of file
      +exit
      +#last line - OK
      \ No newline at end of file

      10. Jenkins successfully build script with only LAST line added:

      Started by command line by anonymous
      Building in workspace /opt/jenkins-1.575-0/apps/jenkins/jenkins_home/jobs/freestylesoftwareproject/workspace
      > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
      > /usr/bin/git config remote.origin.url git@192.168.207.26:/opt/git/mera-ci-test.git # timeout=10
      Fetching upstream changes from git@192.168.207.26:/opt/git/mera-ci-test.git
      > /usr/bin/git --version # timeout=10
      > /usr/bin/git fetch --tags --progress git@192.168.207.26:/opt/git/mera-ci-test.git +refs/heads/:refs/remotes/origin/
      > /usr/bin/git rev-parse refs/remotes/origin/dev^

      {commit} # timeout=10
      > /usr/bin/git rev-parse refs/remotes/origin/origin/dev^{commit}

      # timeout=10
      Checking out Revision 6bf3ca934255fa75b71efd7eb970919fb068ece0 (refs/remotes/origin/dev)
      > /usr/bin/git config core.sparsecheckout # timeout=10
      > /usr/bin/git checkout -f 6bf3ca934255fa75b71efd7eb970919fb068ece0
      > /usr/bin/git rev-list f4d46f33fe2f4c5cd41cb938d5152fcff896d473 # timeout=10
      Applying the diff
      Going to notify reviewboard about #16
      Finished: SUCCESS

      Tell me please what is wrong with diff generation?
      Thanks a lot.

      Configuration:
      Jenkins ver. 1.575
      jenkins-reviewbot 2.0
      Review Board 2.0.5
      git version 1.9.1
      Ubuntu 14.04.1 LTS

            yardena Yardena Meymann
            alex7c4 Alex Kor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: