Technotes

Technotes for future me

Jenkins use git submodule with declarative pipeline

To use/checkout a submodule in a Jenkins declarative pipeline use this:

Own example

    stage ('Build') {
        sh 'git submodule update --init --recursive'
        sh "docker build -t technotes:1 ."
    }

Stack overflow example


pipeline {
    agent any

    environment {
        GIT_SSH_COMMAND = 'ssh -i /path/to/my/private/key'
    }

    stages {
        stage('Build') {
            steps {
                sh 'printenv'
                sh 'git submodule update --init --recursive'
            }
        }
    }
}
Last updated on 31 Jan 2021
Published on 16 Dec 2019
Edit on GitHub