{"action":"created","issue":{"url":"https://api.github.com/repos/jenkinsci/flexible-publish-plugin/issues/12","labels_url":"https://api.github.com/repos/jenkinsci/flexible-publish-plugin/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/jenkinsci/flexible-publish-plugin/issues/12/comments","events_url":"https://api.github.com/repos/jenkinsci/flexible-publish-plugin/issues/12/events","html_url":"https://github.com/jenkinsci/flexible-publish-plugin/pull/12","id":61391286,"number":12,"title":"[JENKINS-27278] Execution strategy for publishers in a condition","user":{"login":"ikedam","id":3115961,"avatar_url":"https://avatars.githubusercontent.com/u/3115961?v=3","gravatar_id":"","url":"https://api.github.com/users/ikedam","html_url":"https://github.com/ikedam","followers_url":"https://api.github.com/users/ikedam/followers","following_url":"https://api.github.com/users/ikedam/following{/other_user}","gists_url":"https://api.github.com/users/ikedam/gists{/gist_id}","starred_url":"https://api.github.com/users/ikedam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ikedam/subscriptions","organizations_url":"https://api.github.com/users/ikedam/orgs","repos_url":"https://api.github.com/users/ikedam/repos","events_url":"https://api.github.com/users/ikedam/events{/privacy}","received_events_url":"https://api.github.com/users/ikedam/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-14T03:52:17Z","updated_at":"2015-03-14T06:01:41Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/jenkinsci/flexible-publish-plugin/pulls/12","html_url":"https://github.com/jenkinsci/flexible-publish-plugin/pull/12","diff_url":"https://github.com/jenkinsci/flexible-publish-plugin/pull/12.diff","patch_url":"https://github.com/jenkinsci/flexible-publish-plugin/pull/12.patch"},"body":"### Overview\r\n\r\nThis introduces \"execution strategy\" feature to Flexible Publish plugin. It controls whether to continue to following publishers.\r\n* They are located in the \"Advanced...\" section of each Conditional actions.\r\n    ![executionstrategy1](https://cloud.githubusercontent.com/assets/3115961/6650167/465824ae-ca47-11e4-9311-f6776001b9b0.png)\r\n* You can select \"Fail at end\" or \"Fail fast\"\r\n    ![executionstrategy2](https://cloud.githubusercontent.com/assets/3115961/6650168/4c77b336-ca47-11e4-9b59-835afcd49354.png)\r\n\r\n| Strategy  | Behavior on a failure of a publisher                                                                 |\r\n|:---------:|:-----------------------------------------------------------------------------------------------------|\r\n|Fail at end|Continues to run following publishers. The default behavior in flexible-publish 0.15 and later.           |\r\n|Fail fast  |Doesn't run following publishers. The default behavior for flexible-publish configured in 0.13 and 0.14.1. |\r\n\r\nThis request includes following 2 changes:\r\n1. Makes it clear how flexible-publish works when some of publishers fail.\r\n2. Evaluates a condition only once for publishers.\r\n\r\nThey are fixes or improvements for \"multiple publishers in a condition\" feature I introduced in flexible-publush 0.13 (released Nov, 2014).\r\n\r\nWhat I want to be reviewed:\r\n* Aren't there unexpected regressions?\r\n* Comments for this new feature.\r\n\r\n### Makes it clear how flexible-publish works when some of publishers fail.\r\n\r\nFlexible publish allows define multiple conditions and multiple publishers for each condition like this:\r\n```\r\nFlexible publish\r\n    Condition 1\r\n        Publisher 1\r\n        Publisher 2\r\n    Condition 2\r\n        Publisher 3\r\n```\r\n\r\nThere was no clear definition how flexible-publish behaves when a publisher fails.\r\nIndeed, it works as following. For comparison, I also write the behavier of free style projects.\r\n\r\n|Failure Type                      |Flexible publish|Condition                            |Free style project|\r\n|:---------------------------------|:---------------|:------------------------------------|:-----------------|\r\n|Publisher returns `false`         |Continue        |Stop (and go to the next condition)  |Continue          |\r\n|Publisher throws `AbortException` |Stop            |Stop (whole flexible publish)        |Continue          |\r\n|Publisher throws other `Exception`|Stop            |Stop (whole flexible publish)        |Continue          |\r\n\r\nFor example, when \"Publisher 1\" above returns false, \"Publisher 2\" doesn't run and \"Publisher 3\" runs.\r\nThis may be hard for users to know how flexible-publish works when a publisher fails.\r\n\r\nThe behavior of a free style project is defined in following codes:\r\n* `hudson.model.Build.BuildExecution#post2`\r\n* `hudson.model.AbstractBuild#performAllBuildStep`\r\n\r\nI conclude that publishers are expected to run even a prior publisher fails:\r\n* Publishers often send notifications of build results. Users expects notifications even some publishers fail.\r\n* Those classes are thought to be common basic classes for projects with publishers.\r\n\r\nFor the backward compatibility, I introduced the execution strategy feature.\r\nThis request makes flexible-publish work like this:\r\n\r\n|Failure Type                      |Flexible publish|Condition (fail at end)|Condition (fail fast)              |\r\n|:---------------------------------|:---------------|:----------------------|:----------------------------------|\r\n|Publisher returns `false`         |Continue        |Continue               |Stop (and go to the next condition)|\r\n|Publisher throws `AbortException` |Continue        |Continue               |Stop (and go to the next condition)|\r\n|Publisher throws other `Exception`|Continue        |Continue               |Stop (and go to the next condition)|\r\n\r\n\r\n### Evaluates a condition only once for publishers\r\n\r\nThis configuration\r\n```\r\nFlexible publish\r\n    Condition 1\r\n        Publisher 1\r\n        Publisher 2\r\n```\r\n\r\nworks like this in flexible-publish 0.14.1 and earlier.\r\n```\r\nif(Condition 1){ Publisher 1 }\r\nif(Condition 1){ Publisher 2 }\r\n```\r\n\r\nThis request makes it works like this:\r\n```\r\nif(Condition 1){\r\n  Publisher 1\r\n  Publisher 2\r\n}\r\n```\r\n\r\nReasons:\r\n* Users can expect the condition evaluated only once like they see in the configuration page.\r\n* There may be conditions take much time to be evaluated or have side-effects. It's not reasonable to evaluate those conditions each time.\r\n* If a user really want a condition evaluated for each publishers, they can do that as following:\r\n```\r\nFlexible publish\r\n    Condition 1\r\n        Publisher 1\r\n    Condition 1\r\n        Publisher 2\r\n```"},"comment":{"url":"https://api.github.com/repos/jenkinsci/flexible-publish-plugin/issues/comments/79963762","html_url":"https://github.com/jenkinsci/flexible-publish-plugin/pull/12#issuecomment-79963762","issue_url":"https://api.github.com/repos/jenkinsci/flexible-publish-plugin/issues/12","id":79963762,"user":{"login":"jenkinsadmin","id":874715,"avatar_url":"https://avatars.githubusercontent.com/u/874715?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsadmin","html_url":"https://github.com/jenkinsadmin","followers_url":"https://api.github.com/users/jenkinsadmin/followers","following_url":"https://api.github.com/users/jenkinsadmin/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsadmin/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsadmin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsadmin/subscriptions","organizations_url":"https://api.github.com/users/jenkinsadmin/orgs","repos_url":"https://api.github.com/users/jenkinsadmin/repos","events_url":"https://api.github.com/users/jenkinsadmin/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsadmin/received_events","type":"User","site_admin":false},"created_at":"2015-03-14T06:01:41Z","updated_at":"2015-03-14T06:01:41Z","body":"Thank you for a pull request! Please check [this document](http://jenkins-ci.org/pull-request-greeting) for how the Jenkins project handles pull requests"}}