Fastlane + Jenkins Pipelines (Gaige gets his Java on)


Jenkins

For years, I've been using Jenkins as a CI environment at ClueTrust. For those unfamiliar with Jenkins, it's a long-running open-source project built in Java for doing Continuous Integration. It'll work on just about any platform that can run Java (although it's most at home on Unix machines) and it can be used with nearly any development toolset. It's been a helpful tool, but not without it's difficulties.

Most of my personal development for the past few years has been for macOS and iOS and thus requires Xcode, which means that my Jenkins slaves need to run on macOS machines. In my case, I run both the slaves and the master on Mac Minis (including a brand-spanking new one that really screams). Over the years, running CI on a Mac has been difficult, and required quite a bit of manual tweaking of the environment to keep up with changes in Apple's toolchain.

Enter Fastlane

Over the past few years, development has progressed on an iOS-mostly (macOS-kinda) development tool called Fastlane. The original developer, Felix Krause has been working on Fastlane for years and has moved from independent to Twitter and now Google.

In a nutshell, it shepherds most of the build/test/deploy cycle for iOS and macOS software, providing pretty output and a fast cycle.

When I went through our last feature release for CartoMobile in the fall of 2018, I ran into some annpoying changes in the build process that caused some difficulties with building and testing in my desktop and laptop environments, and especially automating the screenshot process.

I looked to Fastlane as a solution to this problem, and was quite pleased with the results. In fact, they were so good, I moved my other active projects, including Cartographica, to Fastlane for build/test/deploy. Despite comments about Fastlane being mostly for mobile development, I found it quite easy to work with for macOS development as well.

Of course, if it's worth doing in the manual build process, then it's worth automating, so I set out to follow the Fastlane instructions to get it working with Jenkins. It's clear that somebody had the same idea, as there's explicit support for running Fastlane under Jenkins. Although it required using the KPP Management Plugin, which I hadn't previously used, it worked quite well.

Moving to Pipelines

Fast forward to this winter, and I've been doing some more complex build and test cycles, and reading up on the more recent techniques for using Jenkins and decided it was time to try Pipelines. The value proposition was that you could create a more intelligent pipeline of actions. Whereas Jenkins has long had the ability to chain builds together, or to use build steps, the proliferation of individual "projects" necessary to handle a complex build and test cycle could get pretty unweildy. For example, Cartographica had a 4-project setup if you don't count the individual libraries that are built separately.

Applying pipelines to Cartographica wasn't a difficult process, thanks to the Convert to Pipeline Plugin provided by Infostretch. The automated conversion worked well, except that it didn't know how to convert the KPP Management Plugin. After a cursory stop in the Pipeline Syntax page, it became clear that the KPP Management Plugin was old enough (6 years since the last update at that point) that it didn't use the required code base to get automatic support for Pipelines. Sad trombone... But, hey, I'm a programmer, I've got this.

Enter the Javas

I'd done some recent Java work at Haste, but it'd been quite a while since my last serious effort to pick up someone else's code and run with it in that language, especially a plugin to yet another, much larger codebase. It turns out that the Jenkins folks (and hte folks who made the original plugin) did a good job of making things pretty sane. Once I'd reoriented my brain to Java, it was pretty straightforward to modify the code to support pipelines, and the results is that after a few hours, I now have a completely functional Jenkins Pipeline for Cartographica using Fastlane and my modified KPP Management plugin.

My modified source code can be found at gaige/kpp-management-plugin on GitHub.

Helpful links: