I am attempting to test a Jenkinsfile, with docker images, and various tests using a Jenkins Pipeline. I am able to checkout the latest code from Gerrit using a branch name or a merged commit hash. But, want to know if it is possible to test using an un-merged commit hash. I am trying to test this using a commit before it is merged for the following reasons:
- In case the commit breaks existing code.
- In case my docker images and other files are not actually set up properly. If I were to find an error in the Jenkinsfile or other configuration files, I would have to keep pushing code until I get it right.
Is this possible? How do you all test your files and pipeline before merging?
The following is my Jenkinsfile syntax:
pipeline {
agent any
stages {
stage('Checkout git repository') {
agent any
steps {
checkout([
$class: 'GitSCM',
branches: [[name: '<un-merged commit hash>']],
extensions: [[$class: 'WipeWorkspace']],
userRemoteConfigs: [[
credentialsId: '<credentials hash>',
url: '<git repository url>'
]]
])
}
}
}
}
$GERRIT_REFSPEC
. And I set up the Script Path to point to my Jenkinsfile in my Gerrit directory. – Dr Bass Dec 2 '19 at 17:49