Skip to content

[DSL][Example] configuration example for DSL #196

@PauloFerreira25

Description

@PauloFerreira25

Describe your use-case which is not covered by existing documentation.

Look, it was really hard to do the first one.
Well, since it's not in the documentation, I'm sending it to have something.
Thanks for listening

def jobFullName = '_FULL_JOB_NAME'
// IMPORTANT: use a constant and unique identifier
def jobUUID = 'b7e3db59-4b28-4c03-b967-8b024818753e' // USING: https://www.uuidgenerator.net/
def jobGitRemoteUrl = 'git@github.com:_ORG_/_REPO_SOURCE_BUILD_.git'
def jobGitCredentialsId = '_JENKINS_CRED_ID_'
def jenkinsScriptPath = 'jenkins.yml'
def configDrivenRemoteUrl = 'git@github.com:_ORG_/_REPO_CONFIG_DRIVEN.git'
def configDrivenCredentialsId = '_JENKINS_CRED_ID_'

multibranchPipelineJob(jobFullName) {
    branchSources {
        git {
            id(jobUUID)
            remote(jobGitRemoteUrl)
            credentialsId(jobGitCredentialsId)
        }
    }
    factory {
        configDrivenWorkflowBranchProjectFactory {
            scriptPath(jenkinsScriptPath)
            jenkinsFileScm {
                gitSCM {
                    userRemoteConfigs {
                        userRemoteConfig {
                            url(configDrivenRemoteUrl)
                            credentialsId(configDrivenCredentialsId)
                            name('')
                            refspec('')
                        }
                    }
                    browser { }
                    gitTool('git')
                    branches { branchSpec { name('*/main') } }
                    doGenerateSubmoduleConfigurations(false)
                }
            }
        }
    }
    orphanedItemStrategy { discardOldItems { numToKeep(10) } }
}

Reference any relevant documentation, other materials or issues/pull requests that can be used for inspiration.

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions