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

Adding sample Jenkins Pipeline #16880

Merged
merged 1 commit into from
Oct 27, 2017
Merged

Adding sample Jenkins Pipeline #16880

merged 1 commit into from
Oct 27, 2017

Conversation

coreydaley
Copy link
Member

@coreydaley coreydaley commented Oct 15, 2017

Adding a sample Jenkins Pipeline in support of documentation updates.

Supports: openshift/openshift-docs#5720

Trello: https://trello.com/c/rBojNLGj/1121-5-better-devguide-pipeline-docs-techdebt

@coreydaley
Copy link
Member Author

@bparees @gabemontero ptal

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 15, 2017
Copy link
Contributor

@bparees bparees left a comment

Choose a reason for hiding this comment

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

this not a "detailed walkthrough/example of building/deploying/promoting an application via a pipeline." (from the trello card).

it's also using the legacy plugin logic ("openshiftBuild", "openshiftVerifyBuild", etc) when it should be using only the openshift client plugin.

jenkinsfile: |-
try {
timeout(time: 20, unit: 'MINUTES') {
// run this pipeline on a node.js slave pod
Copy link
Contributor

Choose a reason for hiding this comment

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

align this w/ the next line.

// setup to check if the objects from the template have already been created
def templateGeneratedSelector = openshift.selector('all,secret', [ template: 'nodejs-mongodb-example' ])
def objectsGeneratedFromTemplate = templateGeneratedSelector.exists()
def objectModels = openshift.process( template )
Copy link
Contributor

Choose a reason for hiding this comment

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

no reason to process the template if the objects already exist.

@bparees
Copy link
Contributor

bparees commented Oct 16, 2017

this not a "detailed walkthrough/example of building/deploying/promoting an application via a pipeline." (from the trello card).

some additional information on why i say this... all this pipeline is doing is deploying a template if the template was not previously deployed. That's not a useful workflow for someone trying to iterate on developing an application because it's not going to update things if their template has changed.

it's also not demonstrating promotion.

what would make more sense:

  1. delete everything w/ the template label (so we get a fresh start)
  2. deploy the template
  3. verify it built/deployed/is accessible (should build w/ a tag like :dev)
  4. tag the newly built image as :stage
  5. comments indicating that the stage environment should trigger off/pick up the newly available image. (no need to implement/demonstrate the actual stage deployment, sufficient to show the image is available for the stage env)

and it should be done using the openshift client plugin semantics, not the openshift pipeline plugin ones.

@coreydaley
Copy link
Member Author

@bparees @gabemontero ptal

Copy link
Contributor

@bparees bparees left a comment

Choose a reason for hiding this comment

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

by reusing an existing template you've created a somewhat unnatural pipeline definition. i think it would be better to have your own template, or to invoke oc new-app to construct all the resources dynamically.

}
stage('create') {
// create a new template from the templatePath
def template = openshift.create(templatePath).object()
Copy link
Contributor

Choose a reason for hiding this comment

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

you shouldn't need to create the template to process it.

for (o in objectModels) {
// update the output image to be tagged with 'dev'
if (o.kind == "BuildConfig") {
o.spec.output.to.name = "${templateName}:dev"
Copy link
Contributor

Choose a reason for hiding this comment

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

why doesn't the template just define it this way?

for (t in o.spec.triggers) {
// set the deployment config to deploy the image tagged with 'dev'
if (t.type == "ImageChange") {
t.imageChangeParams.from.name = "${templateName}:dev"
Copy link
Contributor

Choose a reason for hiding this comment

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

why doesn't the template just define it this way?

Copy link
Contributor

@gabemontero gabemontero left a comment

Choose a reason for hiding this comment

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

I've got nothing new to add other than two of the points I raised in the associated doc PR ... I'll reiterate here for convenience:

  1. long term we should monitor if adding a Jenkinsfile along these lines in our -ex repos makes sense
  2. if not now, at some point soon we'll need a declarative pipeline syntax example

@coreydaley
Copy link
Member Author

Updated example to use declarative pipeline syntax

@openshift-ci-robot openshift-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 23, 2017
@coreydaley
Copy link
Member Author

/retest

1 similar comment
@coreydaley
Copy link
Member Author

/retest

@gabemontero
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 24, 2017
@coreydaley
Copy link
Member Author

@bparees ptal, all tests are passing

kind: "BuildConfig"
apiVersion: "v1"
metadata:
name: "sample-nodejs-pipeline"
Copy link
Contributor

Choose a reason for hiding this comment

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

align this name and the filename.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated, thought i had already fixed that, must have been in the docs

// if everything else succeeded, tag the ${templateName}:latest image as ${templateName}:stage
// a pipeline build config for the staging environment can watch for the ${templateName}:stage
// image to change and then deploy it to the staging environment
openshift.tag("${templateName}:latest", "${templateName}:stage")
Copy link
Contributor

Choose a reason for hiding this comment

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

you need to tag this into a different imagestream because your cleanup logic deletes the ${templateName} imagestream every time. And having a pipeline that deletes the "last good" tag as its first step is not logical.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

Copy link
Member Author

Choose a reason for hiding this comment

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

(also updated the example in the docs)

@openshift-merge-robot openshift-merge-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 25, 2017
@bparees
Copy link
Contributor

bparees commented Oct 25, 2017

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 25, 2017
@openshift-merge-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bparees, coreydaley, gabemontero

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 25, 2017
@bparees bparees added the kind/bug Categorizes issue or PR as related to a bug. label Oct 25, 2017
Adding sample Jenkins Pipeline using declarative syntax

Adding a sample Jenkins Pipeline in support of documentation updates.

Trello: https://trello.com/c/rBojNLGj/1121-5-better-devguide-pipeline-docs-techdebt
@openshift-merge-robot openshift-merge-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 25, 2017
@bparees bparees added the lgtm Indicates that a PR is ready to be merged. label Oct 26, 2017
@coreydaley
Copy link
Member Author

/retest

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@coreydaley
Copy link
Member Author

/retest

1 similar comment
@coreydaley
Copy link
Member Author

/retest

@0xmichalis
Copy link
Contributor

/cherrypick stage

@openshift-ci-robot
Copy link

@Kargakis: @Kargakis once the present PR merges, I will cherry-pick it on top of stage in a new PR and assign it to you.

In response to this:

/cherrypick stage

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue.

@openshift-merge-robot openshift-merge-robot merged commit 0f1a868 into openshift:master Oct 27, 2017
@coreydaley
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants