Reputation: 1068
I have a Node.js application with a Docker file. I want to build this in Jenkins. I also want to run test cases.For which I have defined a script in package.json
file. Which runs test cases and generates coverage report.
From what I have understood. I need to
I want to checkout my repository from github.com . Here are the steps that I followed
Here is what my Jenkins file looks like
pipeline {
agent {
docker {
image 'node:6-alpine'
args '-p 3000:3000'
}
}
stages {
stage('initialization') {
steps {
script {
TAG_NAME = '1.1.'+ "${env.BUILD_NUMBER}"
def clientImage = docker.build("registrypath:5000/test:${TAG_NAME}", "-f ./path_to_dockerfile/Dockerfile .")
}
}
}
}
}
I get a Docker error: command not found. I have not been able to complete the first step to proceed further.
Upvotes: 1
Views: 1693
Reputation: 21
You have to install docker client inside your jenkins container. You can do it by custom docker image.
Jenkins documentation say how to do that here.
More explanation from a guy here.
I did it (with fresh docker installation instructions for centos7) and that works well.
You have to mount /var/run/docker.sock inside container and add jenkins user in docker group :
usermod -a -G docker jenkins
Upvotes: 0
Reputation: 55
You can use docker-in-docker in order to build your images in a docker container.
That is not quite recommendable due to data corruption.
Recommended: install in your own image, derived from jenkins/jenkins:lts, the binary file for docker and mount /var/lib/docker from your machine, where Jenkins is run.
Through this, you have also the advantage that your image are cached on your machine and you must not pull always the image from repository because Jenkins was restarted.
For more informations:
Upvotes: 1
Reputation: 12896
Make sure that Docker is installed on your Jenkins machine or that Jenkins itself is running in a Docker container.
Upvotes: 0