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

Add quickstarter pipeline #230

Merged

Conversation

michaelsauter
Copy link
Member

@michaelsauter michaelsauter commented Apr 3, 2020

Implements a new pipeline that can be used to provision quickstarters.

It uses the same style as the new "component pipeline", with some simplifications. For now, this pipeline has only been used for the Go quickstarter (opendevstack/ods-quickstarters#222). I'll convert the other ones after this PR is merged .. in the process, I might need to do some minor adjustments to the pipeline.

To visualise what a new Jenkinsfile looks like, here's the one from Go (updated):

def odsGitRef = env.ODS_GIT_REF ?: 'production'
def odsImageTag = env.ODS_IMAGE_TAG ?: 'latest'
library("ods-jenkins-shared-library@${odsGitRef}")

odsQuickstarterPipeline(
  imageStreamTag: "cd/jenkins-slave-golang:${odsImageTag}",
) { context ->

  odsQuickstarterStageCopyFiles(context)

  stage('Write go.mod') {
    dir(context.targetDir) {
      sh "echo 'module example.com/${context.projectId}/${context.componentId}' > go.mod"
      sh "echo '' >> go.mod"
      sh "echo 'go 1.12' >> go.mod"
    }
  }

  odsQuickstarterStageCreateOpenShiftResources(
    context,
    [directory: 'common/ocp-config/component-environment']
  )

  odsQuickstarterStageRenderJenkinsfile(context)

  odsQuickstarterStageRenderSonarProperties(context)
}

Some observations:

  • I noticed that the way I implemented it, we basically don't need the IContext as Context is just data access. Thoughts on this?
  • There's some boilerplate around the image (dockerRegistry/odsImageTag). I guess we can get rid of it, but might be a bit of magic
  • The quickstarterId is required right now - that could also be read from the pipeline itself - it has jenkinsfilePath: "be-golang-plain/Jenkinsfile" set. I might default to that, and allow people to override?
  • Setting up OpenShift resources will likely be similar across most quickstarters. Maybe we can simplify that too - but unsure what the right level of abstraction is. Right now I'm leaving that for later ...

clemensutschig
clemensutschig previously approved these changes Apr 3, 2020
Copy link
Member

@clemensutschig clemensutschig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it - I am wondering if we should not rename the context thing .. we have then 2* IContext, just in 3 different pacakges.

@michaelsauter
Copy link
Member Author

michaelsauter commented Apr 6, 2020

@oalyman @renedupont I've done a few more changes to make it even easier to author quickstarters. Could you provide feedback too? Thx!

@michaelsauter michaelsauter moved this from To Do to In Progress in OpenDevStack 3.0 Apr 7, 2020
@michaelsauter
Copy link
Member Author

@clemensutschig @henrjk @oalyman Good to merge this? I'd love to proceed with converting the quickstarters. If you are OK with the "interface" - so the way that quickstarter Jenkinsfiles are written using this PR, then I suggest to merge this, and we can open up cleanup / enhancement issues.

Copy link
Member

@henrjk henrjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very neat.

I am torn on whether I'd rather see unique type names unique so that quickstarter names cannot be confused with component names.
On the other hand the qs classes could presumably also be in their own shared library.

Sorry for the ramblings.


import com.cloudbees.groovy.cps.NonCPS

class Context implements IContext {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is keeping you from removing IContext and adding potential docs right here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@henrjk With IContext I can use the type in the code while exchanging the implementation in the tests.

@michaelsauter
Copy link
Member Author

michaelsauter commented Apr 8, 2020

@henrjk Thanks!

Actually I really want to have this as a single library, but I have failed to outline the reasoning:

  • one repo is easier to manage then multiple (in terms of releases, branches, issues ...)
  • there are many things that can be shared between the libraries, such as interaction with OpenShift (services)
  • having one repo enforces more similarity (in terms of testing approach, dependencies used etc.) which makes it easier for people to work across libraries

@michaelsauter michaelsauter merged commit d71e7d0 into opendevstack:master Apr 8, 2020
OpenDevStack 3.0 automation moved this from In Progress to Done Apr 8, 2020
@michaelsauter michaelsauter deleted the feature/quickstarter-pipeline branch April 8, 2020 14:05
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
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants