{"action":"created","comment":{"url":"https://api.github.com/repos/jenkinsci/envinject-plugin/pulls/comments/29555230","id":29555230,"diff_hunk":"@@ -59,16 +61,15 @@ private static void insertRootCauseNames(Set<String> causeNames, Cause cause, in\n \n     private static Map<String, String> buildCauseEnvironmentVariables(String envBase, Collection<String> causeNames) {\n         Map<String, String> triggerVars = new HashMap<String, String>();\n-        StringBuilder all = new StringBuilder();\n+        List<String> nonEmptyNames = new ArrayList<String>();\n         for (String name : causeNames) {\n-            if (!StringUtils.isBlank(name)) {\n-                triggerVars.put(envBase + \"_\" + name, \"true\");\n-                all.append(\",\");\n-                all.append(name);\n+            if (isNotBlank(name)) {\n+                triggerVars.put(on(\"_\").join(envBase, name), \"true\");\n+                nonEmptyNames.add(name);\n             }\n         }\n         // add variable containing all the trigger names\n-        triggerVars.put(envBase, all.toString().substring(1));\n+        triggerVars.put(envBase, on(\",\").join(nonEmptyNames));","path":"src/main/java/org/jenkinsci/plugins/envinject/service/BuildCauseRetriever.java","position":36,"original_position":36,"commit_id":"81416520412995432ea9fe444c635e578dd3aa8d","original_commit_id":"81416520412995432ea9fe444c635e578dd3aa8d","user":{"login":"oleg-nenashev","id":3000480,"avatar_url":"https://avatars.githubusercontent.com/u/3000480?v=3","gravatar_id":"","url":"https://api.github.com/users/oleg-nenashev","html_url":"https://github.com/oleg-nenashev","followers_url":"https://api.github.com/users/oleg-nenashev/followers","following_url":"https://api.github.com/users/oleg-nenashev/following{/other_user}","gists_url":"https://api.github.com/users/oleg-nenashev/gists{/gist_id}","starred_url":"https://api.github.com/users/oleg-nenashev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oleg-nenashev/subscriptions","organizations_url":"https://api.github.com/users/oleg-nenashev/orgs","repos_url":"https://api.github.com/users/oleg-nenashev/repos","events_url":"https://api.github.com/users/oleg-nenashev/events{/privacy}","received_events_url":"https://api.github.com/users/oleg-nenashev/received_events","type":"User","site_admin":false},"body":"Conflicts with #49 . Please avoid bulk changes (especially when they are not listed in the PRs summary)","created_at":"2015-05-03T11:26:47Z","updated_at":"2015-05-03T11:26:47Z","html_url":"https://github.com/jenkinsci/envinject-plugin/pull/45#discussion_r29555230","pull_request_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/pulls/45","_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/envinject-plugin/pulls/comments/29555230"},"html":{"href":"https://github.com/jenkinsci/envinject-plugin/pull/45#discussion_r29555230"},"pull_request":{"href":"https://api.github.com/repos/jenkinsci/envinject-plugin/pulls/45"}}},"pull_request":{"url":"https://api.github.com/repos/jenkinsci/envinject-plugin/pulls/45","id":33287553,"html_url":"https://github.com/jenkinsci/envinject-plugin/pull/45","diff_url":"https://github.com/jenkinsci/envinject-plugin/pull/45.diff","patch_url":"https://github.com/jenkinsci/envinject-plugin/pull/45.patch","issue_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/issues/45","number":45,"state":"open","locked":false,"title":"Fix for plugin compatibility when used anonymous class cause","user":{"login":"lanwen","id":1964214,"avatar_url":"https://avatars.githubusercontent.com/u/1964214?v=3","gravatar_id":"","url":"https://api.github.com/users/lanwen","html_url":"https://github.com/lanwen","followers_url":"https://api.github.com/users/lanwen/followers","following_url":"https://api.github.com/users/lanwen/following{/other_user}","gists_url":"https://api.github.com/users/lanwen/gists{/gist_id}","starred_url":"https://api.github.com/users/lanwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lanwen/subscriptions","organizations_url":"https://api.github.com/users/lanwen/orgs","repos_url":"https://api.github.com/users/lanwen/repos","events_url":"https://api.github.com/users/lanwen/events{/privacy}","received_events_url":"https://api.github.com/users/lanwen/received_events","type":"User","site_admin":false},"body":"Example for reproduce (test added):\r\n```java\r\n FreeStyleBuild build = jenkins.createFreeStyleProject().scheduleBuild2(0, new Cause() {\r\n            @Override\r\n            public String getShortDescription() {\r\n                return \"This build was started by a hobbit Bilbo. Bilbo Baggins\";\r\n            }\r\n        }).get();\r\n```\r\n\r\nException:\r\n```\r\n[EnvInject] - Loading node environment variables.\r\nFATAL: String index out of range: -1\r\nhttp://stacktrace.jenkins-ci.org/search?query=java.lang.StringIndexOutOfBoundsException: String index out of range: -1\r\nat java.lang.String.substring(String.java:1875) <http://stacktrace.jenkins-ci.org/search/?query=java.lang.String.substring&entity=method>\r\nat org.jenkinsci.plugins.envinject.service.BuildCauseRetriever.buildCauseEnvironmentVariables(BuildCauseRetriever.java:71) <http://stacktrace.jenkins-ci.org/search/?query=org.jenkinsci.plugins.envinject.service.BuildCauseRetriever.buildCauseEnvironmentVariables&entity=method>\r\nat org.jenkinsci.plugins.envinject.service.BuildCauseRetriever.getTriggeredCause(BuildCauseRetriever.java:40) <http://stacktrace.jenkins-ci.org/search/?query=org.jenkinsci.plugins.envinject.service.BuildCauseRetriever.getTriggeredCause&entity=method>\r\nat org.jenkinsci.plugins.envinject.service.EnvInjectVariableGetter.getBuildVariables(EnvInjectVariableGetter.java:111) <http://stacktrace.jenkins-ci.org/search/?query=org.jenkinsci.plugins.envinject.service.EnvInjectVariableGetter.getBuildVariables&entity=method>\r\nat org.jenkinsci.plugins.envinject.EnvInjectListener.setUpEnvironmentWithoutJobPropertyObject(EnvInjectListener.java:231) <http://stacktrace.jenkins-ci.org/search/?query=org.jenkinsci.plugins.envinject.EnvInjectListener.setUpEnvironmentWithoutJobPropertyObject&entity=method>\r\nat org.jenkinsci.plugins.envinject.EnvInjectListener.setUpEnvironment(EnvInjectListener.java:46) <http://stacktrace.jenkins-ci.org/search/?query=org.jenkinsci.plugins.envinject.EnvInjectListener.setUpEnvironment&entity=method>\r\nat hudson.model.AbstractBuild$AbstractBuildExecution.createLauncher(AbstractBuild.java:587) <http://stacktrace.jenkins-ci.org/search/?query=hudson.model.AbstractBuild$AbstractBuildExecution.createLauncher&entity=method>\r\nat hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:491) <http://stacktrace.jenkins-ci.org/search/?query=hudson.model.AbstractBuild$AbstractBuildExecution.run&entity=method>\r\nat hudson.model.Run.execute(Run.java:1759) <http://stacktrace.jenkins-ci.org/search/?query=hudson.model.Run.execute&entity=method>\r\nat hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) <http://stacktrace.jenkins-ci.org/search/?query=hudson.model.FreeStyleBuild.run&entity=method>\r\nat hudson.model.ResourceController.execute(ResourceController.java:89) <http://stacktrace.jenkins-ci.org/search/?query=hudson.model.ResourceController.execute&entity=method>\r\nat hudson.model.Executor.run(Executor.java:240) <http://stacktrace.jenkins-ci.org/search/?query=hudson.model.Executor.run&entity=method>\r\n```\r\n\r\nAlso:\r\n- Refactor test for this class to junit4 style\r\n- Speed up with help of jenkins class rule\r\n- Move test to corresponding package\n\n<!-- Reviewable:start -->\n[<img src=\"https://reviewable.io/review_button.png\" height=40 alt=\"Review on Reviewable\"/>](https://reviewable.io/reviews/jenkinsci/envinject-plugin/45)\n<!-- Reviewable:end -->\n","created_at":"2015-04-14T18:47:46Z","updated_at":"2015-05-03T11:26:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3721199d8cf880f9cb6f07f621345bf5655ce3ee","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/pulls/45/commits","review_comments_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/pulls/45/comments","review_comment_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/issues/45/comments","statuses_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/statuses/81416520412995432ea9fe444c635e578dd3aa8d","head":{"label":"lanwen:anonymouse-cause","ref":"anonymouse-cause","sha":"81416520412995432ea9fe444c635e578dd3aa8d","user":{"login":"lanwen","id":1964214,"avatar_url":"https://avatars.githubusercontent.com/u/1964214?v=3","gravatar_id":"","url":"https://api.github.com/users/lanwen","html_url":"https://github.com/lanwen","followers_url":"https://api.github.com/users/lanwen/followers","following_url":"https://api.github.com/users/lanwen/following{/other_user}","gists_url":"https://api.github.com/users/lanwen/gists{/gist_id}","starred_url":"https://api.github.com/users/lanwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lanwen/subscriptions","organizations_url":"https://api.github.com/users/lanwen/orgs","repos_url":"https://api.github.com/users/lanwen/repos","events_url":"https://api.github.com/users/lanwen/events{/privacy}","received_events_url":"https://api.github.com/users/lanwen/received_events","type":"User","site_admin":false},"repo":{"id":33944407,"name":"envinject-plugin","full_name":"lanwen/envinject-plugin","owner":{"login":"lanwen","id":1964214,"avatar_url":"https://avatars.githubusercontent.com/u/1964214?v=3","gravatar_id":"","url":"https://api.github.com/users/lanwen","html_url":"https://github.com/lanwen","followers_url":"https://api.github.com/users/lanwen/followers","following_url":"https://api.github.com/users/lanwen/following{/other_user}","gists_url":"https://api.github.com/users/lanwen/gists{/gist_id}","starred_url":"https://api.github.com/users/lanwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lanwen/subscriptions","organizations_url":"https://api.github.com/users/lanwen/orgs","repos_url":"https://api.github.com/users/lanwen/repos","events_url":"https://api.github.com/users/lanwen/events{/privacy}","received_events_url":"https://api.github.com/users/lanwen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lanwen/envinject-plugin","description":"","fork":true,"url":"https://api.github.com/repos/lanwen/envinject-plugin","forks_url":"https://api.github.com/repos/lanwen/envinject-plugin/forks","keys_url":"https://api.github.com/repos/lanwen/envinject-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lanwen/envinject-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lanwen/envinject-plugin/teams","hooks_url":"https://api.github.com/repos/lanwen/envinject-plugin/hooks","issue_events_url":"https://api.github.com/repos/lanwen/envinject-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/lanwen/envinject-plugin/events","assignees_url":"https://api.github.com/repos/lanwen/envinject-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/lanwen/envinject-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/lanwen/envinject-plugin/tags","blobs_url":"https://api.github.com/repos/lanwen/envinject-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lanwen/envinject-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lanwen/envinject-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/lanwen/envinject-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lanwen/envinject-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/lanwen/envinject-plugin/languages","stargazers_url":"https://api.github.com/repos/lanwen/envinject-plugin/stargazers","contributors_url":"https://api.github.com/repos/lanwen/envinject-plugin/contributors","subscribers_url":"https://api.github.com/repos/lanwen/envinject-plugin/subscribers","subscription_url":"https://api.github.com/repos/lanwen/envinject-plugin/subscription","commits_url":"https://api.github.com/repos/lanwen/envinject-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/lanwen/envinject-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/lanwen/envinject-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/lanwen/envinject-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/lanwen/envinject-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/lanwen/envinject-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lanwen/envinject-plugin/merges","archive_url":"https://api.github.com/repos/lanwen/envinject-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lanwen/envinject-plugin/downloads","issues_url":"https://api.github.com/repos/lanwen/envinject-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/lanwen/envinject-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/lanwen/envinject-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/lanwen/envinject-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lanwen/envinject-plugin/labels{/name}","releases_url":"https://api.github.com/repos/lanwen/envinject-plugin/releases{/id}","created_at":"2015-04-14T16:47:13Z","updated_at":"2015-04-14T16:47:14Z","pushed_at":"2015-04-20T19:18:31Z","git_url":"git://github.com/lanwen/envinject-plugin.git","ssh_url":"git@github.com:lanwen/envinject-plugin.git","clone_url":"https://github.com/lanwen/envinject-plugin.git","svn_url":"https://github.com/lanwen/envinject-plugin","homepage":"","size":732,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jenkinsci:master","ref":"master","sha":"f6caad427a83688089334d5ee2c75fbeedca80ac","user":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"repo":{"id":2059304,"name":"envinject-plugin","full_name":"jenkinsci/envinject-plugin","owner":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jenkinsci/envinject-plugin","description":"","fork":false,"url":"https://api.github.com/repos/jenkinsci/envinject-plugin","forks_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/forks","keys_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/teams","hooks_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/hooks","issue_events_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/events","assignees_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/tags","blobs_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/languages","stargazers_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/stargazers","contributors_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/contributors","subscribers_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/subscribers","subscription_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/subscription","commits_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/merges","archive_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/downloads","issues_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/labels{/name}","releases_url":"https://api.github.com/repos/jenkinsci/envinject-plugin/releases{/id}","created_at":"2011-07-16T20:09:41Z","updated_at":"2015-04-17T06:27:20Z","pushed_at":"2015-05-02T21:59:37Z","git_url":"git://github.com/jenkinsci/envinject-plugin.git","ssh_url":"git@github.com:jenkinsci/envinject-plugin.git","clone_url":"https://github.com/jenkinsci/envinject-plugin.git","svn_url":"https://github.com/jenkinsci/envinject-plugin","homepage":"","size":1894,"stargazers_count":23,"watchers_count":23,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":54,"mirror_url":null,"open_issues_count":12,"forks":54,"open_issues":12,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/envinject-plugin/pulls/45"},"html":{"href":"https://github.com/jenkinsci/envinject-plugin/pull/45"},"issue":{"href":"https://api.github.com/repos/jenkinsci/envinject-plugin/issues/45"},"comments":{"href":"https://api.github.com/repos/jenkinsci/envinject-plugin/issues/45/comments"},"review_comments":{"href":"https://api.github.com/repos/jenkinsci/envinject-plugin/pulls/45/comments"},"review_comment":{"href":"https://api.github.com/repos/jenkinsci/envinject-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jenkinsci/envinject-plugin/pulls/45/commits"},"statuses":{"href":"https://api.github.com/repos/jenkinsci/envinject-plugin/statuses/81416520412995432ea9fe444c635e578dd3aa8d"}}}}