Hi, we normally store our Jenkinsfiles with SVN. We have a need to monitor and respond to changes in a GitHub repo. My thoughts are to use a declarative pipeline, hosted in SVN, to checkout (clone?) the GitHub repo, monitor it for changes (manually - not using Jenkins polling) and to commit some changes according to the incoming changes.
So I need to be able to clone a GitHub repo from with a declarative pipeline. This StackOverflow answer suggests using this pipeline code:
node {
def gradleHome
stage('Prepare/Checkout') { // for display purposes
git branch: 'develop', url: 'https://github.com/WtfJoke/Any.git'
dir('a-child-repo') {
git branch: 'develop', url: 'https://github.com/WtfJoke/AnyChild.git'
}
env.JAVA_HOME="${tool 'JDK8'}"
env.PATH="${env.JAVA_HOME}/bin:${env.PATH}" // set java home in jdk environment
gradleHome = tool '3.4.1'
}
stage('Build') {
// Run the gradle build
if (isUnix()) {
sh "'${gradleHome}/bin/gradle' clean build"
} else {
bat(/"${gradleHome}\bin\gradle" clean build/)
}
}
}
Could I do something similar in declarative syntax?
Or do you have any other suggestions please?