...

/

Working with Environment Variables and Agents

Working with Environment Variables and Agents

This lesson shows how to create a new pipeline using environment variables and agents.

Let’s say that we want to add code coverage to our pipeline. We could do that with many different tools. However, since the goal is not to teach you how to set up code coverage or to explore which tool is better, we’ll skip the selection process and use the Codecov service. Keep in mind that I’m not saying that it is better than the others nor that you must use a service for that, but rather that I needed an example to demonstrate a few new pipeline instructions. Codecov seems like the right candidate.

Integrating our pipeline with Codecov

What do we need to do to integrate our pipeline with the Codecov service? If we check their instruction for Go applications, we’ll see that we should output code coverage to a text file. Since I’m trying to make the examples as agnostic to programming languages as possible, we’ll skip changing the Makefile that contains testing targets assuming that you’ll read the Codecov instructions later on if you choose to use it. So, instead of telling you to apply specific changes to Makefile, we’ll download a Gist I prepared.

Press + to interact
curl -o Makefile \
https://gist.githubusercontent.com/vfarcic/313bedd36e863249cb01af1f459139c7/raw

Now that we put Go internals out of the way, there are a few other things we need to do. We need to run a script provided by Codecov. That script expects a token that will authenticate us. So, we need three things.

  1. A container image with the script
  2. An environment variable with the token.
  3. A pipeline step that will execute the script that will send the code coverage results to Codecov.

Retrieving a Codecov token #

Let’s start by retrieving a Codecov token for ...