News for hackers. Stuff that matters.
Re:Untangling Jenkins by oblio on Monday December 25, 2017 @04:43PM (#16005838)
I'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

Re:Untangling Jenkins by grogenaut on Monday December 25, 2017 @04:49PM (#16005865)
Going 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
Re:Untangling Jenkins by Matt3o12_ on Monday December 25, 2017 @05:48PM (#16006049)
I‘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.

Re:Untangling Jenkins by grogenaut on Monday December 25, 2017 @05:58PM (#16006089)
The 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.

Re:Untangling Jenkins by Matt3o12_ on Tuesday December 26, 2017 @07:10AM (#16008261)
Got 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!
Re:Untangling Jenkins by voidr on Wednesday December 27, 2017 @03:00AM (#16013518)
> 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.

If you would have used Jenkins pipelines, you would know that you can debug it directly from the UI. I can make my builds hard to run locally on configuration-based systems as well, this is not really an argument against Pipelines.

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

You haven't used Jenkins Pipelines though, if you would have used it, you would know about the debugging part I mentioned above.

> Build systems should be simple, scalaboe, agile, and composable, not monolithic. Keep the monolithic to the individual builds not cross company.

These have nothing to do with the actual topic, these are just generalisations.

> The point is that you get mu hich better reuse by not allowing arbitrary groovy and building up interface contracts.

You can reuse the groovy code you write, which means you actually get more reuse.

> 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).

That is a bad analogy, a correct one would be something like: writing NodeJS build scripts in JavaScript instead of using Grunt or Gulp, or Groovy vs. Maven/Ant.

> Jenkins should just be your execution/workflow environment not a dev framework.

What is a "dev framework" in your mind?

> Also never mutate the worker boxes, everything should be completely isloated from itself and each other.

What does that have to do with using a programming language instead of a config DSL?

> Jenkins is like any other software architecture.

Fail to see how that vague statement supports your argument.

Re:Untangling Jenkins by grogenaut on Thursday January 04, 2018 @11:18AM (#16071487)
>If you would have used Jenkins pipelines Nice, way to start off with an ad hominem attack. Yes I'm lying to you about having used pipelines. That's what I do, I go on hacker news and lie about what I do, especially jenkins, to throw people off the scent. Seriously... if people dont know that pipelines are easily debuggable, that's a problem with the documentation, not with the person. It's also not a reason to attack people.

I have used jenkins pipelines. However I didnt use it from scratch so no, I couldn't do what you said due to all of the other issues. My point is that it does let you hang yourself, I prefer the config based systems as it's harder to hang yourself.

Your NodeJs anology is more apt but who cares you got the point. This is a discussion not a literature critique.

A dev framework to me is the type of stuff you've built up around a typical compile of a given "stack". For instance, doing ruby on rails, you're likely to have a bunch of build tooling you've built up to make that easier. I would prefer to distribute that stuff more generically and unrelated to jenkins vs some other build system, as opposed to building it all into jenkins.

As for mutating workers... you seem to be under the mistaken notion that I'm discussing the one thing you are discussing. But in general, if you have a turing complete language with complete system access like you do in the groovy, you can do anything and anything isn't always a great idea. I like the config based systems as it doesn't allow you to do anything, it allows you to do things we've deemed as good for building software. Jenkins boxes end up being shared resources in a large company so it's very difficult to audit what everyone is doing and side effects they are causing.

>Fail to see how that vague statement supports your argument.

Ok

>You can reuse the groovy code you write, which means you actually get more reuse.

You can but most people don't know how to or dont. It's a break from your typical dev loop and it's yet another framework to learn. I don't think it's effective unless you dive in and most people don't dive in. So to me it's a bad model. This is opinion.

Re:Untangling Jenkins by oblio on Monday December 25, 2017 @04:54PM (#16005885)
There'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.
Re:Untangling Jenkins by grogenaut on Monday December 25, 2017 @06:05PM (#16006124)
Can 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.

Re:Untangling Jenkins by jeremya on Monday December 25, 2017 @10:22PM (#16006877)
I 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

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/

Re:Untangling Jenkins by grogenaut on Tuesday December 26, 2017 @02:21AM (#16007589)
thanks
Re:Untangling Jenkins by RyJones on Monday December 25, 2017 @11:33PM (#16007087)
We use JJB, which is YAML based.

https://github.com/hyperledger/ci-management/tree/master/jjb

for instance

Re:Untangling Jenkins by grogenaut on Tuesday December 26, 2017 @02:21AM (#16007591)
thanks
Re:Untangling Jenkins by jnsaff2 on Tuesday December 26, 2017 @01:55AM (#16007537)
Yea but the declarative pipelines have cheat codes that allow cheeky (read lazy) people to still run code in the pipeline:(
Re:Untangling Jenkins by vorg on Tuesday December 26, 2017 @11:42PM (#16012876)
> 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.

Re:Untangling Jenkins by mikewhy on Monday December 25, 2017 @06:43PM (#16006227)
Another downside to Jenkins: $200/hr to learn other products do it just as well with much less overhead.
Re:Untangling Jenkins by emmelaich on Monday December 25, 2017 @08:17PM (#16006504)
I 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.

Re:Untangling Jenkins by mooreds on Monday December 25, 2017 @09:37PM (#16006732)
$200/hr sounds expensive until you realize you are gaining access to all the mistakes they've made on someone else's dime.
Re:Untangling Jenkins by closeparen on Monday December 25, 2017 @11:54PM (#16007145)
Consultants are long gone by the time their mistakes are apparent.
Re:Untangling Jenkins by oblio on Tuesday December 26, 2017 @01:33PM (#16010053)
That 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.
Re:Untangling Jenkins by piva00 on Wednesday December 27, 2017 @08:07AM (#16014530)
I 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.

Re:Untangling Jenkins by oblio on Wednesday December 27, 2017 @10:44AM (#16015364)
You need the team you're part of to have enough discipline for that. Not always the case. Sometimes you need to know when to cut your losses and go for the cheap, plastic, solution (i.e. backups).
Re:Untangling Jenkins by voidr on Wednesday December 27, 2017 @03:04AM (#16013534)
That's just the poster's consulting price, you can learn everything for free online.