pipeline {
agent any
environment {
dockerImage = ''
registry = 'yashkhati/pythonapp'
}
stages {
stage('Checkout') {
steps {
checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/Yash-codeAndDev/DevOps_PythonApp.git']])
}
}
stage('Build Docker Image') {
steps {
script {
// Build the Docker image from the specified directory
dockerImage = docker.build registry
echo "Docker image built: ${dockerImage.id}"
}
}
}
stage('Run Tests') {
steps {
script {
docker.image("${dockerImage.id}").inside {
sh 'pytest'
}
}
}
}
// Add more stages as needed, e.g., deployment, testing
}
}
i am getting error on Run Test can anyone tell me why ? Error : Jenkins does not seem to be running inside a container