Created
July 6, 2017 19:26
-
-
Save martinda/3fc193de9ac34e38b18068ea6d3ae662 to your computer and use it in GitHub Desktop.
Detect Symbolic link in Jenkins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This snippet causes a java.io.NotSerializableException: sun.nio.fs.UnixPath | |
// Not sure why because I use @NonCPS | |
import java.nio.file.Path | |
import java.nio.file.Paths | |
import java.nio.file.Files | |
Path gradlePropertiesPath = Paths.get('/localdisk/jenkins/gradle/gradle.properties') | |
node() { | |
symlinkFile(gradlePropertiesPath) | |
echo "Done" | |
} | |
@NonCPS | |
void symlinkFile(Path filePath) { | |
// If the symlink already exists, there is nothing to do | |
if (Files.readSymbolicLink(filePath)) { | |
return | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment