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

refactor [JenkinsBuild] #3302

Merged
merged 10 commits into from
Apr 19, 2019
Merged

refactor [JenkinsBuild] #3302

merged 10 commits into from
Apr 19, 2019

Conversation

calebcartwright
Copy link
Member

@calebcartwright calebcartwright commented Apr 14, 2019

Refs #2863

@calebcartwright calebcartwright added the service-badge New or updated service badge label Apr 14, 2019
@calebcartwright calebcartwright changed the title refactor [JenkinsBuild] [WIP] refactor [JenkinsBuild] Apr 14, 2019
@shields-ci
Copy link

shields-ci commented Apr 14, 2019

Warnings
⚠️

📚 Remember to ensure any changes to serverSecrets in services/jenkins/jenkins-base.js are reflected in the server secrets documentation

⚠️

📚 Remember to ensure any changes to serverSecrets in services/jenkins/jenkins-build.tester.js are reflected in the server secrets documentation

⚠️

📚 Remember to ensure any changes to serverSecrets in services/jenkins/jenkins-build.service.js are reflected in the server secrets documentation

Messages
📖 ✨ Thanks for your contribution to Shields, @calebcartwright!

Generated by 🚫 dangerJS against 75aafde

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-3302 April 14, 2019 19:12 Inactive
@calebcartwright calebcartwright changed the title [WIP] refactor [JenkinsBuild] refactor [JenkinsBuild] Apr 14, 2019
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-3302 April 14, 2019 19:18 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-3302 April 14, 2019 20:26 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-3302 April 14, 2019 20:29 Inactive
@paulmelnikow
Copy link
Member

Haven't given this a full review, though was playing around with #1956 (comment) and I noticed a disparity and thought I'd mention it.

This on master:

npm run badge https://img.shields.io/jenkins/s/https/jenkins-oss.wixpress.com/job/multi-detox-master.svg

is equivalent to

npm run badge https://img.shields.io/jenkins/s/https/jenkins-oss.wixpress.com/multi-detox-master.svg

on this branch.

@calebcartwright
Copy link
Member Author

calebcartwright commented Apr 14, 2019

Fair point on the paths. It looks to me as if the legacy service did its best to support users whether they simply mentioned a job name multi-detox-master or whether they specified a full path that ran through views, like view/Precise/view/All%20Precise/job/precise-desktop-amd64_default

There is an issue here with the route path though, in this PR it is currently:
pattern: ':protocol(http|https)/:host+/:job+'

I believe the consecutive + params are problematic. The problem I was trying to address is that some instances may be on their own url path, like: https://jenkins.ubuntu.com/server/ that need to support one or more additional /, but similarly the user provided values for job can have their own N number of / as well 🤔

One way I can fix this would be to revert the pattern back to:
pattern: ':protocol(http|https)/:host/:job+'

However, this does require the user to enter the host path info, and the job prefix, and the job name in the route

This would not work (since the host is on the /server path):
/jenkins/s/https/jenkins.ubuntu.com/admin-jobs-update.svg

and would require:
/jenkins/s/https/jenkins.ubuntu.com/server/job/admin-jobs-update.svg

@calebcartwright calebcartwright changed the title refactor [JenkinsBuild] [WIP] refactor [JenkinsBuild] Apr 17, 2019
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-3302 April 17, 2019 22:48 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-3302 April 17, 2019 23:24 Inactive
@calebcartwright calebcartwright changed the title [WIP] refactor [JenkinsBuild] refactor [JenkinsBuild] Apr 17, 2019
@calebcartwright
Copy link
Member Author

I've updated the route to mirror the existing/current route

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-3302 April 18, 2019 21:51 Inactive
@shields-ci
Copy link

shields-ci commented Apr 18, 2019

Warnings
⚠️

📚 Remember to ensure any changes to serverSecrets in services/jenkins/jenkins-base.js are reflected in the server secrets documentation

⚠️

📚 Remember to ensure any changes to serverSecrets in services/jenkins/jenkins-build.tester.js are reflected in the server secrets documentation

⚠️

📚 Remember to ensure any changes to serverSecrets in services/jenkins/jenkins-build.service.js are reflected in the server secrets documentation

Messages
📖 ✨ Thanks for your contribution to Shields, @calebcartwright!

Generated by 🚫 dangerJS against 8cc811f

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-3302 April 18, 2019 22:37 Inactive
errorMessages = { 404: 'instance or job not found' },
disableStrictSSL,
}) {
const options = { qs, strictSSL: disableStrictSSL === undefined }
Copy link
Member Author

Choose a reason for hiding this comment

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

See below comment in jenkins-common.js for more info on param name

label: 'build',
}
}

static get route() {
return {
base: 'jenkins/s',
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't have any PR #'s handy, but we seem to be trending away from single letter aliases to more explicit route param names.

I'd like to do the same thing here (build or status instead of s). Any thoughts/objections?

Copy link
Member

Choose a reason for hiding this comment

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

Happy if you want to change it, but we'll want to maintain an alias/redirect for /s for existing users

We talked about formalising some of this stuff in docs in #3144 (comment) and then.. haven't got round to doing it yet. There's several things in that discussion that I want to get done at some point but haven't found the time. Having this stuff documented would make it easier when we're thinking

wait, what is our convention for a "build status" URL?

🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll leave it in place for now. I plan on using some of the common bits in here to refactor the Jenkins test service so I'll consider the alias redirecting in that one

const Joi = require('joi')

const queryParamSchema = Joi.object({
disableStrictSSL: Joi.equal(''),
Copy link
Member Author

@calebcartwright calebcartwright Apr 18, 2019

Choose a reason for hiding this comment

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

Although I usually try to refrain from using negated variable names, naming this with the disable prefix seemed to be the best approach given the default behavior we want here and the way boolean query params are handled (empty string when set, undefined when not set).

With this approach, a user will have to explicitly include the disableStrictSSL query param:
https://shields-staging-pr-3302.herokuapp.com/jenkins/s/https/jenkins-oss.wixpress.com/job/detox-android-56-master.svg?disableStrictSSL

As the default behavior (no query param provided) will still enforce strict ssl, which is why the below badge will fail (there's a cert chain issue with the target jenkins instance)
https://shields-staging-pr-3302.herokuapp.com/jenkins/s/https/jenkins-oss.wixpress.com/job/detox-android-56-master.svg

Definitely open to feedback/suggestions/etc. if anyone has any alternative ideas!

return `${protocol}://${host}/${jobPrefix}${job}/${
lastBuild ? 'lastBuild/' : ''
}${plugin ? `${plugin}/` : ''}api/json`
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm setting this function up to be re-used in all the other Jenkins services (Tests, etc.) which is why it contains things not explicitly used for the Build service badge

namedParams: {
scheme: 'https',
protocol: 'https',
host: 'jenkins.qa.ubuntu.com',
Copy link
Member Author

Choose a reason for hiding this comment

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

I am also intentionally not including the new disableStrictSSL query param here as I do not believe this is something we want to advertise; it's a work around for a handful of exceptional circumstances only.

Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

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

I think this is good to go, but we can re-review /approveif you want to add the alias before we merge

@shields-deployment
Copy link

This pull request was merged to master branch. This change is now waiting for deployment, which will usually happen within a few days. Stay tuned by joining our #ops channel on Discord!

After deployment, changes are copied to gh-pages branch:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge New or updated service badge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants