Example Jenkins pipeline publishing NPM package to AWS CodeArtifact

CodeArtifact is an AWS product for storing build artifacts in the cloud, akin to Nexus or Artifactory. The example below shows a basic Jenkins Pipeline job that builds and NPM artifact and publishes it to CodeArtifact, which I’m publishing as it was a bit tricky to figure out. The key bit is getting the access token to be generated by the CLI tools and then passing it down to the main build process via an environment variable.

Fluentlenium

My team have been wanting to improve our testing process for our front-end web code. One area we have been looking at is browser automation testing. Although there have been new tools in this space (i.e. Puppeteer, Playwright, Cypress), it is still Selenium and its WebDriver that seem to dominate. Unfortunately, Selenium-based testing code is quite verbose, and the library can be hard to get started with. Thankfully, a library called Fluentlenium has been written to make things easier.

Book Review: Superthinking by Gabriel Weinberg and Lauren McCainn

“…you can’t really know anything if you just remember isolated facts and try and bang ’em back. If the facts don’t hang together on a latticework of theory, you don’t have them in a usable form. You’ve got to have models in your head.” Charlie Munger, Vice Chair of Berkshire Hathaway Super Thinking is a fast-paced introduction to the world of Mental Models that fires over 300 of them at you by the end of the book!

Vuex Test Service Mocking

A typical pattern for Vue applications which use REST APIs is to have a Vuex Store which delegates API operations to a service helper. This decouple the store’s logic for client-side data storage/manipulation logic, from logic to interact with the server. However, this can make unit testing the Vuex Store logic harder as now there is a dependency on this service helper which requires a server to work with. To test this you could start the server and have the service use it, but its not always practical and certainly isn’t unit testing.

A year with Testcontainers

Testcontainers is a Java library for integrating Docker containers into tests. It provides tools to spin up build images, spin up containers and interact with them. Extensions have been provided to wrap commonly used tools, for example, launching a Postgres Database and getting the JDBC connection is super simple. @Test public void testSimple() throws SQLException { try (PostgreSQLContainer postgres = new PostgreSQLContainer<>()) { postgres.start(); .... } } Our team has been using Testcontainers for just over a year now and I though I’d share some experiences, pros and cons.

Jenkins Declarative Pipeline Tips

Jenkins Declarative Pipelines allow you to script your build process as code and are rapidly being adopted. However, they can be tricky to use, so here are a few tips. The Snippet and Declarative Directive generators Jenkins ships with generators for different parts of the pipeline. These can be accessed through the web interface and come with forms for configuring different parts of the build step. This can be useful for generating parts of the pipeline or seeing what functionality is available.

Testcontainers makes testing with Databases easy

Testcontainers makes testing code against a database ridiculously easy. My current project has a requirement to interact with different database types. In the past this would have been a pain to test against; perhaps requiring some centrally managed databases that developers access. Even with local servers there are issues of state, resource usage and other factors that make writing reliable tests hard. However, Testcontainers leverages containerization through Docker and take the pain away.

Book Review: My Job Went to India: 52 Ways to Save Your Job By Chad Fowler

This book is a treasure chest, containing pearls of wisdom for Software Engineers looking to take themselves to the next level. Each of the 52 pearls contains is not just general advice, but specific actions that can be taken. These vary from habits like “reserve 2 hours a week for exploring new technologies”, to scheduled actions like an annual self appraisal. These practical steps make the book especially useful. Chad writes as a recruiter, sent on a mission to India to setup a new offshoring team.

Book Review: So Good They Cant Ignore You by Cal Newport

Seeking some career advice, and drawn in by the catchy title, I ordered a copy of So Good They Can&rsquo;t Ignore You by Cal Newport. In the book Cal seeks to find the secret to “good work” using a series of case studies of different people’s careers, from across different industries from Blue Grass music to Software Engineering. These form the basis for various “laws” about good work, which readers can follow in their own careers.

Debugging resource leaks through Java Streams

Any Java programmer worth their salt will know about the Stream<T> interface and how to use it for data processing. However, incorrect use can lead to resource leaks if the source of the stream is some resource that needs to be closed. Stream extends the Autocloseable interface, and also allows for onClose callbacks to be added to do cleanup work. In this example a Stream<String> is returned which reads lines from a File.

Bio

I am a Software Engineer from the UK with experience covering all aspects of development.