Developer Activity: Work on feature-branch

In this module, as a Developer you are tasked to make change to an existing service - the parasol-store service. You will create a feature branch of the repository and then work in an ephemeral environment that allows you to work independently without impacting other developers in your team. Once you are ready with the changes, you can raise a merge request to push your changes to main branch, and there progressing the changes to production deployment

Please make sure you are logged in as a Developer with dev1/{common_password}. If you are unsure how to, please refer to the below note.

Click here to view instructions to login as the Developer.

Login as Developer

  • You will perform this activity as a Developer.

  • Logout from Red Hat Developer Hub

    • Navigate to the Settings menu at the bottom right side of Red Hat Developer Hub and click on the kebab menu in the Profile card

      Settings of Red Hat Developer Hub
    • Sign out of Red Hat Developer Hub from the Settings section as shown in the screenshot below.

      Signing out of Red Hat Developer Hub
  • Logout from GitLab

    • Click on the Profile icon, and Sign out from the dropdown as shown in the screenshot below.

      Signing out of Red Hat Developer Hub
  • Login back as a Developer to to Red Hat Developer Hub and GitLab using the credentials dev1/{common_password}

Create a feature-branch

  1. Click here to access the parasol-store repository.

  2. Click on the (+) button as shown in the screenshot below, and click on New branch menu

    create branch

  3. Name the branch as my-feature-branch so as to make it easier to follow the rest of the instructions.

    create branch name

Onboard the Feature Branch using template

  1. Visit your instance of Red Hat Developer Hub. If prompted, login as dev1/{common_password}.

  2. Choose the Create side menu, and you will see the Parasol Store Development template. Click on Choose.

    choose parasol store template

  3. In Step 1: Provide Information for the sandbox deployment, enter the feature-branch name my-feature-branch or the name you have picked for your branch.

    choose parasol store template step1

  4. In Step 2: Provide database information. Keep all the fields as they are - no need to make changes. The parameters are already set based on the OpenShift Service names from the existing deployments of the application.

    choose parasol store template step2

  5. Click on Review, and proceed to Create

    choose parasol store template step3

  6. Click on the Open component on catalog link

    parasol branch component

Explore the Component

  1. The newly created component for the ephemeral environment acts as a single pane of glass to perform most of the acivities as a developer

    parasol branch component laanding

  2. Notice that under the CI tab, a pipeline is in progress. If this isn’t in progress yet, allow a few minutes for the pipeline to kickoff.

    parasol branch first pipeline

  3. The pipeline turns green when it finishes the run successfully

    parasol branch first pipeline success

  4. Explore the other tabs to see how Red Hat Developer Hub provides a single pane of glass for the Developer’s ephemeral dev environment.

    1. The Overview tab provides easy access to the sourcecode and deployments

    2. The Topology tab provides a window to the deployment on OpenShift

    3. The Issues and Pull/Merge Requests tabs provide insights about the GitLab repo

    4. CI tab shows an easy view of the pipeline in both OpenShift (Tekton based pipeline), and on GitLab

    5. The CD tab shows the deployed components/systems in the namespace using ArgoCD plugin

View the deployment on OpenShift

  1. To view the deployment on OpenShift, click here.

Login to OpenShift using the htpasswd provider and the credentials admin / {common_password}.

parasol branch deployment1

Add features to the application

  1. Click on the < > View Source button on the Red Hat Developer Hub Component Overview page to access the source repository of parasol-store.

    parasol branch component overview

  2. Switch to the my-feature-branch

    parasol switchbranch

  3. The feature request is to provide a REST API call endpoint that returns the total number of available products. For the purposes of this workshop, we will (once again) uncomment some code.

  4. Changes are needed in the parasol-store> src> main> java> org> parasol> retail> store> catalog> rest> CatalogResource.java file. You can click here to directly access this file on GitLab.

  5. Select Edit > Edit single file. If prompted, login with dev1/{common_password}.

    parasol webide

  6. Right at the bottom of this file, you will find the getProductCount() method that’s been commented out.

    parasol commented prodcount

  7. Carefully delete the these two lines: /* DELETE THIS COMMENT LINE and DELETE THIS COMMENT LINE */. This will remove the comments.

  8. After deletion, the file should look like this

    parasol un commented prodcount

  9. Add a Commit Message Chore: Add ProdCount REST API call at the bottom of the page; make sure the Target Branch is my-feature-branch; Click Commit changes

  10. You can now close the GitLab browser.

View parasol-store component on Red Hat Developer Hub

  1. Navigate to parasol-store-my-feature-branch component from your Red Hat Developer Hub

  2. Access the CI tab to view the pipeline. You will see a new pipeline being triggered for the change you just made.

    parasol innerloop pipeline1

  3. Shortly, the pipeline will be marked as Succeeded

    parasol innerloop pipeline ok

    The first pipeline was triggered when you created this branch using the Software Template, and the next is by the Git commit.
  4. Once you’re happy with the changes, you can proceed to create a merge request to the main branch.

Conclusion

In this module you learnt how Software Templates and plugins can accelerate developer productivity. With Red Hat Developer Hub, developers have access to all the necessary tools via a single pane of glass, reducing cognitive load.

This marks the end of the inner loop within the ephemeral development environment. In the next section, you will create a merge request to the main branch to initiate the outer loop.