{"action":"created","issue":{"url":"https://api.github.com/repos/cloudbees/groovy-cps/issues/61","repository_url":"https://api.github.com/repos/cloudbees/groovy-cps","labels_url":"https://api.github.com/repos/cloudbees/groovy-cps/issues/61/labels{/name}","comments_url":"https://api.github.com/repos/cloudbees/groovy-cps/issues/61/comments","events_url":"https://api.github.com/repos/cloudbees/groovy-cps/issues/61/events","html_url":"https://github.com/cloudbees/groovy-cps/pull/61","id":234926180,"number":61,"title":"[FIXED JENKINS-38268] Proper lexical scoping for closure variables.","user":{"login":"abayer","id":120218,"avatar_url":"https://avatars1.githubusercontent.com/u/120218?v=3","gravatar_id":"","url":"https://api.github.com/users/abayer","html_url":"https://github.com/abayer","followers_url":"https://api.github.com/users/abayer/followers","following_url":"https://api.github.com/users/abayer/following{/other_user}","gists_url":"https://api.github.com/users/abayer/gists{/gist_id}","starred_url":"https://api.github.com/users/abayer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abayer/subscriptions","organizations_url":"https://api.github.com/users/abayer/orgs","repos_url":"https://api.github.com/users/abayer/repos","events_url":"https://api.github.com/users/abayer/events{/privacy}","received_events_url":"https://api.github.com/users/abayer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-06-09T20:05:27Z","updated_at":"2017-06-09T20:33:13Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/cloudbees/groovy-cps/pulls/61","html_url":"https://github.com/cloudbees/groovy-cps/pull/61","diff_url":"https://github.com/cloudbees/groovy-cps/pull/61.diff","patch_url":"https://github.com/cloudbees/groovy-cps/pull/61.patch"},"body":"[JENKINS-38268](https://issues.jenkins-ci.org/browse/JENKINS-38268)\r\n\r\nPreviously, any variables that hadn't been explicitly declared (via\r\n`ClosureCallEnv.declareVariable`) in a `Closure` would end up getting\r\nset in the captured `Env`. Which means we'd end up setting things\r\nglobally when we really didn't mean to. This changes that to only set\r\na variable in the captured `Env` if there's no `locals` variable\r\ndefined by that name *and* the captured `Env` has a non-null return\r\nfor `getVariableType(name)` - i.e., the variable name has already been\r\ndeclared in the captured `Env`.\r\n\r\nFurther tests in a `parallel` will be needed in `workflow-cps`.\r\n\r\ncc @reviewbybees "},"comment":{"url":"https://api.github.com/repos/cloudbees/groovy-cps/issues/comments/307492753","html_url":"https://github.com/cloudbees/groovy-cps/pull/61#issuecomment-307492753","issue_url":"https://api.github.com/repos/cloudbees/groovy-cps/issues/61","id":307492753,"user":{"login":"jglick","id":154109,"avatar_url":"https://avatars2.githubusercontent.com/u/154109?v=3","gravatar_id":"","url":"https://api.github.com/users/jglick","html_url":"https://github.com/jglick","followers_url":"https://api.github.com/users/jglick/followers","following_url":"https://api.github.com/users/jglick/following{/other_user}","gists_url":"https://api.github.com/users/jglick/gists{/gist_id}","starred_url":"https://api.github.com/users/jglick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jglick/subscriptions","organizations_url":"https://api.github.com/users/jglick/orgs","repos_url":"https://api.github.com/users/jglick/repos","events_url":"https://api.github.com/users/jglick/events{/privacy}","received_events_url":"https://api.github.com/users/jglick/received_events","type":"User","site_admin":false},"created_at":"2017-06-09T20:33:13Z","updated_at":"2017-06-09T20:33:13Z","body":"So it sounds like the bug is that `ClosureCallEnv.declareVariable` is not getting called. Perhaps in `CpsTransformer.visitClosureExpression`? Or perhaps `assignArguments` is wrong—but then how could it work in `CpsFunction`?"}}
{"actor":{"display_login":"jglick"}}