Drongo_III Posted May 14, 2020 Share Posted May 14, 2020 Sorry if this post doesn't belong here or anywhere else on this site. I'm trying to build a Jenkins pipeline using the declarative Jenkinsfile. I've used the Git SCM plugin to pull down the main GitHub repo for the build. It gets triggered off a GitHub Webhook. This works great. The next thing I want to do is pull in another repository for the same build step that contains the build code (i.e. the steps for building the application that came down with the original Git SCM trigger). I want to separate it because the build code is common to a number of applications i'll be building so makes no sense to store it with each application. The problem comes when I try to checkout another repo in my build step. It effectively wipes out the repository files from the original SCM checkout that happened when it was triggered. What i was expecting to happen is to be able to checkout the additional build repository files to a sub-directory leaving the original files in tact. But that doesn't happen. Am I using this incorrectly? Or is it just how the plugin works that you're only allowed to checkout one repo at a time? I've added an excerpt from my Jenkinsfile below. It's the checkout step below that seems to wipe out the repo that was pulled down when the build was triggered. stages { stage('Building') { steps { sh "mkdir test && cd test" //use this to checkout the repo for build script checkout([$class: 'GitSCM', branches: [[name: '*/master' ]], extensions: scm.extensions, userRemoteConfigs: [[ url: 'git@github.com:XXX/build-code.git', credentialsId: 'XXX-XXX-XXX-XXX-XXX' ]] ]) Quote Link to comment Share on other sites More sharing options...
requinix Posted May 14, 2020 Share Posted May 14, 2020 Set it up as a submodule, or install it to the build host manually and reuse it that way, or write your common build code as extensions to Jenkins directly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.