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!

Steps

  1. In Harness:

    click:#
    Projects (blue bar)1
    Your Project: ?project2

    project select

  2. If you see the Welcome screen with Get Started pane, kick it to the curb with the “X” top right. close splash

    Create the pipeline

  3. In your project:

    click:#
    Projects (blue bar)1
    Your Project: ?project2
    Create a pipeline
  4. In the box that pops up:

    click:#value
    Name1Python Build
    Inline2
    Start3

    Create a pipeline2

  5. then:

    click:#
    Add Stage1
    build2

    Add build stage

  6. 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

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

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

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

  10. 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!

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

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

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

    Save the completed build artifact

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

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

  16. 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

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