0

I'm writing a Jenkinsfile to create builds for a multi-branch pipeline and docker/docker pipeline plugin for spinning up the docker containers in Jenkins. I have an image that I want to use to build the docker containers. I need to pull this image from a certain URL say: docker.abc.com, run the container and then do all the Jenkins stuff inside the container. I'm currently getting the following error:

Jenkins does not seem to be running inside a container

My code looks something like this:

node {
    try {
        // set working directory
        dir(working directory here){
            stage(main){
                checkout scm
                docker.image("docker.abc.com/def:latest").inside{
                    // do Jenkins stuff
                }
            }
        }
    }
    catch {
        // catch error and send notification
    }
}
Noob Coder
  • 38
  • 4

1 Answers1

0

I solved the issue a few days back. My code structure (I can't share the exact code, sorry about that):

node {
    try {
        // set working directory
        dir(working directory here){
            stage(main){
                // get docker image
                // defined a docker command here that runs the container, clones git repository inside it and uses makefile to build the project
                // ran the docker command in a shell script
            }
        }
    }
    catch {
        // catch error and send notification
    }
}
Noob Coder
  • 38
  • 4