I am using declarative Jenkins pipeline. I am newbie in Jenkins so i don't understand something. I don't know how to handle this error and can someone tell me what is best options to do builds.
I have bash script which build, tag and push docker image to repository. This is the part of my Jenkinsfile;
pipeline {
agent {
kubernetes {
label 'bmf-worker'
defaultContainer 'jnlp'
yaml """
apiVersion: v1
kind: Pod
metadata:
labels:
component: ci
spec:
# Use service account that can deploy to all namespaces
serviceAccountName: service-reader
containers:
- name: docker
image: docker
command:
- cat
tty: true
- name: kubectl
image: gcr.io/cloud-builders/kubectl
command:
- cat
tty: true
- name: gcloud
image: google/cloud-sdk
command:
- cat
tty: true
"""
}
}
stages {
stage('Code Checkout and Setup') {
steps {
echo 'Code Checkout and Setup'
}
}
stage('Build') {
parallel {
stage('Build') {
steps {
echo 'Start building Frontend and Backend Docker images'
}
}
stage('Build BMF Frontend') {
steps {
container('gcloud') {
echo 'Building Bmf Frontend Image'
sh 'chmod +x build.sh'
sh './build.sh --build_bmf_frontend'
}
}
}
stage('Tag BMF Frontend') {
steps {
container('gcloud') {
echo 'Building Bmf Frontend Image'
sh 'chmod +x build.sh'
sh './build.sh --tag_frontend'
}
}
}
stage('Build BMF Backend') {
steps {
container('gcloud') {
echo 'Buildinging Bmf Backend Images'
sh 'chmod +x build.sh'
sh './build.sh --build_bmf_backend'
}
}
}
stage('Tag BMF Backend') {
steps {
container('gcloud') {
echo 'Building Bmf Frontend Image'
sh 'chmod +x build.sh'
sh './build.sh --tag_frontend'
}
}
}
}
}
How to use podTemplate to execute my steps. When am using docker container for Stage Build BMF Backend i have these errors;
- Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
- /home/jenkins/workspace/BMF/bmf-web@tmp/durable-c146e810/script.sh: line 1: ./build.sh: not found
With gcloud container defined in podTemplate;
time="2019-03-12T13:40:56Z" level=error msg="failed to dial gRPC: cannot connect to the Docker daemon. Is 'docker daemon' running on this host?: dial unix /var/run/docker.sock: connect: no such file or directory"
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
And how to tag docker images because I need docker to tag and git because tags is short commit. When am using docker there is no git.
My Jenkins master is on Google Cloud Kubernetes.
Can someone explain me better solution to execute jobs.