■ ■ ■ ■ ■ ■
src/main/java/io/onedev/agent/ShellExecutorUtils.java
| skipped 139 lines |
140 | 140 | | |
141 | 141 | | File userDir = new File(buildDir, "user"); |
142 | 142 | | FileUtils.createDir(userDir); |
143 | | - | Map<String, String> environments = new HashMap<>(); |
144 | | - | environments.put("HOME", userDir.getAbsolutePath()); |
145 | 143 | | |
146 | 144 | | String messageData = jobData.getJobToken() + ":" + workspaceDir.getAbsolutePath(); |
147 | 145 | | new Message(MessageType.REPORT_JOB_WORKSPACE, messageData).sendBy(session); |
| skipped 35 lines |
183 | 181 | | for (Map.Entry<CacheInstance, String> entry: cacheAllocations.entrySet()) { |
184 | 182 | | if (!PathUtils.isCurrent(entry.getValue())) { |
185 | 183 | | File sourceDir = entry.getKey().getDirectory(cacheHomeDir); |
186 | | - | File destDir = resolveCachePath(workspaceDir, userDir, entry.getValue()); |
| 184 | + | File destDir = resolveCachePath(workspaceDir, entry.getValue()); |
187 | 185 | | if (destDir.exists()) |
188 | 186 | | FileUtils.deleteDir(destDir); |
189 | 187 | | else |
| skipped 7 lines |
197 | 195 | | } |
198 | 196 | | |
199 | 197 | | Commandline shell = getShell(); |
| 198 | + | Map<String, String> environments = new HashMap<>(); |
| 199 | + | environments.put("GIT_HOME", userDir.getAbsolutePath()); |
200 | 200 | | shell.workingDir(workspaceDir).environments(environments); |
201 | 201 | | shell.addArgs(jobScriptFile.getAbsolutePath()); |
202 | 202 | | |
| skipped 8 lines |
211 | 211 | | jobLogger.log("Checking out code..."); |
212 | 212 | | Commandline git = new Commandline(Agent.gitPath); |
213 | 213 | | git.workingDir(workspaceDir); |
| 214 | + | Map<String, String> environments = new HashMap<>(); |
| 215 | + | environments.put("HOME", userDir.getAbsolutePath()); |
214 | 216 | | git.environments(environments); |
215 | 217 | | |
216 | 218 | | CloneInfo cloneInfo = checkoutExecutable.getCloneInfo(); |
| skipped 107 lines |
324 | 326 | | return new Commandline("sh"); |
325 | 327 | | } |
326 | 328 | | |
327 | | - | public static File resolveCachePath(File workspaceDir, File homeDir, String cachePath) { |
| 329 | + | public static File resolveCachePath(File workspaceDir, String cachePath) { |
328 | 330 | | if (cachePath.startsWith(KubernetesHelper.HOME_PREFIX)) { |
| 331 | + | File homeDir = new File(System.getProperty("user.home")); |
329 | 332 | | return new File(homeDir, cachePath.substring(KubernetesHelper.HOME_PREFIX.length())); |
330 | 333 | | } else { |
331 | 334 | | File cacheDir = new File(cachePath); |
| skipped 64 lines |