Skip to content

Lab A - Build Software

Goals

We’ll setup a CI Pipeline with source code tests, build, and then push the artifact to a remote repository!

Lab Guide

  1. Login to Harness at https://workshop.harness.io using the credentials provided.

  2. Ensure your project is selected: 1 click on project, 2 click/ensure project level, 3 click on project shown. Project Select

  3. Get your personal application link: 1 click the hamburger button, 2 click on Unified View. Unified View

  4. then 1 click-hold and drag over your URL (it will look different). Right-click and copy the URL. Unified View2

  5. Open a new tab in your browser and then paste the URL into the address bar and press enter.

    Our first pipeline

  6. Return to the Harness Platform tab then: 1 click Pipelines, 2 Click Create a Pipeline Create a pipeline

  7. In the box that pops up: 1 give your pipeline a name, 2 click Inline, 3 click Start Create a pipeline2

  8. then: 1 click Add Stage, 2 Build as the Stage Type Add build stage

  9. then: 1 enter any name (ex: build), 2 ensure Clone Codebase is selected, 3 click for repo selector and pick harnessrepo, 4 click Set Up Stage configure build step

    Configure the infrastructure and tests

  10. On the infrastructure page: 1 click Cloud, 2 click Continue build infrastructure

  11. On the execution page: 1 click Add Step, 2 click Add Step add tests

  12. In the Step Library: 1 (optional) type tests in search box, 2 click Run Tests add test step

  13. In the Run Tests pane: 1 name the test Run Tests with Intelligence, 2 choose python, 3 Pytest, 4 Click Additional Configuration to expand…

    5 copy and paste the install command below into the Pre-Command field…

    pip install pytest & cd ./python-tests

    … then: 6 click Apply Changes configure tests

    Leverage a template for software build!

  14. Back in the Execution pane: 1 click Add Step, 2 click Use Template add compile step

  15. In the Template Library: 1 click Compile Application, 2 click Use Template (far bottom right of screen) choose template

  16. In the template box: 1 name the template Compile, 2 click Apply Changes save template

    Save the completed build artifact

  17. Back in the Execution pane: 1 click Add Step, 2 click Add Step add save step

  18. In the Step Library: 1 type docker in search box, 2 click Build and Push an image to Dockerhub add save step2

  19. In the Build and Push pane:
    1 name the step Push to DockerHub
    2 select dockerhub for Docker Connector
    3 for Docker Respository paste:

    Terminal window
    nikpap/harness-workshop

    4 click +Add in Tags, then paste:

    Terminal window
    <+variable.username>-<+pipeline.sequenceId>

    5 Click Optional Configuration to expand
    6 For DockerFile paste:

    Terminal window
    /harness/frontend-app/harness-webapp/Dockerfile

    7 For Context paste:

    Terminal window
    /harness/frontend-app/harness-webapp

    8 Click Apply Changes. That was the biggest step in the workshop, you did it! ⭐️ docker config

  20. In the top right of Pipeline Studio: 1 click Save, 2 click Run run pipeline