I have been trying for days to try and get my jenkins pipeline to work, I was already able to execute tests via docker on my local using cmd lines. However when trying to do the same steps on jenkins it keeps on failing. Is there any way anyone could possibly provide an example of working jenkins pipeline script (regardless of using dockerfile to build the image or by using the docker image on dockerhub) that is able to generate reports within the docker container.
Reference : git - https://seleniumbase.io/integrations/docker/ReadMe/ Dockerfile - https://github.com/seleniumbase/SeleniumBase/blob/master/Dockerfile
Here is what i have been working with :
node {
git 'https://gitlab.com/username/repo.git'
def myEnv = docker.build 'seleniumbase:1'
// Run tests inside the Docker container
def containerName = 'sbase-container'
def testCommand = 'pytest' // Replace with your actual test command
def testCommand2 = "--var1=username' --var2='password' --dashboard --html=/SeleniumBase/examples/reports-generated/report.html --browser=chrome --headless"
try {
def container = myEnv.run("-i -t --name ${containerName}")
container.inside {
bat './run_script.sh'
}
} finally {
// Clean up the Docker container
bat "docker stop ${containerName}" // Use 'bat' step for Windows
bat "docker rm ${containerName}" // Use 'bat' step for Windows
}
}
Thank you so much in advance. Do let me know if there is any other information required.