
Using Foresight for Improved Observability in Jira

As someone working in the software field, you’re probably already familiar with Atlassian’s products. Atlassian offers a range of tools to help manage tasks (Jira), support developers’ collaboration on code (Bitbucket) or centralize software documents (Confluence). In 2020, they released Jira Service Management (JSM), which allows developers, administrators, and business owners to collaborate at high velocity.
Jira Service Management
JSM makes work visible and acts as a single source of truth, so that an entire IT team can view work processes and outstanding tasks in a single location, keeping everyone on the same page and allowing for efficient collaboration. Code reviewers can also use data provided by JSM to decide whether to merge pull requests from their software engineers; this determines whether new changes are applied to the existing software to improve customer experience. JSM offers important benefits to any DevOps team.
JSM’s Limitation; Foresight’s Solution
Despite having all these great features, JSM still lacks one important feature: It doesn’t display the status of the tests in the software project. Without test status observability, we cannot be certain whether the software works as expected.
This is where Foresight comes in handy. By combining Foresight tests’ data capture and JSM’s data, code reviewers can be certain about what has been changed in the code and where, and whether or not the changed code has already been checked using new tests.
Let’s explore how Foresight complements JSM using a real world example.
Demo Project: Applying Foresight to JSM
Let’s create a project demonstrating JSM and Foresight in a retail application. Our application will allow users to shop online. Its code can be found in this GitHub repository.
When we deploy the application, here’s what we see:

The application is up and running, and already has a good number of users. After a few months, some customers report an error to the customer service team. A new JSM issue is created by the customer service team describing the bug.

When the users try to add a product to the cart, the default number of the products in the product page view is seven, instead of just one item as we would expect. Reporting this bug in the JSM board means that customer service staff, developers, and technical leads can track the updates about the bug simultaneously, enabling them to collaborate together efficiently.
Create a GitHub Action Workflow
We need to create a GitHub Action workflow for this project in order to apply every updated code change. This allows us to test the new code and check whether it introduces any errors. Here is the GitHub workflow file defined in yaml format:
In this workflow, we first need to download the latest code from GitHub. Next, we’ll set up Python version 3.8, and finally, we’ll install dependencies to be able to run the test for the retail application.
When we push the workflow file to the GitHub repository and create a pull request in GitHub, we see that the GitHub Action is triggered automatically.

Now that we’ve created the GitHub Workflow for deploying the application, let’s go ahead and integrate JSM with GitHub.
Integrate JSM with GitHub
To collaborate as a team on Jira Service Management, we need to integrate JSM with GitHub so that everyone on our team can see the code changes in GitHub that pertain to a bug reported using JSM. This allows us to review the code efficiently and to check whether the updated code resolves the bug or not.
To integrate JSM with GitHub, we first need to install the GitHub integration tool.

Then click “Get it now” to install GitHub for JSM.

After choosing the relevant JSM site, click “Install app.”

Click “Get started” to start integrating GitHub and JSM. After this step, we’ll be redirected to the configuration page automatically, where we’ll indicate our GitHub organization or GitHub personal repository in order to choose which data we’re going to integrate with JSM.

If the relevant personal or organizational GitHub account isn’t showing up on this screen yet, we need to install the “Jira Software + GitHub” application in the appropriate GitHub account. The Github For Jira integration page offers a guide to this process.

After installing the “Jira Software + GitHub” application, we’ll see that the “Jira” application is added to our listed applications in GitHub.

Then, we should be able to see our GitHub account/GitHub organization in the Jira set up page in order to integrate them with one another.

After choosing the Github account/GitHub organization we want to integrate, we should see “Install Jira'' displayed:

Hit “Install,” then choose the relevant site.

After clicking on “Connect,” we should be able to see our new account/organization in the connected organizations list on the Jira configuration page.

We should also see the Github pull request and its commit in JSM by now.

Great! We’ve successfully integrated JSM with GitHub. Let’s move to the next step: Checking the new pull request in GitHub from the JSM site.
Check the New Pull Request in GitHub
Let’s pick up where we left off in our online retail demo. The store’s customer service team had created a new JSM issue on the JSM board. When viewing a product page, customers were being presented with the default number of items being seven, instead of one as we’d expect.
From a business perspective, this could make customers uncomfortable and may discourage purchasing, because customers think that the shopping site is forcing them to buy in high quantities.
Let’s remind ourselves how this looks in JSM:

Our team quickly found the root cause of the error and submitted a new pull request to GitHub Action.
Let’s take a look at the pull request to decide whether or not to apply this change.
JSM’s Shortcoming
From the JSM bug report, we can see the code commits as below.

There is a commit for “Update test for default value of item.” Let’s take a closer look.

We can see that the default number of items has been updated to one instead of seven, which should resolve our issue. However, we’re not sure whether the bug is really fixed because we can’t see the status of all the executed tests from JSM and GitHub in this view. Moreover, we don’t know whether or not the developer added new tests for the updated codes.
This is where we need to call on Foresight. Let’s integrate Foresight into GitHub Action workflows so we can answer these important questions and make sure our application is functioning as it should.
Integrate Foresight into Existing GitHub Action Workflows
In order to integrate Foresight into GitHub Action workflows, we need to add foresight-workflow-kit-action and foresight-test-kit-action into the defined yaml file. The final workflow yaml file will look like this:
Let’s push this updated code to the GitHub repository to see the status of the tests in Foresight.
Foresight Capabilities to the Rescue
In Foresight, we can see that the latest workflow run is successful.

The “Tests” status in the workflow shows us whether our tests are successful or not.

Here, we can see all our tests (two, in this case) are successful. However, we notice that there is one line in our code that hasn’t yet been tested. Click on “See Changes” to see what code this is.

There is one line—indicated by brown highlight—that hasn’t been tested, which is:
Since this code escaped testing, we need to add more tests to make sure that we’re running tests on each and every line of code in order to mitigate the risks of introducing new bugs to the application. Let’s skip ahead and see what happens once someone on our team has added new tests to account for this line of code.
Check the Tests Status After Adding a New Test
After adding this new test, our team created a new pull request for the JSM issue. When we check the pull request from JSM, we can see that there is a commit for the new test, named “Add test for checking self.title.”

Clicking on that commit, we see the new test that we added.

Here, our team added a new test named “test_check_title_item” for checking the __str__ method.
Let’s go to Foresight to see the status of our tests in the workflow.

We now have three tests, all of which have passed, and we can see that all of our code has been accounted for in these tests. The new pull request is now ready to be merged.

Let’s go ahead and merge it in order to deploy the fix for the bug.

Thanks to Foresight’s change impact analysis, we’re able to see which lines of code are accounted for by tests, and the status of the executed tests. With this information, we’re able to merge our team’s pull request with confidence.
Conclusion
Foresight closes JSM’s test gaps, captures code changes, and reports test statuses, optimizing GitHub and JSM integration by ensuring monitoring transparency for the entire DevOps team, allowing code fixes to be performed quickly and efficiently.
Explore how Foresight can help you to build reliable products quickly and efficiently today!