In the previous section, we built and pushed a docker image to Docker Hub. In this section, we will look at how to pull the built docker image and runs tests against it.
To pull our application docker image artifact from Docker Hub and run tests, follow these steps.
Navigate to Admin -> Pipelines and click on
Create a pipeline within this group.
Specify the pipeline name as
Introduce the pipeline
build_and_publish_imageas a material called
Tip: Choose the option 'Pipeline' in the 'Material' dropdown.
We want to add our build pipeline
build_and_publish_imageas a dependency to this one, as we want the test pipeline to run only after the docker image is built.
Create a stage named
Create the initial job
test_app_image. The initial task argument is
docker run $DOCKERHUB_USERNAME/bulletin-board:$GO_DEPENDENCY_LABEL_UPSTREAM npm test
Tip: Do not forget the
-coption in the arguments section.
DOCKERHUB_USERNAMEas an environment variable.
Fetch External Artifact taskto pull the built image from Docker Hub.
Reorder the tasks as shown as we want to first fetch the image before running any tests.
We have created a sample elastic profile
demo-app for the helm release by default. Before associating elastic profile to a job, you'll need to verify that the elastic profile and plugin settings are set up.
Navigate to Admin > Elastic Agent Profiles
You should be able to see
demo-app in this.
If the elastic profile does not exist or if you would like to create your own, refer to this section
Navigate to Admin > Plugins and click on Status Report
If you're able to see a screen similar to the screenshot above, then the plugin has been configured.
If the plugin settings have not been configured, refer to this section
Before you can run the pipeline, you’ll need to associate an elastic profile ID with the job to be executed. To do this, go to the
Job Settings tab of the specific job.
Tip: Use the tree on the left to navigate to the job
test_app_image. Once you're here, you can associate the profile ID under the Job Settings tab.
Once you’ve associated the job to the profile, you’re ready to run the pipeline.
Now that the test pipeline is configured, we can run it to verify that the tests have been run.
To run the pipeline, unpause the pipeline in the GoCD dashboard. The changes in the source git repository get picked up automatically when the pipeline is triggered.
In the next section, we'll look at how to configure a pipeline to deploy our sample application onto a Kubernetes cluster.