5 ms·
Untangling Jenkins
- oblio 9y agoI've been a build/release engineer for quite a few years now, most spent using Jenkins. It can be quite a heavyweight beast, especially since it's written in Java (so heavy in terms of resource usage) and since it's old (so lots of legacy in terms of architecture). Still, in terms of costs and scalability (up to the level where you have thousands of developers and you probably want to roll your own), I think it is one of the best tools out there for its role as a prettier cron/queuing system. A few tips: * if you can afford it, stop ASAP using the UI for configurating jobs; look into Pipelines or the JobDSL, based on your needs * once you have more than a few jobs, stop running anything on the master node, for increased stability * use the minimum number of plugins and tie as few things to Jenkins as possible; script as many things and put the scripts into version control * backup the global configuration; you can try to version control it but it's tricky; at least back it up periodically and most of the time it is enough That's it for now, for more details, $200/h :p
- grogenaut 9y agoGoing off of this I wouldn't even use job dsl or pipelines as they allow you to execute arbitrary groovy. I would consider emulating Travis ci or Amazon pipelines where it is all declarative not imperitive. This way you can re-impliment and consolidate without doing a Turing complete parse of tons of custom groovy scripts
- oblio 9y agoThere's a Declarative Pipeline these days plus you can turn on the Groovy sandbox. There's also a YAML based thing but I forgot its name.
- grogenaut 9y agoCan you provide links? I'm on a plane so very hard to Google. Seriously? Downvotes? On a holiday on a plane and I get down votes asking for a little help? I did try and google and didn't find the stuff.
- jeremya 9y agoI agree it's not easy to Google for the Declarative Pipeline or Groovy Sandbox. Here's the comparison of the two syntaxes available in Jenkins Pipeline (Scripted and Declarative): https://jenkins.io/doc/book/pipeline/syntax/#compare https://jenkins.io/doc/book/pipeline/syntax/#compare Here are details on the Groovy Sandbox (provided by the Script Security Plugin and installed by default when installing recent Jenkins). The Groovy Sandbox is on by default for Jenkins Pipeline: https://jenkins.io/doc/book/managing/script-approval/ https://jenkins.io/doc/book/managing/script-approval/
- grogenaut 9y agothanks
- RyJones 9y agoWe use JJB, which is YAML based. https://github.com/hyperledger/ci-management/tree/master/jjb https://github.com/hyperledger/ci-management/tree/master/jjb for instance
- grogenaut 9y agothanks
- harlowja 9y agoJust fyi :) Docs: https://docs.openstack.org/infra/jenkins-job-builder/ https://docs.openstack.org/infra/jenkins-job-builder/ Reviews: https://review.openstack.org/#/q/project:openstack-infra/jenkins-job-builder https://review.openstack.org/#/q/project:openstack-infra/jen... Code: https://git.openstack.org/cgit/openstack-infra/jenkins-job-builder https://git.openstack.org/cgit/openstack-infra/jenkins-job-b...
- jnsaff2 9y agoYea but the declarative pipelines have cheat codes that allow cheeky (read lazy) people to still run code in the pipeline:(
- Matt3o12_ 9y agoI‘m not sure what’s bad about executing arbitrary groovy scripts because you are running arbitrary code anyways (unless Jenkins is not running any code at all – e.g. compile static assets, do something else). If some developer wanted access to the secret files – config files which might have sensitive information such as the database password for the staging environment (I don’t know what they are called in Jenkins) they could just modify the code to dump them to stdout. I am asking this because I don’t see a problem with running turning compete scripts if the application is most likely to run arbitary code anyways, which has access to syscalls any many other dangerous stuff anyways. You need to trust your employees anyways and if you can’t trust them with not dumping the staging environment in purpose, you should not have hired them. It is possible to include harmless looking code which can be malicious and still be considered a bug if found during code review’s.
- grogenaut 9y agoThe point is that you get mu hich better reuse by not allowing arbitrary groovy and building up interface contracts. This is exactly like any other coding. Using groovy is akin to allowing arbitrary SQL from your web devs intead of apis (from an interface pov not security). Instead just invoke something outside of Jenkins groovy framework like maven, make, etc. Makes you much more portable and upgradable. Jenkins should just be your execution/workflow environment not a dev framework. Also never mutate the worker boxes, everything should be completely isloated from itself and each other. Jenkins is like any other software architecture. Finally doing too much in Jenkins makes it impossible to test Jenkins locally, which means you can neither debug builds locally without pushing new code to build, nor can you test alterations to Jenkins itself locally which makes it much much more fragile. How do I know? I'm a sr dev coming in and fixing a mid sized engineering org (400+ devs) jenkins 4 years of accretions. These are major issues we've identified in just a week of looking. Build systems should be simple, scalaboe, agile, and composable, not monolithic. Keep the monolithic to the individual builds not cross company.
- Matt3o12_ 9y agoGot it, my groovy files have always been setup the environment (I.e. write config files for the test database, API keys, etc everything that should not be in git), and then just execute make to make so that I don’t have a completely different setup each environment. Thank you very much!
- vorg 9y ago> Travis ci or Amazon pipelines where it is all declarative not imperitive [...] a Turing complete parse of tons of custom groovy scripts Even worse than Apache Groovy being an imperative DSL (compared to Travis ci and Amazon pipelines being all declarative) is that the most declarative portions of Groovy (i.e. its collections API) are disabled when used in the Jenkins pipelines.
- mikewhy 9y agoAnother downside to Jenkins: $200/hr to learn other products do it just as well with much less overhead.
- emmelaich 9y agoI think $200/h is a low-end average estimate for any type of enterprisey software, open source or not. If you don't buy expertise in the short term, it may cost you a lot more in the long run.
- mooreds 9y ago$200/hr sounds expensive until you realize you are gaining access to all the mistakes they've made on someone else's dime.
- closeparen 9y agoConsultants are long gone by the time their mistakes are apparent.
- oblio 9y agoThat was actually a joke since I've never done any Jenkins consulting but Jenkins, including the setup cost is waaaay cheaper than other solutions I've seen for what I used it for: distributed cron, queuing system for tasks, higher level dashboard for managers, CI server, etc.
- piva00 9y agoI could tell it was a joke when you mentioned keeping backups of your main configuration instead of porting ALL of your Jenkins config to code and maintaining that in version control. At my current job I started as a SRE for the team supporting Jenkins and other CI/CD tools for the rest of engineering (around 50+ other teams), I moved back to a SWE position but as an insight: don't run a single master Jenkins for all of your teams, make it federated (per-team/project or whatever suits your organisational structure) AND do all of Jenkins' configuration through scripts. Never rely on backing up the old configuration (problematic in cases of rollback to previous Jenkins versions, brittle for recovery), just start it fresh every time you need to recover and re-run your provisioning scripts, that also includes NEVER maintaining jobs through the UI, only through JobDSL, JJB or Pipeline scripts.
- BlanketApple 9y agoMan, I'm having this problem right now at work and it's been a nightmare. Admittedly the problem is like 90% cultural. People (on my team) don't understand pipeline and they absolutely don't understand Groovy. Before, they would just write a job with a shell script that e.g. ran valgrind, etc. Lots of small repos with similar steps, so they'd write one job and apply it to 20 different repos. It worked pretty well. That's still an option with pipelines, but it feels much more discouraged (to e.g. write a shared pipeline job that runs a multi-line shell script). It's also just a bit of an organizational nightmare to see 200+ jobs on the main screen (as opposed to 20 jobs that did the same thing for 200 repos). Unfortunately, it also seems like declarative pipeline is limited enough that we end up writing a lot of Groovy. I sorta get why Groovy became the official scripting language, but it's like pulling teeth getting people to learn even basic Groovy. I realize, again, that a lot of this is a cultural problem. Mostly just trying to give a counterpoint that pipelines don't always look as clean as the article implies, especially for orgs with a lot of repos (where committing the same 'test.sh' file to each repo doesn't make a lot of sense).
- grogenaut 9y agoWhy not make it easy to reuse functions to do the steps the groovy is doing and build all of the common steps in a reusable way? Eg what the article is suggesting
- BlanketApple 9y agoYeah, we've done that. And again, this is totally a cultural problem. But inevitably I end up writing that shared groovy code (because I have the most familiarity), and so when things go wrong, or it needs to be changed, I end up being the one having to debug it. Definitely a huge bus factor. It'd be nice if it was a slightly more common language (e.g. Python) so it wasn't such a pain.
- grogenaut 9y agoAah. Cultural problems are different. What's the main issue there? Making a Python language plugin wouldn't be hard though.
- correlation 9y agoI have come up with a slogan for Jenkins: "Jenkins - The butler that does not hesitate to do a disservice". It is currently the most brittle piece of infrastructure we run, with jobs spiralling out of control and slaves crashing with cryptic exceptions. Add to that a horrible plugin ecosystem (tried to install the Slack plugin, it crashed all builds and our webhook endpoint). Add to that groovy (I don't feel like becoming an archeologist). Gosh, can't someone just build a lightweight ci/cd system ontop of e.g. k8s jobs? Or should we just give up and do managed ci/cd?
- mianos 9y agoI replaced it with saltstack. I had so many things not working I thought it was me just being dumb or not spending enough time learning to use it. A few salt states on the end of a git hook did everything, auto deployment, testing, staging, monitoring. I am probably missing something about the awsome power of jenkins but know firms still running my saltstack CI/CD systems years after I left. Weird.
- CodeAlong 9y agoMy workplace has primarily switched all net new ci/cd workflow from Jenkins to Drone (https://github.com/drone/drone https://github.com/drone/drone - Drone is a Continuous Delivery system built on container technology.). Having managed masters with 20,000 + configured jobs I agree that Jenkins is a very sore spot for our entire pipeline. We’ve had greater success with increasing the number of masters (one per team or application) and using the kubernetes plugin for slaves. However, most of our pipeline complaints have been mitigated by getting teams to migrate from Jenkins to Drone. While I don’t think Drone currently supports k8s job, it is very lightweight in comparison to Jenkins. Most of our developers would agree that it isn’t a perfect product, but it has reduced friction points by a large amount.
- SOLAR_FIELDS 9y agoInteresting war story. We have a couple of master instances that go down all the time because of several thousand jobs running. Gonna ask our devops what they are cooking up to resolve and compare to this solution.
- Sir_Cmpwn 9y agoIf I may suggest my own alternative to Jenkins: builds.sr.ht. It runs build manifests submitted through an API and does not support job configuration itself; you must use an external integration to automate your builds. Build manifests look something like this: https://git.sr.ht/~sircmpwn/wlroots/tree/.build.yml https://git.sr.ht/~sircmpwn/wlroots/tree/.build.yml More complex example: https://git.sr.ht/~sircmpwn/builds.sr.ht/tree/.build.yml https://git.sr.ht/~sircmpwn/builds.sr.ht/tree/.build.yml Builds run with full virtualization (KVM) on any number of distributed (optional trust) build runners. The whole thing is open source: https://git.sr.ht/~sircmpwn/builds.sr.ht https://git.sr.ht/~sircmpwn/builds.sr.ht It's also self-hosting, it builds and deploys itself and the rest of the *.sr.ht network: https://builds.sr.ht/job/602 https://builds.sr.ht/job/602 If anyone wants to give it a try, please get in touch (email in my profile) and I'll hook you up with an account on my hosted instance. I could use more people to kick the wheels and help me find the pain points.
- jonthepirate 9y agoI am spearheading an effort to release a CloudFormation template that will launch Jenkins clusters into your AWS account. It represents everything learned while working with Jenkins for over 6 years including 2.5 years of Jenkins at Lyft and 1 year at DoorDash. If you would like to collaborate, please contact block.jon@gmail.com. The project was written with an eye towards making the launching of a Jenkins cluster very very easy. It's designed with Docker workloads in mind. Some of the gems include autoscaling, instrumentation & metrics, automatic Let's Encrypt certificate registration, GitHub webhook integration and retries during pipeline slave disconnects which makes spot instances viable even when they abruptly go away... something that saves you 75%!! on your AWS instance costs.
- mooreds 9y agoI don't have cycles to help, but please post this on HN when you are ready!
- jonthepirate 9y agoHere's a preview of what I'm working on that I just published to YouTube: https://www.youtube.com/watch?v=GkflqV6KenM https://www.youtube.com/watch?v=GkflqV6KenM I'd love to hear more about what problems any of you are facing with Jenkins so I can be sure to address them in the work I'm doing. Jon
- emmelaich 9y agoHas anyone here used BlueOcean and have anything to say about it good or bad? https://jenkins.io/projects/blueocean/ https://jenkins.io/projects/blueocean/
- tokenizerrr 9y agoMeh. The interface for viewing logs lags my browser.
- emmelaich 9y agoIt is beta-ish still, so that may go away. I was more looking for comments about the features, pipeline etc. Also, regarding logs the site says this: "Diagnose problems instantly and say good-riddance to endlessly scanning through logs." Won't believe till I try it but it's a good goal!
- draw_down 9y agoIt is pretty horrible to interact with as a “customer”, that is, a developer whose builds run on it but who does not administer it.
- chrisanthropic 9y agoThe best Jenkins advice I ever received was from here: https://medium.com/mindera/jenkins-a-la-travis-6c5a8debbb5b https://medium.com/mindera/jenkins-a-la-travis-6c5a8debbb5b On setting up Jenkins Job Builder using a 'seed job'. This setup allows you to add a .jenkins directory to you project, define a yaml based jenkins job inside that directory, push to github, and Jenkins will create the job you defined - NO web UI required. In other words you make Jenkins behave like Travis. Set this up with your first job being a job to backup Jenkins to S3 and things aren't as bad to manage.
- finspin 9y agoI'm currently looking into how JJB could be used for simple scheduled jobs. But isn't the setup described in the article basically the same what you can do with Jenkinsfile?
- nunez 9y agoJenkins and any other CI/CD tool is a prime candidate for immutable infrastructure; it’s the one thing that nobody cares about too much until it no longer works, and it is relatively easy to get going with scripts or Docker