{"action":"created","comment":{"url":"https://api.github.com/repos/jenkinsci/jenkins/pulls/comments/28072597","id":28072597,"diff_hunk":"@@ -0,0 +1,143 @@\n+/*\n+ * The MIT License\n+ * \n+ * Copyright (c) 2013 IKEDA Yasuyuki\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+\n+package hudson;\n+\n+import static org.junit.Assert.*;\n+import hudson.model.Cause;\n+import hudson.model.FreeStyleProject;\n+import hudson.model.ParametersAction;\n+import hudson.model.StringParameterValue;\n+import hudson.slaves.DumbSlave;\n+\n+import java.lang.reflect.Field;\n+import java.util.Arrays;\n+\n+import org.junit.Rule;\n+import org.junit.Test;\n+import org.jvnet.hudson.test.JenkinsRule;\n+import org.jvnet.hudson.test.CaptureEnvironmentBuilder;\n+\n+public class EnvVarsTest {\n+    @Rule\n+    public JenkinsRule j = new JenkinsRule();\n+    \n+    private void resetEnvVarsCache() throws Exception {\n+        Field f = EnvVars.class.getDeclaredField(\"shouldNotCaseSensitive\");\n+        f.setAccessible(true);\n+        f.set(null, null);\n+        f.setAccessible(false);\n+    }\n+    \n+    @Test\n+    public void testCaseSensitiveOnMaster() throws Exception {\n+        assertNull(System.getProperty(EnvVars.PROP_CASE_INSENSITIVE));\n+        resetEnvVarsCache();\n+        \n+        FreeStyleProject p = j.createFreeStyleProject();\n+        CaptureEnvironmentBuilder ceb = new CaptureEnvironmentBuilder();\n+        p.getBuildersList().add(ceb);\n+        j.assertBuildStatusSuccess(p.scheduleBuild2(0, new Cause.UserCause(), Arrays.asList(\n+                new ParametersAction(\n+                        new StringParameterValue(\"var1\", \"value1\"),\n+                        new StringParameterValue(\"Var1\", \"value2\")\n+                )\n+        )));\n+        assertEquals(\"value1\", ceb.getEnvVars().get(\"var1\"));\n+        assertEquals(\"value2\", ceb.getEnvVars().get(\"Var1\"));\n+        assertNull(ceb.getEnvVars().get(\"VAR1\"));\n+    }\n+    \n+    @Test\n+    public void testCaseSensitiveOnSlave() throws Exception {\n+        assertNull(System.getProperty(EnvVars.PROP_CASE_INSENSITIVE));\n+        resetEnvVarsCache();\n+        \n+        DumbSlave slave = j.createOnlineSlave();\n+        FreeStyleProject p = j.createFreeStyleProject();\n+        p.setAssignedNode(slave);\n+        CaptureEnvironmentBuilder ceb = new CaptureEnvironmentBuilder();\n+        p.getBuildersList().add(ceb);\n+        j.assertBuildStatusSuccess(p.scheduleBuild2(0, new Cause.UserCause(), Arrays.asList(\n+                new ParametersAction(\n+                        new StringParameterValue(\"var1\", \"value1\"),\n+                        new StringParameterValue(\"Var1\", \"value2\")\n+                )\n+        )));\n+        assertEquals(\"value1\", ceb.getEnvVars().get(\"var1\"));\n+        assertEquals(\"value2\", ceb.getEnvVars().get(\"Var1\"));\n+        assertNull(ceb.getEnvVars().get(\"VAR1\"));\n+    }\n+    \n+    @Test\n+    public void testCaseInsensitiveOnMaster() throws Exception {\n+        assertNull(System.getProperty(EnvVars.PROP_CASE_INSENSITIVE));\n+        try {\n+            System.setProperty(EnvVars.PROP_CASE_INSENSITIVE, \"true\");\n+            resetEnvVarsCache();\n+            \n+            FreeStyleProject p = j.createFreeStyleProject();\n+            CaptureEnvironmentBuilder ceb = new CaptureEnvironmentBuilder();\n+            p.getBuildersList().add(ceb);\n+            j.assertBuildStatusSuccess(p.scheduleBuild2(0, new Cause.UserCause(), Arrays.asList(\n+                    new ParametersAction(\n+                            new StringParameterValue(\"var1\", \"value1\"),\n+                            new StringParameterValue(\"Var1\", \"value2\")\n+                    )\n+            )));\n+            String expected = ceb.getEnvVars().get(\"var1\");\n+            assertEquals(expected, ceb.getEnvVars().get(\"Var1\"));\n+            assertEquals(expected, ceb.getEnvVars().get(\"VAR1\"));\n+        } finally {\n+            System.getProperties().remove(EnvVars.PROP_CASE_INSENSITIVE);\n+        }\n+    }\n+    \n+    @Test\n+    public void testCaseInsensitiveOnSlave() throws Exception {\n+        assertNull(System.getProperty(EnvVars.PROP_CASE_INSENSITIVE));\n+        try {\n+            System.setProperty(EnvVars.PROP_CASE_INSENSITIVE, \"true\");","path":"test/src/test/java/hudson/EnvVarsTest.java","position":121,"original_position":121,"commit_id":"8caa2c3920d1fb0d2450a8777756c7af64c36f8b","original_commit_id":"8caa2c3920d1fb0d2450a8777756c7af64c36f8b","user":{"login":"jtnord","id":494726,"avatar_url":"https://avatars.githubusercontent.com/u/494726?v=3","gravatar_id":"","url":"https://api.github.com/users/jtnord","html_url":"https://github.com/jtnord","followers_url":"https://api.github.com/users/jtnord/followers","following_url":"https://api.github.com/users/jtnord/following{/other_user}","gists_url":"https://api.github.com/users/jtnord/gists{/gist_id}","starred_url":"https://api.github.com/users/jtnord/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtnord/subscriptions","organizations_url":"https://api.github.com/users/jtnord/orgs","repos_url":"https://api.github.com/users/jtnord/repos","events_url":"https://api.github.com/users/jtnord/events{/privacy}","received_events_url":"https://api.github.com/users/jtnord/received_events","type":"User","site_admin":false},"body":"tests should not touch system properties as they can affect other tests running concurrently.","created_at":"2015-04-09T15:32:05Z","updated_at":"2015-04-09T15:32:05Z","html_url":"https://github.com/jenkinsci/jenkins/pull/988#discussion_r28072597","pull_request_url":"https://api.github.com/repos/jenkinsci/jenkins/pulls/988","_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/jenkins/pulls/comments/28072597"},"html":{"href":"https://github.com/jenkinsci/jenkins/pull/988#discussion_r28072597"},"pull_request":{"href":"https://api.github.com/repos/jenkinsci/jenkins/pulls/988"}}},"pull_request":{"url":"https://api.github.com/repos/jenkinsci/jenkins/pulls/988","id":9450002,"html_url":"https://github.com/jenkinsci/jenkins/pull/988","diff_url":"https://github.com/jenkinsci/jenkins/pull/988.diff","patch_url":"https://github.com/jenkinsci/jenkins/pull/988.patch","issue_url":"https://api.github.com/repos/jenkinsci/jenkins/issues/988","number":988,"state":"open","locked":false,"title":"[FIX JENKINS-16255] Handle environment variables case-sensitive.","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},"body":"This is a fix for [JENKINS-16255] (https://issues.jenkins-ci.org/browse/JENKINS-16255).\r\nJenkins handles names of environment variables in case-insensitive way, and that often causes problems on UNIX platforms.\r\n\r\nJenkins have handled variables case-insensitively for Windows platforms ([JENKINS-968](https://issues.jenkins-ci.org/browse/JENKINS-968)):\r\n* An exception occurs when launching dot-net programs on Windows.\r\n    * I'm not sure how to reproduce this.\r\n* PATH environment variables are split (PATH and Path) and does not work. \r\n\r\nI resolved these problems in following ways:\r\n* When launching a native process, convert `EnvVars` into case-insensitive on Windows (`EnvVars#forNativeProcess`).\r\n* Handles XYZ+ABC environment variables case-insensitively if that `EnvVars` will be used for Windows.\r\n    * XYZ+ABC is used for adding a new path to the PATH variable. For example, when you use a maven builder, a path to maven binary is added to PATH. \r\n    * `EnvVars` that is overridden with XYZ+ABC is always instantiated on the node where a process is launched (which is done in `LocalLauncher`).\r\n\r\nUsers can have Jenkins works as before by launching with -Dhudson.EnvVars.caseInsensitive=true.\r\nConfiguring in the system configuration page would be most convenient, but it is not possible for `EnvVars` are used in a very early stage of launching, and the system configuration is not yet loaded.\r\n","created_at":"2013-10-28T13:59:03Z","updated_at":"2015-04-09T15:32:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fe5cc80fb0deca036c5bef5bbe180b405186d9e0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jenkinsci/jenkins/pulls/988/commits","review_comments_url":"https://api.github.com/repos/jenkinsci/jenkins/pulls/988/comments","review_comment_url":"https://api.github.com/repos/jenkinsci/jenkins/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jenkinsci/jenkins/issues/988/comments","statuses_url":"https://api.github.com/repos/jenkinsci/jenkins/statuses/8caa2c3920d1fb0d2450a8777756c7af64c36f8b","head":{"label":"ikedam:feature/JENKINS-16255_CaseSensitiveEnvVars_after20280","ref":"feature/JENKINS-16255_CaseSensitiveEnvVars_after20280","sha":"8caa2c3920d1fb0d2450a8777756c7af64c36f8b","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},"repo":{"id":9817848,"name":"jenkins","full_name":"ikedam/jenkins","owner":{"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},"private":false,"html_url":"https://github.com/ikedam/jenkins","description":"Jenkins Continuous Integration Server","fork":true,"url":"https://api.github.com/repos/ikedam/jenkins","forks_url":"https://api.github.com/repos/ikedam/jenkins/forks","keys_url":"https://api.github.com/repos/ikedam/jenkins/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ikedam/jenkins/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ikedam/jenkins/teams","hooks_url":"https://api.github.com/repos/ikedam/jenkins/hooks","issue_events_url":"https://api.github.com/repos/ikedam/jenkins/issues/events{/number}","events_url":"https://api.github.com/repos/ikedam/jenkins/events","assignees_url":"https://api.github.com/repos/ikedam/jenkins/assignees{/user}","branches_url":"https://api.github.com/repos/ikedam/jenkins/branches{/branch}","tags_url":"https://api.github.com/repos/ikedam/jenkins/tags","blobs_url":"https://api.github.com/repos/ikedam/jenkins/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ikedam/jenkins/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ikedam/jenkins/git/refs{/sha}","trees_url":"https://api.github.com/repos/ikedam/jenkins/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ikedam/jenkins/statuses/{sha}","languages_url":"https://api.github.com/repos/ikedam/jenkins/languages","stargazers_url":"https://api.github.com/repos/ikedam/jenkins/stargazers","contributors_url":"https://api.github.com/repos/ikedam/jenkins/contributors","subscribers_url":"https://api.github.com/repos/ikedam/jenkins/subscribers","subscription_url":"https://api.github.com/repos/ikedam/jenkins/subscription","commits_url":"https://api.github.com/repos/ikedam/jenkins/commits{/sha}","git_commits_url":"https://api.github.com/repos/ikedam/jenkins/git/commits{/sha}","comments_url":"https://api.github.com/repos/ikedam/jenkins/comments{/number}","issue_comment_url":"https://api.github.com/repos/ikedam/jenkins/issues/comments{/number}","contents_url":"https://api.github.com/repos/ikedam/jenkins/contents/{+path}","compare_url":"https://api.github.com/repos/ikedam/jenkins/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ikedam/jenkins/merges","archive_url":"https://api.github.com/repos/ikedam/jenkins/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ikedam/jenkins/downloads","issues_url":"https://api.github.com/repos/ikedam/jenkins/issues{/number}","pulls_url":"https://api.github.com/repos/ikedam/jenkins/pulls{/number}","milestones_url":"https://api.github.com/repos/ikedam/jenkins/milestones{/number}","notifications_url":"https://api.github.com/repos/ikedam/jenkins/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ikedam/jenkins/labels{/name}","releases_url":"https://api.github.com/repos/ikedam/jenkins/releases{/id}","created_at":"2013-05-02T17:00:50Z","updated_at":"2014-04-20T03:37:19Z","pushed_at":"2015-03-30T12:26:40Z","git_url":"git://github.com/ikedam/jenkins.git","ssh_url":"git@github.com:ikedam/jenkins.git","clone_url":"https://github.com/ikedam/jenkins.git","svn_url":"https://github.com/ikedam/jenkins","homepage":"http://jenkins-ci.org/","size":82818,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":false,"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":"af66dd0639e39217314f7d3648f831e85baf6750","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":1103607,"name":"jenkins","full_name":"jenkinsci/jenkins","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/jenkins","description":"Jenkins Continuous Integration Server","fork":true,"url":"https://api.github.com/repos/jenkinsci/jenkins","forks_url":"https://api.github.com/repos/jenkinsci/jenkins/forks","keys_url":"https://api.github.com/repos/jenkinsci/jenkins/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jenkinsci/jenkins/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jenkinsci/jenkins/teams","hooks_url":"https://api.github.com/repos/jenkinsci/jenkins/hooks","issue_events_url":"https://api.github.com/repos/jenkinsci/jenkins/issues/events{/number}","events_url":"https://api.github.com/repos/jenkinsci/jenkins/events","assignees_url":"https://api.github.com/repos/jenkinsci/jenkins/assignees{/user}","branches_url":"https://api.github.com/repos/jenkinsci/jenkins/branches{/branch}","tags_url":"https://api.github.com/repos/jenkinsci/jenkins/tags","blobs_url":"https://api.github.com/repos/jenkinsci/jenkins/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jenkinsci/jenkins/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jenkinsci/jenkins/git/refs{/sha}","trees_url":"https://api.github.com/repos/jenkinsci/jenkins/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jenkinsci/jenkins/statuses/{sha}","languages_url":"https://api.github.com/repos/jenkinsci/jenkins/languages","stargazers_url":"https://api.github.com/repos/jenkinsci/jenkins/stargazers","contributors_url":"https://api.github.com/repos/jenkinsci/jenkins/contributors","subscribers_url":"https://api.github.com/repos/jenkinsci/jenkins/subscribers","subscription_url":"https://api.github.com/repos/jenkinsci/jenkins/subscription","commits_url":"https://api.github.com/repos/jenkinsci/jenkins/commits{/sha}","git_commits_url":"https://api.github.com/repos/jenkinsci/jenkins/git/commits{/sha}","comments_url":"https://api.github.com/repos/jenkinsci/jenkins/comments{/number}","issue_comment_url":"https://api.github.com/repos/jenkinsci/jenkins/issues/comments{/number}","contents_url":"https://api.github.com/repos/jenkinsci/jenkins/contents/{+path}","compare_url":"https://api.github.com/repos/jenkinsci/jenkins/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jenkinsci/jenkins/merges","archive_url":"https://api.github.com/repos/jenkinsci/jenkins/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jenkinsci/jenkins/downloads","issues_url":"https://api.github.com/repos/jenkinsci/jenkins/issues{/number}","pulls_url":"https://api.github.com/repos/jenkinsci/jenkins/pulls{/number}","milestones_url":"https://api.github.com/repos/jenkinsci/jenkins/milestones{/number}","notifications_url":"https://api.github.com/repos/jenkinsci/jenkins/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jenkinsci/jenkins/labels{/name}","releases_url":"https://api.github.com/repos/jenkinsci/jenkins/releases{/id}","created_at":"2010-11-22T21:21:23Z","updated_at":"2015-04-09T07:57:02Z","pushed_at":"2015-04-09T05:52:26Z","git_url":"git://github.com/jenkinsci/jenkins.git","ssh_url":"git@github.com:jenkinsci/jenkins.git","clone_url":"https://github.com/jenkinsci/jenkins.git","svn_url":"https://github.com/jenkinsci/jenkins","homepage":"http://jenkins-ci.org/","size":404223,"stargazers_count":3912,"watchers_count":3912,"language":"Java","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":1760,"mirror_url":null,"open_issues_count":101,"forks":1760,"open_issues":101,"watchers":3912,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/jenkins/pulls/988"},"html":{"href":"https://github.com/jenkinsci/jenkins/pull/988"},"issue":{"href":"https://api.github.com/repos/jenkinsci/jenkins/issues/988"},"comments":{"href":"https://api.github.com/repos/jenkinsci/jenkins/issues/988/comments"},"review_comments":{"href":"https://api.github.com/repos/jenkinsci/jenkins/pulls/988/comments"},"review_comment":{"href":"https://api.github.com/repos/jenkinsci/jenkins/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jenkinsci/jenkins/pulls/988/commits"},"statuses":{"href":"https://api.github.com/repos/jenkinsci/jenkins/statuses/8caa2c3920d1fb0d2450a8777756c7af64c36f8b"}}}}