Closed ungerts closed 5 years ago
Plan sounds good đź‘Ť
Implemented first version which allows me to run following Jenkinsfile for testing:
def final projectId = 'project13'
def final componentId = 'component123'
def final credentialsId = "${projectId}-cd-cd-user-with-password"
def sharedLibraryRepository
def dockerRegistry
def multiRepoBuild
node {
sharedLibraryRepository = env.SHARED_LIBRARY_REPOSITORY
dockerRegistry = env.DOCKER_REGISTRY
multiRepoBuild = !!env.MULTI_REPO_BUILD
}
library identifier: 'ods-library@production', retriever: modernSCM(
[$class: 'GitSCMSource',
remote: sharedLibraryRepository,
credentialsId: credentialsId])
def configMap = [
image: "${dockerRegistry}/cd/jenkins-slave-golang",
projectId: projectId,
componentId: componentId,
branchToEnvironmentMapping: [
'master': 'test',
'*': 'dev'
]
]
if (multiRepoBuild) {
configMap.displayNameUpdateEnabled = false
configMap.localCheckoutEnabled = false
configMap.bitbucketNotificationEnabled = false
configMap.ciSkipEnabled = false
configMap.cloneSourceEnv = false
}
odsPipeline(configMap) { context ->
//...
}
Assumption ist that a MRO sets an environment variable called _MULTI_REPOBUILD
Hmm - what do you think about hiding all of this inside the shared lib? You can read the environment variables inside (we only read SHARED_LIBRARY_REPOSITORY
and DOCKER_REGISTRY
because we need them before we have the shared lib), and then you can disable inside the lib. That way, we do not need to touch all the Jenkinsfile
s out there and we do not need to have all this extra code in each file, making it hard to update.
Yes, I think in that direction, too. My only counter argument is that in this case we access a "magic variable" (MULTI_REPO_BUILD) that does not exist in ODS at the moment.
Am Mi., 17. Juli 2019 um 17:19 Uhr schrieb Michael Sauter < notifications@github.com>:
Hmm - what do you think about hiding all of this inside the shared lib? You can read the environment variables inside (we only read SHARED_LIBRARY_REPOSITORY and DOCKER_REGISTRY because we need them before we have the shared lib), and then you can disable inside the lib. That way, we do not need to touch all the Jenkinsfiles out there and we do not need to have all this extra code in each file, making it hard to update.
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/opendevstack/ods-jenkins-shared-library/issues/97?email_source=notifications&email_token=AALWPCXENP6OCRJWP2IDON3P742AHA5CNFSM4IEAG3J2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2EWQ2Q#issuecomment-512321642, or mute the thread https://github.com/notifications/unsubscribe-auth/AALWPCQSNZ6D6IHFQCRJVKTP742AHANCNFSM4IEAG3JQ .
I'm okay with that. Maybe allow to also "enable MRO mode" by setting an option.
@michaelsauter Found a solution that both is possible
@michaelsauter @metmajer @tjaeschke how do we handle branch to environment mapping in MRO builds?
Options:
+1 for option 2
I'd also let the orchestrating pipeline control where things should be deployed.
Implemented option 2
Implemented approach:
MULTI_REPO_BUILD
must be set to true
.MULTI_REPO_ENV
must be set to the environment the pipline should deploy to (e.g. test
).git
. The step checkout scm
would checkout the repo of the enclosing pipeline.MULTI_REPO_ENV
.If I understand correctly, this has been merged by now by another PR. Closing this - @ungerts reopen if you think this is not completed yet.
Multi repository orchestration (MRO) requires to checkout an ODS component/repository within a top level pipeline and to load/execute its Jenkinsfile dynamically. Example:
In order to allow orchestration the ODS pipeline should be more configurable:
PoC (working in progress) can be found here: https://github.com/ungerts/ods-jenkins-shared-library/tree/experimental/mro