Skip to content

Instantly share code, notes, and snippets.

@martinda
Created July 6, 2017 19:26
Show Gist options
  • Save martinda/3fc193de9ac34e38b18068ea6d3ae662 to your computer and use it in GitHub Desktop.
Save martinda/3fc193de9ac34e38b18068ea6d3ae662 to your computer and use it in GitHub Desktop.
Detect Symbolic link in Jenkins
// 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