Go Demo

This is a minimal HelloWorld demo!

First, make sure you have a Kubernetes cluster with Jenkins X installe

Warning

It is easiest to use all the default values, such as a dns on nip.io and Static Jenkins.

Create Quickstart

Let's examine what quickstart does.

1
jx create quickstart # Cancel with ctrl+c

Cancel it with ctr+c, as it will be very interactive.

Let's create the Go (lang) demo!

1
jx create quickstart -l go -p jx-go -b

Info

Go to github.com/jenkins-x-quickstarts to see all the available quickstarts.

Open repo

Replace ? with your GitHub user.

1
export GH_USER=?
1
open "https://github.com/$GH_USER/jx-go"

View created files

Let's take a look at what was created:

1
ls -l jx-go
1
cat jx-go/Dockerfile
1
cat jx-go/jenkins-x.yml
1
cat jx-go/Makefile
1
cat jx-go/skaffold.yaml

And let's take a loot at the Helm charts.

1
ls -l jx-go/charts
1
ls -l jx-go/charts/jx-go
1
ls -l jx-go/charts/preview

Webhook

Jenkins X works with Git and wants to work event based. This means there should be a webhook, which will be send to our Jenkins X's cluster.

1
open "https://github.com/$GH_USER/jx-go/settings/hooks"

Releases

Jenkins X will create releases for you in your Git repository (where applicable).

To view them:

1
open "https://github.com/$GH_USER/jx-go/releases"

Explore Application in JX

1
jx console
1
jx get activities
1
jx get activities -f jx-go -w # Cancel with ctrl+c
1
jx get build logs # Cancel with ctrl+c
1
jx get build logs -f jx-go # Cancel with ctrl+c
1
jx get build logs $GH_USER/jx-go/master

General Jenkins X listings

1
jx get pipelines
1
jx get applications
1
jx get applications -e staging
1
jx get env

Update the application

First, make sure the application has been build successfully and is running in our staging environment.

Confirm we're ready

1
jx get activities -f jx-go -w

You should see something like, after which we can continue the next step.

1
2
3
4
5
6
7
STEP                     STARTED AGO DURATION STATUS
joostvdg/jx-go/master #1                      Running Version: 0.0.1
  Release                      4m23s     1m0s Succeeded
  Promote: staging             3m23s    2m26s Succeeded
    PullRequest                3m23s    1m25s Succeeded  PullRequest: https://github.com/joostvdg/environment-jx-staging/pull/1 Merge SHA: f602fd78694fcfef7b59b27469e0e2b8538e1bb7
    Update                     1m58s     1m1s Succeeded  Status: Success at: http://jenkins.jx.35.231.11.119.nip.io/job/joostvdg/job/environment-jx-staging/job/master/2/display/redirect
    Promoted                   1m58s     1m1s Succeeded  Application is at: http://jx-go.jx-staging.35.231.11.119.nip.io
1
2
APP_ADDR=$(kubectl get ing -n jx-staging jx-go -o jsonpath="{.spec.rules[0].host}")
open "http://$APP_ADDR"

You should see a very fancy (for 1992) page which says Hello from: Jenkins X golang http example.

Make the change

We will now create a WIP branch.

1
git checkout -b wip

Now edit our main.go file using your favorite editor - or VIM if you want.

Change the title variable: title := "Jenkins X golang http example" to a value you like. For example: title := "Jenkins X Is Awesome!".

1
2
3
git add main.go
git commit -m "changed our message to be awesome"
git push origin wip

Create PR

We will have to create PR for our change.

When pushing to Git, you should have received a link to create a pr. If not, see below:

1
open "https://github.com/${GH_USER}/jx-go/pull/new/wip"

Keep the PR page open, you will see why!

We will watch the activities to see when our preview is ready!

1
jx get activities -f jx-go -w

Once we see something like Preview Application 0s http://jx-go.jx-joostvdg-jx-go-pr-1.35.231.11.119.nip.io We can go back to our PR page, which should now the link to the preview as well!

Confirm your change is successful and merge the pull request by clicking the merge button.

Go back to the activities feed - in case you closed it. And wait for the PR to land in staging.

1
jx get activities -f jx-go -w

Once the activity Promote: staging is succeeded, we can confirm our application is updated.

1
2
APP_ADDR=$(kubectl get ing -n jx-staging jx-go -o jsonpath="{.spec.rules[0].host}")
curl "http://$APP_ADDR"

To wrap up, go back to the master branch and pull the changes from the PR.

1
2
git checkout master
git pull

Promote to Production

Applications will be automatically promoted to staging, to promote them to production we have to take manual action.

How do you promote manually

To manually Promote a version of your application to an environment use the jx promote command.

1
jx promote --app myapp --version 1.2.3 --env production

The command waits for the promotion to complete, logging details of its progress. You can specify the timeout to wait for the promotion to complete via the --timeout argument.

e.g. to wait for 5 hours

1
jx promote  --app myapp --version 1.2.3 --env production --timeout 5h

You can use terms like 20m or 10h30m for the various duration expressions.

To promote our jx-go application, run the following command.

Promote jx-go to production

1
jx promote  --app jx-go --version 0.0.1 --env production --timeout 1h

Info

You will get a warning message stating Failed to query the Pull Request last commit status for, which is at this time (April 2019) expected behavior.

Once the promotion is completed successfully, you should be returned to your console.

Let's confirm our application landed in Production!

1
2
APP_ADDR=$(kubectl get ing -n jx-production jx-go -o jsonpath="{.spec.rules[0].host}")
curl "http://$APP_ADDR"