{"action":"created","comment":{"url":"https://api.github.com/repos/jenkinsci/ownership-plugin/pulls/comments/53775406","id":53775406,"diff_hunk":"@@ -0,0 +1,148 @@\n+/*\n+ * The MIT License\n+ *\n+ * Copyright (c) 2016 CloudBees, Inc.\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the \"Software\"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be included in\n+ * all copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+ * THE SOFTWARE.\n+ */\n+package org.jenkinsci.plugins.ownership.model.workflow;\n+\n+import com.synopsys.arc.jenkins.plugins.ownership.OwnershipDescription;\n+import com.synopsys.arc.jenkins.plugins.ownership.jobs.JobOwnerHelper;\n+import com.synopsys.arc.jenkins.plugins.ownership.nodes.NodeOwnerHelper;\n+import groovy.lang.Binding;\n+import hudson.Extension;\n+import hudson.model.Node;\n+import hudson.model.Run;\n+import java.io.IOException;\n+import java.io.InputStream;\n+import javax.annotation.CheckForNull;\n+import javax.annotation.Nonnull;\n+import jenkins.model.Jenkins;\n+import org.apache.commons.io.IOUtils;\n+import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.ProxyWhitelist;\n+import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist;\n+import org.jenkinsci.plugins.workflow.cps.CpsScript;\n+import org.jenkinsci.plugins.workflow.cps.GlobalVariable;\n+import org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper;\n+import org.kohsuke.accmod.Restricted;\n+import org.kohsuke.accmod.restrictions.NoExternalUse;\n+\n+/**\n+ * Provides {@link OwnershipDescription}s for different item types.\n+ * @author Oleg Nenashev\n+ * @since TODO\n+ */\n+@Extension\n+public class OwnershipGlobalVariable extends GlobalVariable {\n+\n+    @Override \n+    public final Object getValue(CpsScript script) throws Exception {   \n+        final Binding binding = script.getBinding();\n+        final Object loadedObject;\n+        if (binding.hasVariable(getName())) {\n+            loadedObject = binding.getVariable(getName());\n+        } else {\n+            // Note that if this were a method rather than a constructor, we would need to mark it @NonCPS lest it throw CpsCallableInvocation.\n+            loadedObject = script.getClass().getClassLoader()\n+                    .loadClass(getClassName())\n+                    .getConstructor(CpsScript.class).newInstance(script);\n+            binding.setVariable(getName(), loadedObject);\n+        }\n+        return loadedObject;\n+    }","path":"src/main/java/org/jenkinsci/plugins/ownership/model/workflow/OwnershipGlobalVariable.java","position":69,"original_position":69,"commit_id":"9dfa1d1953fd233546a673e77f7507f8f0ac8da3","original_commit_id":"9dfa1d1953fd233546a673e77f7507f8f0ac8da3","user":{"login":"tfennelly","id":429311,"avatar_url":"https://avatars.githubusercontent.com/u/429311?v=3","gravatar_id":"","url":"https://api.github.com/users/tfennelly","html_url":"https://github.com/tfennelly","followers_url":"https://api.github.com/users/tfennelly/followers","following_url":"https://api.github.com/users/tfennelly/following{/other_user}","gists_url":"https://api.github.com/users/tfennelly/gists{/gist_id}","starred_url":"https://api.github.com/users/tfennelly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tfennelly/subscriptions","organizations_url":"https://api.github.com/users/tfennelly/orgs","repos_url":"https://api.github.com/users/tfennelly/repos","events_url":"https://api.github.com/users/tfennelly/events{/privacy}","received_events_url":"https://api.github.com/users/tfennelly/received_events","type":"User","site_admin":false},"body":"The above code really seems like code that a plugin should not need to have. Seems like `CpsScript` should provide this ootb.","created_at":"2016-02-23T12:51:31Z","updated_at":"2016-02-23T12:51:31Z","html_url":"https://github.com/jenkinsci/ownership-plugin/pull/45#discussion_r53775406","pull_request_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/pulls/45","_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/ownership-plugin/pulls/comments/53775406"},"html":{"href":"https://github.com/jenkinsci/ownership-plugin/pull/45#discussion_r53775406"},"pull_request":{"href":"https://api.github.com/repos/jenkinsci/ownership-plugin/pulls/45"}}},"pull_request":{"url":"https://api.github.com/repos/jenkinsci/ownership-plugin/pulls/45","id":60092129,"html_url":"https://github.com/jenkinsci/ownership-plugin/pull/45","diff_url":"https://github.com/jenkinsci/ownership-plugin/pull/45.diff","patch_url":"https://github.com/jenkinsci/ownership-plugin/pull/45.patch","issue_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/issues/45","number":45,"state":"open","locked":false,"title":"[JENKINS-32353] - Pipeline plugin support in Ownership Plugin","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":"- [x] - Manage Ownership UI and summary boxes\r\n- [x] - Global <code>ownership</code> variable for workflow CPS\r\n- [x] - Expose node ownership info if possible\r\n- [x] - Functional tests for Ownership variable\r\n- [x] - Functional tests for Ownership-based security\r\n- [x] - Documentation","created_at":"2016-02-21T15:47:53Z","updated_at":"2016-02-23T12:51:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"613f96baff90200eea0ecc55512311c846891092","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/pulls/45/commits","review_comments_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/pulls/45/comments","review_comment_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/issues/45/comments","statuses_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/statuses/9dfa1d1953fd233546a673e77f7507f8f0ac8da3","head":{"label":"oleg-nenashev:JENKINS-32353","ref":"JENKINS-32353","sha":"9dfa1d1953fd233546a673e77f7507f8f0ac8da3","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},"repo":{"id":28810931,"name":"ownership-plugin","full_name":"oleg-nenashev/ownership-plugin","owner":{"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},"private":false,"html_url":"https://github.com/oleg-nenashev/ownership-plugin","description":"Jenkins plugin. Provides explicit ownership of jobs and slaves","fork":true,"url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin","forks_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/forks","keys_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/teams","hooks_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/hooks","issue_events_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/events","assignees_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/tags","blobs_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/languages","stargazers_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/stargazers","contributors_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/contributors","subscribers_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/subscribers","subscription_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/subscription","commits_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/merges","archive_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/downloads","issues_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/labels{/name}","releases_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/oleg-nenashev/ownership-plugin/deployments","created_at":"2015-01-05T12:04:21Z","updated_at":"2015-05-06T08:33:52Z","pushed_at":"2016-02-21T18:08:47Z","git_url":"git://github.com/oleg-nenashev/ownership-plugin.git","ssh_url":"git@github.com:oleg-nenashev/ownership-plugin.git","clone_url":"https://github.com/oleg-nenashev/ownership-plugin.git","svn_url":"https://github.com/oleg-nenashev/ownership-plugin","homepage":"https://wiki.jenkins-ci.org/display/JENKINS/Ownership+Plugin","size":663,"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":"fe99e468f024c217fda09b75900f74ac38d1e806","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":11373851,"name":"ownership-plugin","full_name":"jenkinsci/ownership-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/ownership-plugin","description":"Jenkins plugin. Provides explicit ownership of jobs and slaves","fork":true,"url":"https://api.github.com/repos/jenkinsci/ownership-plugin","forks_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/forks","keys_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/teams","hooks_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/hooks","issue_events_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/events","assignees_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/tags","blobs_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/languages","stargazers_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/stargazers","contributors_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/contributors","subscribers_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/subscribers","subscription_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/subscription","commits_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/merges","archive_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/downloads","issues_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/labels{/name}","releases_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/jenkinsci/ownership-plugin/deployments","created_at":"2013-07-12T17:08:07Z","updated_at":"2016-01-05T22:34:47Z","pushed_at":"2016-02-21T18:08:47Z","git_url":"git://github.com/jenkinsci/ownership-plugin.git","ssh_url":"git@github.com:jenkinsci/ownership-plugin.git","clone_url":"https://github.com/jenkinsci/ownership-plugin.git","svn_url":"https://github.com/jenkinsci/ownership-plugin","homepage":"https://wiki.jenkins-ci.org/display/JENKINS/Ownership+Plugin","size":656,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":4,"forks":8,"open_issues":4,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/ownership-plugin/pulls/45"},"html":{"href":"https://github.com/jenkinsci/ownership-plugin/pull/45"},"issue":{"href":"https://api.github.com/repos/jenkinsci/ownership-plugin/issues/45"},"comments":{"href":"https://api.github.com/repos/jenkinsci/ownership-plugin/issues/45/comments"},"review_comments":{"href":"https://api.github.com/repos/jenkinsci/ownership-plugin/pulls/45/comments"},"review_comment":{"href":"https://api.github.com/repos/jenkinsci/ownership-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jenkinsci/ownership-plugin/pulls/45/commits"},"statuses":{"href":"https://api.github.com/repos/jenkinsci/ownership-plugin/statuses/9dfa1d1953fd233546a673e77f7507f8f0ac8da3"}}}}