From 514d37b5b6ebfc5d8010856813ef6dbeff5b0cd0 Mon Sep 17 00:00:00 2001
From: donal <donalspring@gmail.com>
Date: Thu, 26 Apr 2018 17:51:40 +0200
Subject: [PATCH] ADD - last exercise

---
 exercises/images/exercise6/fail-local.png          |    0 
 exercises/6-return-of-the-app-monitoring/README.md |   44 +++++++++++++++++++++++++++++++++++++++++---
 exercises/images/exercise6/fail-cause.png          |    0 
 exercises/images/exercise6/build-monitor.png       |    0 
 exercises/images/exercise6/fail-dashboard.png      |    0 
 5 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/exercises/6-return-of-the-app-monitoring/README.md b/exercises/6-return-of-the-app-monitoring/README.md
index 58bdba6..4a7c598 100644
--- a/exercises/6-return-of-the-app-monitoring/README.md
+++ b/exercises/6-return-of-the-app-monitoring/README.md
@@ -6,7 +6,7 @@
 ## Learning Outcomes
 As a learner you will be able to
 - Create dashboards in Jenkins to display build status
-- 
+- Seed Jenkins using DSL to create dashboards by default
 
 ## Tools and Frameworks
 > Name of tool - short description and link to docs or website
@@ -48,7 +48,7 @@
 ![config-commiters](../images/exercise6/config-commiters.png)
 
 2. Save your configuration to see your Build Monitor! 
-![](../images/exercise6/.png)
+![build-monitor](../images/exercise6/build-monitor.png)
 
 2. Let's create another view for Jenkins using the `Pipeline Aggregator View` plugin. This view is great because it shows lots of valuable information in a clean; easy to visualise way. Create a new view called `todolist-pipelines` and select `Pipeline Aggregator View`
 ![config-pipeline-view](../images/exercise6/config-pipeline-view.png)
@@ -65,7 +65,45 @@
 2. Explore the Jenkins Blue Ocean view for some additional monitors and views that make Jenkins look pretty!
 ![blue-ocean](../images/exercise6/blue-ocean.png)
 
-### Part 2 - Seed Jenkins Dashboards
+### Part 2 - Build Fail Analyser
+> _In this exercise we will intentionally fail the build to capture some metrics about why it's failed and how we can tighten the feedback for future failures_
+
+2. Open the `todolist-fe` app in your favourite editor. In this exercise, we will fail a test and capture the message in the log and visualise it on a dashboard.
+
+2. Open the one of the tests you wrote in previous labs; for example `tests/unit/vue-components/TodoItem.spec.js`. Negate the test at the very bottom of the file to by adding a `.not` to the `expect()` statement as shown below.
+```javascript
+  it("call makImportant when clicked", () => {
+    const wrapper = mount(TodoItem, {
+      methods,
+      propsData: { todoItem: importantTodo }
+    });
+    // TODO - test goes here!
+    const input = wrapper.find(".important-flag");
+    input.trigger("click");
+    expect(methods.markImportant).not.toHaveBeenCalled();
+    });
+});
+```
+
+2. Run your tests locally and you should see one failing test as shown below. Jenkins will have the same out put so we can capture this as code!
+![fail-local](../images/exercise6/fail-local.png)
+
+2. The `Test Suites: 1 failed, 11 passed, 12 total` string can be coded into a regex. On Jenkin homepage; hit the `Failure Cause Management` nav on the left hand menu. On the page that loads; hit `Create new`.
+
+2. Call the new Failure Cause `jest-tests`. Set the Description to be `${1,1} failed out of ${1,2}`. The `${1,1}` refers to the first capture group in a regex. Click `Add indication > Build log`. Set the Pattern to match for the test output we've seen in our test execution on the terminal using this regex `.*Tests:.*(\d+) failed.*(\d+) total.*`. 
+![fail-cause](../images/exercise6/fail-cause.png)
+
+2. Our dashboards are set to show the `Description` field from the `Build Fail Analyser`. Run a build by checking in our failed tests and check the result on the Build Monitor created in previous step
+```bash
+$ git add .
+$ git commit -m "TEST - failing build"
+$ git push
+```
+![fail-dashboard](../images/exercise6/fail-dashboard.png)
+
+2. We can save up these regex and inject them into the `jenkins-s2i` so the configuration is there the next time we launch and we don't have to code them up again. In `enablement-ci-cd` repo; the `jenkins-s2i/configuration/build-failure-analyzer.xml` already contains ones we've collected on previous residencies.
+
+### Part 3 - Seed Jenkins Dashboards
 > _TODO - Add instructions for creating dashboards as part of s2i in Jenkins setup using DSL_
 
 2. Open the s2i in `enablement-ci-cd` .....
diff --git a/exercises/images/exercise6/build-monitor.png b/exercises/images/exercise6/build-monitor.png
new file mode 100644
index 0000000..651f75f
--- /dev/null
+++ b/exercises/images/exercise6/build-monitor.png
Binary files differ
diff --git a/exercises/images/exercise6/fail-cause.png b/exercises/images/exercise6/fail-cause.png
new file mode 100644
index 0000000..123f0f3
--- /dev/null
+++ b/exercises/images/exercise6/fail-cause.png
Binary files differ
diff --git a/exercises/images/exercise6/fail-dashboard.png b/exercises/images/exercise6/fail-dashboard.png
new file mode 100644
index 0000000..6dacb73
--- /dev/null
+++ b/exercises/images/exercise6/fail-dashboard.png
Binary files differ
diff --git a/exercises/images/exercise6/fail-local.png b/exercises/images/exercise6/fail-local.png
new file mode 100644
index 0000000..9bded9c
--- /dev/null
+++ b/exercises/images/exercise6/fail-local.png
Binary files differ

--
Gitblit v1.9.3