Skip to content

Instantly share code, notes, and snippets.

@mattiasb
Last active March 23, 2018 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattiasb/4514db3ad2c56c66bb0d8202f9335552 to your computer and use it in GitHub Desktop.
Save mattiasb/4514db3ad2c56c66bb0d8202f9335552 to your computer and use it in GitHub Desktop.
Will I get the same agent?
// In the following pipeline the stages that start with 'Build: ' needs to run
// on the same node and in the same workspace, the same is true for the stages
// that begin with 'Test: '
// Will this be the case as the pipeline is written?
// If not, can I force the pipeline to do so?
pipeline {
options {
skipDefaultCheckout()
}
environment {
// In a real world pipeline this would be calculated via git-describe
GIT_TAG = 'v1.1'
}
stages {
stage('Build: Run') {
agent {
label 'builder'
}
steps {
cleanWs()
checkout scm
// Builds src/ and stores artifacts under build/
bat 'builder.bat build src/ build/'
}
}
stage('Build: Archive') {
agent {
label 'builder'
}
steps {
// Compresses the build dir
bat 'archiver.bat archive build/ build-${env.GIT_TAG}.zip'
// Saves under some artifact network share
bat 'archiver.bat store-archive build-${env.GIT_TAG}.zip'
}
}
stage('Test: Fetch Archive') {
agent {
label 'tester'
}
steps {
cleanWs()
// Gets the build artifacts from the artifact network share
bat 'archiver.bat get-archive build-${env.GIT_TAG}.zip'
// Uncompresses the build artifacts under build/
bat 'archiver.bat unarchive ${env.GIT_TAG}.zip build/'
}
}
stage('Test: Run') {
agent {
label 'tester'
}
steps {
// Run tests and store results under tests/
bat 'tester.bat test build/ tests/'
}
}
stage('Test') {
agent {
label 'tester'
}
steps {
// Compresses the test results dir
bat 'archiver.bat archive tests/ tests-${env.GIT_TAG}.zip'
// Saves under some artifact network share
bat 'archiver.bat store-archive tests-${env.GIT_TAG}.zip'
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment