N
N
Nikolay Baranenko2021-06-21 22:45:23
Jenkins
Nikolay Baranenko, 2021-06-21 22:45:23

What is the right way to run pipeline update sub modules?

I want to reuse the template pipeline in the pipeline of the project in a smaller way, which, like bricks, lie in the sub module

in git, there is a repo with the project and tried it with jenkins-ci-examples

in the project first like this

pipeline {
    agent any
    stages {
        stage ('Checkout') {
            steps {
                deleteDir()
                checkout scm
                sh 'git submodule update --init --recursive jenkins-ci-examples'                
            }
        }
        stage('test import template') {
            steps {
                script{
                    sh "cd jenkins-ci-examples; ls -las";
                    jenkins_ci_examples.test_module = load "first_template.groovy"
                }
            }
        }

        stage('test run template') {
            steps {
                script{
                    jenkins_ci_examples.test_module.ansible_sskkeys("vars")
                }
            }
        }

    }
}


then like this

node{
checkout([
    $class: 'GitSCM', 
    branches: scm.branches, 
    doGenerateSubmoduleConfigurations: false, 
    extensions: , 
    submoduleCfg: [], 
    userRemoteConfigs: scm.userRemoteConfigs
  ])    
}


everything is fine, BUT the latest commits in the jenkins-ci-examples sub repo do not reach the checkout e

ps I will immediately say
that the Recursively update submodules option is on

How to solve this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolay Baranenko, 2021-06-23
@drno-reg

the issue was resolved in this way

sh "git submodule foreach --recursive git pull origin master";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question