Skip to content

Instantly share code, notes, and snippets.

@samvarankashyap
Created September 8, 2017 19:42
Show Gist options
  • Save samvarankashyap/6164edca31ae1a8e11f10328d412b8e7 to your computer and use it in GitHub Desktop.
Save samvarankashyap/6164edca31ae1a8e11f10328d412b8e7 to your computer and use it in GitHub Desktop.
node {
echo 'Hello World'
timestamps {
// Just some echoes to show the timestamps.
stage "First echo"
echo "Hey, look, I'm echoing with a timestamp!"
// A sleep to make sure we actually get a real difference!
stage "Sleeping"
sleep 30
// And a final echo to show the time when we wrap up.
stage "Second echo"
echo "Wonder what time it is now?"
}
stage "Create build output"
// Make the output directory.
sh "mkdir -p output"
// Write an useful file, which is needed to be archived.
writeFile file: "output/usefulfile.txt", text: "This file is useful, need to archive it."
// Write an useless file, which is not needed to be archived.
writeFile file: "output/uselessfile.md", text: "This file is useless, no need to archive it."
stage "Archive build output"
// Archive the build output artifacts.
archiveArtifacts artifacts: 'output/*.txt', excludes: 'output/*.md'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment