Jump to content

Jenkins Pipeline and checkout


Recommended Posts

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'
               ]]
           ])

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.