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

Allow reading custom build message from a workspace file, in case of non-success

        [JENKINS-12881] Allow reading custom build message from a workspace file, in case of non-success

        Joe Hansche added a comment - - edited

        The approach I took on this was to have a configurable error file that can be specified in the "Gerrit Trigger" section of config, in the Advanced section. When building the approval message, if the result is not SUCCESS, it attempts to read from the unsuccessful-message file. If that is configured and the file is present, its contents will be appended to that build stats section.

        One concern, which my current implementation is susceptible to, is that currently the file is only read once all builds have completed, but that could result in some data integrity issues. Instead, that file's contents should be read as soon as the build is completed, and store the contents to the MemoryImprint instead. EDIT: this has been fixed in the pull request.

        Joe Hansche added a comment - - edited The approach I took on this was to have a configurable error file that can be specified in the "Gerrit Trigger" section of config, in the Advanced section. When building the approval message, if the result is not SUCCESS, it attempts to read from the unsuccessful-message file. If that is configured and the file is present, its contents will be appended to that build stats section. One concern, which my current implementation is susceptible to, is that currently the file is only read once all builds have completed, but that could result in some data integrity issues. Instead, that file's contents should be read as soon as the build is completed, and store the contents to the MemoryImprint instead. EDIT: this has been fixed in the pull request.

        Joe Hansche added a comment -

        The pull request is at https://github.com/jenkinsci/gerrit-trigger-plugin/pull/12

        The comment there is expanding on what I think is your initial suggestion in the Confluence discussion , and I like the flexibility of being able to do that. Just not sure how to really do cross-plugin support like that (relatively new to Jenkins development). I've tested this, and it works, but it's not as flexible as I'd like, since some of the failures will be caused by post-build steps, where a shell script won't be able to manipulate the error-message file.

        This also kind of creates some ambiguity, because it's possible for the error-message file to exist in the workspace (e.g., from an old build?), and that could cause the file to get picked up in a later build that actually failed as a result of a publisher, for example – and that would be misleading in the Gerrit comment. So, not really sure how I feel about this yet.

        Joe Hansche added a comment - The pull request is at https://github.com/jenkinsci/gerrit-trigger-plugin/pull/12 The comment there is expanding on what I think is your initial suggestion in the Confluence discussion , and I like the flexibility of being able to do that. Just not sure how to really do cross-plugin support like that (relatively new to Jenkins development). I've tested this, and it works, but it's not as flexible as I'd like, since some of the failures will be caused by post-build steps, where a shell script won't be able to manipulate the error-message file. This also kind of creates some ambiguity, because it's possible for the error-message file to exist in the workspace (e.g., from an old build?), and that could cause the file to get picked up in a later build that actually failed as a result of a publisher, for example – and that would be misleading in the Gerrit comment. So, not really sure how I feel about this yet.

        Code changed in jenkins
        User: Joe Hansche
        Path:
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpander.java
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/model/BuildMemory.java
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTrigger.java
        gerrithudsontrigger/src/main/resources/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTrigger/config.jelly
        gerrithudsontrigger/src/main/webapp/trigger/help-BuildUnsuccessfulFilepath.html
        gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTriggerTest.java
        gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/mock/DuplicatesUtil.java
        http://jenkins-ci.org/commit/gerrit-trigger-plugin/6b28ce0abd571c8f9325df195f462862fed42540
        Log:
        JENKINS-12881: Initial implementation

        SCM/JIRA link daemon added a comment - Code changed in jenkins User: Joe Hansche Path: gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpander.java gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/model/BuildMemory.java gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTrigger.java gerrithudsontrigger/src/main/resources/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTrigger/config.jelly gerrithudsontrigger/src/main/webapp/trigger/help-BuildUnsuccessfulFilepath.html gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTriggerTest.java gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/mock/DuplicatesUtil.java http://jenkins-ci.org/commit/gerrit-trigger-plugin/6b28ce0abd571c8f9325df195f462862fed42540 Log: JENKINS-12881 : Initial implementation

        Code changed in jenkins
        User: Joe Hansche
        Path:
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpander.java
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ToGerritRunListener.java
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/model/BuildMemory.java
        http://jenkins-ci.org/commit/gerrit-trigger-plugin/f79e10be25028ad69a433a82b061ebc1bd6371d2
        Log:
        JENKINS-12881: Obtain failure message at completed-time.

        Resolves a potential race condition when a single job
        may be executing multiple times before the change "batch"
        status is ready to be reported back to Gerrit.

        The test setup is:

        • Job-A
        • Shell: echo "Starting ${BUILD_TAG}" > error-message.txt
          sleep 5
        • Shell: echo "Always fails ${BUILD_TAG}" > error-message.txt
          sleep 5
          exit 1
        • Job-B
        • Shell: echo "Starting ${BUILD_TAG}" > error-message.txt
          sleep 15
        • Shell: echo "Never fails ${BUILD_TAG}" > error-message.txt
          sleep 15

        Job-B will always be the long-pole (30 sec). Job-A will always fail,
        hopefully with "Always fails ______" as the error-message.

        Create 2 commits for review, and push both commits to Gerrit. Both
        Job-A builds will run and fail within 20 seconds, before the first
        Job-B build is even finished executing.

        The test is successful if both review commits contain the correct
        "Always fails

        {TAG}

        " messages, corresponding to the correct URL.
        The test fails if any other string exists in the failure message.

        SCM/JIRA link daemon added a comment - Code changed in jenkins User: Joe Hansche Path: gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpander.java gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ToGerritRunListener.java gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/model/BuildMemory.java http://jenkins-ci.org/commit/gerrit-trigger-plugin/f79e10be25028ad69a433a82b061ebc1bd6371d2 Log: JENKINS-12881 : Obtain failure message at completed-time. Resolves a potential race condition when a single job may be executing multiple times before the change "batch" status is ready to be reported back to Gerrit. The test setup is: Job-A Shell: echo "Starting ${BUILD_TAG}" > error-message.txt sleep 5 Shell: echo "Always fails ${BUILD_TAG}" > error-message.txt sleep 5 exit 1 Job-B Shell: echo "Starting ${BUILD_TAG}" > error-message.txt sleep 15 Shell: echo "Never fails ${BUILD_TAG}" > error-message.txt sleep 15 Job-B will always be the long-pole (30 sec). Job-A will always fail, hopefully with "Always fails ______" as the error-message. Create 2 commits for review, and push both commits to Gerrit. Both Job-A builds will run and fail within 20 seconds, before the first Job-B build is even finished executing. The test is successful if both review commits contain the correct "Always fails {TAG} " messages, corresponding to the correct URL. The test fails if any other string exists in the failure message.

        Code changed in jenkins
        User: Joe Hansche
        Path:
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ToGerritRunListener.java
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/model/BuildMemory.java
        http://jenkins-ci.org/commit/gerrit-trigger-plugin/7e4c31972ba20d5b556a8d7f470f6e050998c1b4
        Log:
        JENKINS-12881: Refactor the message retrieval

        Refactor at which point the message is retrieved, and
        which class is responsible for doing so. Should be more in
        line with the original intent of the classes, and not
        introduce a high degree of coupling.

        SCM/JIRA link daemon added a comment - Code changed in jenkins User: Joe Hansche Path: gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ToGerritRunListener.java gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/model/BuildMemory.java http://jenkins-ci.org/commit/gerrit-trigger-plugin/7e4c31972ba20d5b556a8d7f470f6e050998c1b4 Log: JENKINS-12881 : Refactor the message retrieval Refactor at which point the message is retrieved, and which class is responsible for doing so. Should be more in line with the original intent of the classes, and not introduce a high degree of coupling.

        Code changed in jenkins
        User: Joe Hansche
        Path:
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpander.java
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ToGerritRunListener.java
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/model/BuildMemory.java
        gerrithudsontrigger/src/main/webapp/trigger/help-BuildUnsuccessfulFilepath.html
        http://jenkins-ci.org/commit/gerrit-trigger-plugin/2118649a59a7a3be1b787c650f21c21832ba6869
        Log:
        JENKINS-12881: Fixes per code review comments at pull request #12

        SCM/JIRA link daemon added a comment - Code changed in jenkins User: Joe Hansche Path: gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpander.java gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ToGerritRunListener.java gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/model/BuildMemory.java gerrithudsontrigger/src/main/webapp/trigger/help-BuildUnsuccessfulFilepath.html http://jenkins-ci.org/commit/gerrit-trigger-plugin/2118649a59a7a3be1b787c650f21c21832ba6869 Log: JENKINS-12881 : Fixes per code review comments at pull request #12

        Code changed in jenkins
        User: Joe Hansche
        Path:
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpander.java
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ToGerritRunListener.java
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/model/BuildMemory.java
        gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpanderTest.java
        gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ToGerritRunListenerTest.java
        gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/mock/Setup.java
        http://jenkins-ci.org/commit/gerrit-trigger-plugin/0cec882c6d52162dca2367ffa7e486cb061457a4
        Log:
        JENKINS-12881: Adds unit tests for failure-message feature

        SCM/JIRA link daemon added a comment - Code changed in jenkins User: Joe Hansche Path: gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpander.java gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ToGerritRunListener.java gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/model/BuildMemory.java gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpanderTest.java gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ToGerritRunListenerTest.java gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/mock/Setup.java http://jenkins-ci.org/commit/gerrit-trigger-plugin/0cec882c6d52162dca2367ffa7e486cb061457a4 Log: JENKINS-12881 : Adds unit tests for failure-message feature

        Code changed in jenkins
        User: Robert Sandell
        Path:
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpander.java
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ToGerritRunListener.java
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/model/BuildMemory.java
        gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTrigger.java
        gerrithudsontrigger/src/main/resources/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTrigger/config.jelly
        gerrithudsontrigger/src/main/webapp/trigger/help-BuildUnsuccessfulFilepath.html
        gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpanderTest.java
        gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ToGerritRunListenerTest.java
        gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTriggerTest.java
        gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/mock/DuplicatesUtil.java
        gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/mock/Setup.java
        http://jenkins-ci.org/commit/gerrit-trigger-plugin/81f7aeaa165eead88f4e6c37b1ee2d313c4e8738
        Log:
        Merge pull request #12 from jhansche/JENKINS-12881

        JENKINS-12881: Allow reading custom build message from a workspace file, in case of non-success

        Compare: https://github.com/jenkinsci/gerrit-trigger-plugin/compare/c86949f...81f7aea

        SCM/JIRA link daemon added a comment - Code changed in jenkins User: Robert Sandell Path: gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpander.java gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ToGerritRunListener.java gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/model/BuildMemory.java gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTrigger.java gerrithudsontrigger/src/main/resources/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTrigger/config.jelly gerrithudsontrigger/src/main/webapp/trigger/help-BuildUnsuccessfulFilepath.html gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpanderTest.java gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ToGerritRunListenerTest.java gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTriggerTest.java gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/mock/DuplicatesUtil.java gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/mock/Setup.java http://jenkins-ci.org/commit/gerrit-trigger-plugin/81f7aeaa165eead88f4e6c37b1ee2d313c4e8738 Log: Merge pull request #12 from jhansche/ JENKINS-12881 JENKINS-12881 : Allow reading custom build message from a workspace file, in case of non-success Compare: https://github.com/jenkinsci/gerrit-trigger-plugin/compare/c86949f...81f7aea

          rsandell rsandell
          jhansche Joe Hansche
          Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

            Created:
            Updated:
            Resolved: