| | |
| | | ## 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 |
| | |
| | | ![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) |
| | |
| | | 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` ..... |