...

/

Naming Steps and Using Multi-Line Commands

Naming Steps and Using Multi-Line Commands

In this lesson we will work on the jenkins-x.yml file and discuss how to name the steps and use multi-line commands.

A quick look at the pipeline

Let’s take a quick look at the pipeline we have so far.

Press + to interact
cd go-demo-6
cat jenkins-x.yml
Press + to interact
buildPack: go
pipelineConfig:
pipelines:
pullRequest:
build:
preSteps:
- command: make unittest
promote:
steps:
- command: ADDRESS=`jx get preview --current 2>&1` make functest

We’re extending the go pipeline defined as a build pack by adding two steps. We’re executing unit tests (make unittest) before the build steps, and we added functional tests as a step after those pre-defined for the promote lifecycle. Both of those steps have issues we might want to fix.

So far, I have tried my best to hide a big problem with the execution of functional tests in our pipelines. They are executed after promotion, but there is no guarantee that our application is fully operational before we run the tests. If you create a pull request right now, without modifying the pipeline, you are likely going to experience failure. A pipeline run triggered by the creation of a pull request will fail because the functional tests are executed not when the application in a preview environment is fully up-and-running but after the “deploy” instruction is sent to Kubernetes. As you probably already know, when we execute kubectl apply, Kube API responds with the acknowledgment that it received the instruction, not with the confirmation that the actual state converged to the desired one.

There are quite a few ways to ensure that an application is rolled out before we run tests against it. We’re using Helm so you might be thinking that --wait should be enough. Usually, that would be the correct assumption if we were using Tiller (Helm server) in the cluster. But, Jenkins X does not use Tiller due to security and quite a few other issues. To be more precise, it does not use Tiller by default. You’ll need to specify --no-tiller false argument when installing Jenkins X. If you followed the instructions (Gists) as they are, your cluster does not ...