summaryrefslogtreecommitdiff
path: root/Jenkinsfile
blob: 8c386c239077d04f309b78ec947b31cab05493ba (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
properties([disableConcurrentBuilds(),
            pipelineTriggers([cron(env.BRANCH_NAME == "master" ? "H 9 * * 1-5" : "")]),
            parameters([string(name: "PARALLEL", defaultValue: (env.BRANCH_NAME == "master" ? "5" : "3"),
                               description: "Number of triggered jobs in parallel simultaneously")])])

node("master") {
    stage("Invoking git clone") {
        checkout scm

        dir("/home/oleg/majordomo") {
            List<String> gitDirectories = (sh (script: 'ls --directory -1 */*', returnStdout: true)).split("\n")
            gitDirectories.collate(params.PARALLEL.toInteger())
                .each { directories ->
                parallel (directories.collectEntries { directory ->
                        [(directory): {warnError("Failed to update Git repository in $directory"){
                                    sh (["git -C $directory checkout master || true",
                                         "git -C $directory pull --rebase",
                                         "$WORKSPACE/clean.sh $directory"].join("; "))
                                }}]
                    })
            }
        }
    }
}