{"action":"created","comment":{"url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/pulls/comments/30745582","id":30745582,"diff_hunk":"@@ -636,51 +672,93 @@ private HttpEntity newStashBuildNotificationEntity(\n         json.put(\"description\", getBuildDescription(build, state));\n         json.put(\"url\", Jenkins.getInstance()\n         \t\t.getRootUrl().concat(build.getUrl()));\n-        \n+\n         return new StringEntity(json.toString(), \"UTF-8\");\n \t}\n \n \t/**\n-\t * Returns the build key used in the Stash notification. Includes the \n-\t * build number depending on the user setting.\n-\t * \n-\t * @param \tbuild\tthe build to notify Stash of\n-\t * @return\tthe build key for the Stash notification\n+\t * Return the old-fashion build key\n+\t *\n+\t * @param  build the build to notify Stash of\n+\t * @return default build key\n \t */\n-\tprivate String getBuildKey(final AbstractBuild<?, ?> build) {\n+\tprivate String getDefaultBuildKey(final AbstractBuild<?, ?> build) {\n \t\tStringBuilder key = new StringBuilder();\n+\n \t\tkey.append(build.getProject().getName());\n-        if (includeBuildNumberInKey \n-        \t\t|| getDescriptor().isIncludeBuildNumberInKey()) {\n+\t\tif (includeBuildNumberInKey\n+\t\t\t\t|| getDescriptor().isIncludeBuildNumberInKey()) {\n \t\t\tkey.append('-').append(build.getNumber());\n \t\t}\n \t\tkey.append('-').append(Jenkins.getInstance().getRootUrl());\n+\n+\t\treturn key.toString();\n+\t}\n+\n+\t\t/**\n+         * Returns the build key used in the Stash notification. Includes the\n+         * build number depending on the user setting.\n+         *\n+         * @param \tbuild\tthe build to notify Stash of\n+         * @return\tthe build key for the Stash notification\n+         */\n+\tprivate String getBuildKey(final AbstractBuild<?, ?> build,\n+\t\t\t\t\t\t\t   BuildListener listener) {\n+\n+\t\tStringBuilder key = new StringBuilder();\n+\n+\t\tif (prependParentProjectKey || getDescriptor().isPrependParentProjectKey()){\n+\t\t\tif (null != build.getParent().getParent()) {\n+\t\t\t\tkey.append(build.getParent().getParent().getFullName()).append('-');\n+\t\t\t}\n+\t\t}\n+\n+\t\tString overriddenKey = (projectKey != null && projectKey.trim().length() > 0) ? projectKey : getDescriptor().getProjectKey();","path":"src/main/java/org/jenkinsci/plugins/stashNotifier/StashNotifier.java","position":465,"original_position":465,"commit_id":"a59206cb43121016a3445dac6f5e65a15e2b2740","original_commit_id":"a59206cb43121016a3445dac6f5e65a15e2b2740","user":{"login":"scaytrase","id":6578413,"avatar_url":"https://avatars.githubusercontent.com/u/6578413?v=3","gravatar_id":"","url":"https://api.github.com/users/scaytrase","html_url":"https://github.com/scaytrase","followers_url":"https://api.github.com/users/scaytrase/followers","following_url":"https://api.github.com/users/scaytrase/following{/other_user}","gists_url":"https://api.github.com/users/scaytrase/gists{/gist_id}","starred_url":"https://api.github.com/users/scaytrase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scaytrase/subscriptions","organizations_url":"https://api.github.com/users/scaytrase/orgs","repos_url":"https://api.github.com/users/scaytrase/repos","events_url":"https://api.github.com/users/scaytrase/events{/privacy}","received_events_url":"https://api.github.com/users/scaytrase/received_events","type":"User","site_admin":false},"body":"I'm not sure it is the best way to check that parameter is not empty. Is this correct? projectKey is never set up at global configuration, so I can miss something due to I'm new to Jenkins API","created_at":"2015-05-20T20:29:49Z","updated_at":"2015-05-20T20:29:49Z","html_url":"https://github.com/jenkinsci/stashnotifier-plugin/pull/60#discussion_r30745582","pull_request_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/pulls/60","_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/pulls/comments/30745582"},"html":{"href":"https://github.com/jenkinsci/stashnotifier-plugin/pull/60#discussion_r30745582"},"pull_request":{"href":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/pulls/60"}}},"pull_request":{"url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/pulls/60","id":35706729,"html_url":"https://github.com/jenkinsci/stashnotifier-plugin/pull/60","diff_url":"https://github.com/jenkinsci/stashnotifier-plugin/pull/60.diff","patch_url":"https://github.com/jenkinsci/stashnotifier-plugin/pull/60.patch","issue_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/issues/60","number":60,"state":"open","locked":false,"title":"Enhanced project keys","user":{"login":"scaytrase","id":6578413,"avatar_url":"https://avatars.githubusercontent.com/u/6578413?v=3","gravatar_id":"","url":"https://api.github.com/users/scaytrase","html_url":"https://github.com/scaytrase","followers_url":"https://api.github.com/users/scaytrase/followers","following_url":"https://api.github.com/users/scaytrase/following{/other_user}","gists_url":"https://api.github.com/users/scaytrase/gists{/gist_id}","starred_url":"https://api.github.com/users/scaytrase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scaytrase/subscriptions","organizations_url":"https://api.github.com/users/scaytrase/orgs","repos_url":"https://api.github.com/users/scaytrase/repos","events_url":"https://api.github.com/users/scaytrase/events{/privacy}","received_events_url":"https://api.github.com/users/scaytrase/received_events","type":"User","site_admin":false},"body":"Here is implementation for two options \r\n\r\n* Custom persist project key for a job (Fix #36 )\r\n* Option to prepend parent project name for nested project (i.e maven subprojects). This helps to different jobs operating subprojects with same name to keep different notifications instead of overriding each other.\r\n\r\nAll changes should be BC as disabled on empty (by default). All changes built and tested on my own jenkins installation.","created_at":"2015-05-19T08:33:01Z","updated_at":"2015-05-20T20:29:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b7dd64741fed873c4ff4ec93d53c8e8ec31bc83d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/pulls/60/commits","review_comments_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/pulls/60/comments","review_comment_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/issues/60/comments","statuses_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/statuses/a59206cb43121016a3445dac6f5e65a15e2b2740","head":{"label":"scaytrase:feature/enhanced-project-keys","ref":"feature/enhanced-project-keys","sha":"a59206cb43121016a3445dac6f5e65a15e2b2740","user":{"login":"scaytrase","id":6578413,"avatar_url":"https://avatars.githubusercontent.com/u/6578413?v=3","gravatar_id":"","url":"https://api.github.com/users/scaytrase","html_url":"https://github.com/scaytrase","followers_url":"https://api.github.com/users/scaytrase/followers","following_url":"https://api.github.com/users/scaytrase/following{/other_user}","gists_url":"https://api.github.com/users/scaytrase/gists{/gist_id}","starred_url":"https://api.github.com/users/scaytrase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scaytrase/subscriptions","organizations_url":"https://api.github.com/users/scaytrase/orgs","repos_url":"https://api.github.com/users/scaytrase/repos","events_url":"https://api.github.com/users/scaytrase/events{/privacy}","received_events_url":"https://api.github.com/users/scaytrase/received_events","type":"User","site_admin":false},"repo":{"id":35842504,"name":"stashnotifier-plugin","full_name":"scaytrase/stashnotifier-plugin","owner":{"login":"scaytrase","id":6578413,"avatar_url":"https://avatars.githubusercontent.com/u/6578413?v=3","gravatar_id":"","url":"https://api.github.com/users/scaytrase","html_url":"https://github.com/scaytrase","followers_url":"https://api.github.com/users/scaytrase/followers","following_url":"https://api.github.com/users/scaytrase/following{/other_user}","gists_url":"https://api.github.com/users/scaytrase/gists{/gist_id}","starred_url":"https://api.github.com/users/scaytrase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scaytrase/subscriptions","organizations_url":"https://api.github.com/users/scaytrase/orgs","repos_url":"https://api.github.com/users/scaytrase/repos","events_url":"https://api.github.com/users/scaytrase/events{/privacy}","received_events_url":"https://api.github.com/users/scaytrase/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/scaytrase/stashnotifier-plugin","description":"A Jenkins Plugin to notify Atlassian Stash of build results ","fork":true,"url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin","forks_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/forks","keys_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/teams","hooks_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/hooks","issue_events_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/events","assignees_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/tags","blobs_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/languages","stargazers_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/stargazers","contributors_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/contributors","subscribers_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/subscribers","subscription_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/subscription","commits_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/merges","archive_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/downloads","issues_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/labels{/name}","releases_url":"https://api.github.com/repos/scaytrase/stashnotifier-plugin/releases{/id}","created_at":"2015-05-18T21:03:20Z","updated_at":"2015-05-18T21:03:21Z","pushed_at":"2015-05-20T20:22:42Z","git_url":"git://github.com/scaytrase/stashnotifier-plugin.git","ssh_url":"git@github.com:scaytrase/stashnotifier-plugin.git","clone_url":"https://github.com/scaytrase/stashnotifier-plugin.git","svn_url":"https://github.com/scaytrase/stashnotifier-plugin","homepage":null,"size":287,"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":"develop"}},"base":{"label":"jenkinsci:develop","ref":"develop","sha":"58894a0ac926b3176c1500ca267b1de23597aec3","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":8197450,"name":"stashnotifier-plugin","full_name":"jenkinsci/stashnotifier-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/stashnotifier-plugin","description":"A Jenkins Plugin to notify Atlassian Stash of build results ","fork":false,"url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin","forks_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/forks","keys_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/teams","hooks_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/hooks","issue_events_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/events","assignees_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/tags","blobs_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/languages","stargazers_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/stargazers","contributors_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/contributors","subscribers_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/subscribers","subscription_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/subscription","commits_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/merges","archive_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/downloads","issues_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/labels{/name}","releases_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/releases{/id}","created_at":"2013-02-14T10:24:41Z","updated_at":"2015-05-07T22:15:40Z","pushed_at":"2015-05-20T20:22:43Z","git_url":"git://github.com/jenkinsci/stashnotifier-plugin.git","ssh_url":"git@github.com:jenkinsci/stashnotifier-plugin.git","clone_url":"https://github.com/jenkinsci/stashnotifier-plugin.git","svn_url":"https://github.com/jenkinsci/stashnotifier-plugin","homepage":null,"size":826,"stargazers_count":43,"watchers_count":43,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":43,"mirror_url":null,"open_issues_count":21,"forks":43,"open_issues":21,"watchers":43,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/pulls/60"},"html":{"href":"https://github.com/jenkinsci/stashnotifier-plugin/pull/60"},"issue":{"href":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/issues/60"},"comments":{"href":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/issues/60/comments"},"review_comments":{"href":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/pulls/60/comments"},"review_comment":{"href":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/pulls/60/commits"},"statuses":{"href":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/statuses/a59206cb43121016a3445dac6f5e65a15e2b2740"}}}}