@@ -322,7 +322,10 @@ public void symlinksInNonMultibranchCannotEscapeWorkspaceContextViaReadTrusted()
322
322
FileUtils .copyDirectory (new File (sampleRepo .getRoot (), ".git" ), gitDirInSvnRepo );
323
323
String jenkinsRootDir = r .jenkins .getRootDir ().toString ();
324
324
// Add a Git post-checkout hook to the .git folder in the SVN repo.
325
- Files .write (gitDirInSvnRepo .toPath ().resolve ("hooks/post-checkout" ), ("#!/bin/sh\n touch '" + jenkinsRootDir + "/hook-executed'\n " ).getBytes (StandardCharsets .UTF_8 ));
325
+ Path postCheckoutHook = gitDirInSvnRepo .toPath ().resolve ("hooks/post-checkout" );
326
+ // Always create hooks directory for compatibility with https://github.com/jenkinsci/git-plugin/pull/1207.
327
+ Files .createDirectories (postCheckoutHook .getParent ());
328
+ Files .write (postCheckoutHook , ("#!/bin/sh\n touch '" + jenkinsRootDir + "/hook-executed'\n " ).getBytes (StandardCharsets .UTF_8 ));
326
329
sampleRepoSvn .svnkit ("add" , sampleRepoSvn .wc () + "/Jenkinsfile" );
327
330
sampleRepoSvn .svnkit ("add" , sampleRepoSvn .wc () + "/.git" );
328
331
sampleRepoSvn .svnkit ("propset" , "svn:executable" , "ON" , sampleRepoSvn .wc () + "/.git/hooks/post-checkout" );
@@ -357,7 +360,10 @@ public void symlinksInNonMultibranchCannotEscapeWorkspaceContextViaReadTrusted()
357
360
FileUtils .copyDirectory (new File (sampleRepo .getRoot (), ".git" ), gitDirInSvnRepo );
358
361
String jenkinsRootDir = r .jenkins .getRootDir ().toString ();
359
362
// Add a Git post-checkout hook to the .git folder in the SVN repo.
360
- Files .write (gitDirInSvnRepo .toPath ().resolve ("hooks/post-checkout" ), ("#!/bin/sh\n touch '" + jenkinsRootDir + "/hook-executed'\n " ).getBytes (StandardCharsets .UTF_8 ));
363
+ Path postCheckoutHook = gitDirInSvnRepo .toPath ().resolve ("hooks/post-checkout" );
364
+ // Always create hooks directory for compatibility with https://github.com/jenkinsci/git-plugin/pull/1207.
365
+ Files .createDirectories (postCheckoutHook .getParent ());
366
+ Files .write (postCheckoutHook , ("#!/bin/sh\n touch '" + jenkinsRootDir + "/hook-executed'\n " ).getBytes (StandardCharsets .UTF_8 ));
361
367
sampleRepoSvn .svnkit ("add" , sampleRepoSvn .wc () + "/Jenkinsfile" );
362
368
sampleRepoSvn .svnkit ("add" , sampleRepoSvn .wc () + "/.git" );
363
369
sampleRepoSvn .svnkit ("propset" , "svn:executable" , "ON" , sampleRepoSvn .wc () + "/.git/hooks/post-checkout" );
0 commit comments