Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ODS pipeline configurable for MRO #97

Closed
ungerts opened this issue Jul 16, 2019 · 13 comments
Closed

Make ODS pipeline configurable for MRO #97

ungerts opened this issue Jul 16, 2019 · 13 comments
Assignees
Labels
enhancement New feature or request

Comments

@ungerts
Copy link
Member

ungerts commented Jul 16, 2019

Multi repository orchestration (MRO) requires to checkout an ODS component/repository
within a top level pipeline and to load/execute its Jenkinsfile dynamically. Example:

dir('componentId') {
   git url: '<REPO_URL>'     // checkout ODS component
   load path: 'Jenkinsfile'  // load and execute Jenkinsfile of ODS component
}

In order to allow orchestration the ODS pipeline should be more configurable:

  • Activation/deactivation of CI Skip. In this case Skip is the task of the top level pipeline
  • Activation/deactivation of Bitbucket notification. In case of an orchestrated build notifications
    are send by the top level pipeline.
  • Activation/deactivation of setting build display name. Jenkinsfile runs within a top level
    Jenkinsfile and should not overwrite the build's display name.
  • Activation/deactivation of repo checkout on Jenkins Master. Repo is already checked out.

PoC (working in progress) can be found here: https://github.com/ungerts/ods-jenkins-shared-library/tree/experimental/mro

@michaelsauter
Copy link
Member

Plan sounds good 👍

@clemensutschig clemensutschig added the enhancement New feature or request label Jul 16, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 17, 2019
@ungerts ungerts self-assigned this Jul 17, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 17, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 17, 2019
@ungerts
Copy link
Member Author

ungerts commented Jul 17, 2019

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 ->
  //...
}

@ungerts
Copy link
Member Author

ungerts commented Jul 17, 2019

Assumption ist that a MRO sets an environment variable called MULTI_REPO_BUILD

@michaelsauter
Copy link
Member

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.

@ungerts
Copy link
Member Author

ungerts commented Jul 17, 2019 via email

ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 17, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 17, 2019
@michaelsauter
Copy link
Member

I'm okay with that. Maybe allow to also "enable MRO mode" by setting an option.

ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 18, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 18, 2019
@ungerts
Copy link
Member Author

ungerts commented Jul 18, 2019

@michaelsauter Found a solution that both is possible

@ungerts
Copy link
Member Author

ungerts commented Jul 18, 2019

@michaelsauter @metmajer @tjaeschke how do we handle branch to environment mapping in MRO builds?

Options:

  • branch to environment mapping is handled by the ODS branchToEnvironmentMapping mechanism and configured in the Jenkinsfile. I'm not sure whether this is a limitation, if using release branches. In this case the same branch is used in different environments (TEST/PROD).
  • The orchestrating pipeline provides environment information using a variable which overwrites the mapping in the Jenkinsfile.

ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 18, 2019
@clemensutschig
Copy link
Member

+1 for option 2

@michaelsauter
Copy link
Member

I'd also let the orchestrating pipeline control where things should be deployed.

@ungerts
Copy link
Member Author

ungerts commented Jul 22, 2019

Implemented option 2

@ungerts
Copy link
Member Author

ungerts commented Jul 23, 2019

Implemented approach:

Assumptions, Limitations, Deviations

  • In case of an MRO build, the ODS Jenkinsfile must be called by the enclosing pipeline within a node.
    • Environment variable MULTI_REPO_BUILD must be set to true.
    • Environment variable MULTI_REPO_ENV must be set to the environment the pipline should deploy to (e.g. test).
  • In case of an MRO build, no new node master is created by the ODS pipeline. The node of the enclosing pipeline is used, because creating a new node might change the working directory. Then the existing checkout cannot be used. Furthermore, the branch is not determined using the Openshift build config.
  • On the agent checkout is done using the pipeline step git. The step checkout scm would checkout the repo of the enclosing pipeline.

MRO build configuration

  • Environment is overwritten by variable MULTI_REPO_ENV.
  • Clone environment is suppressed.
  • Bitbucket notifications are disabled.
  • Local checkout on Jenkins master is disabled.
  • Display name of running build is not updated.
  • CI skip is disabled

ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 23, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 23, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 23, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 23, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 24, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 24, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 24, 2019
@ungerts ungerts mentioned this issue Jul 24, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 25, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 25, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 25, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 25, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 26, 2019
ungerts added a commit to ungerts/ods-jenkins-shared-library that referenced this issue Jul 26, 2019
@michaelsauter
Copy link
Member

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.

michaelsauter pushed a commit to BIX-Digital/ods-jenkins-shared-library that referenced this issue Apr 27, 2020
Co-authored-by: Martin Etmajer <martin.etmajer@boehringer-ingelheim.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants