I’m new using Jenkins. My goal is to run a unitest python file on Jenkins. My environment is Windows 10 with a Jenkins version 2.387.1. I’ve installed the default plugins and the additional python. The python file was created in Anaconda (Spyder) with a version of python 3.9.
The python code is the following:
from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver.firefox.service import Service as FirefoxService
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import unittest
class TestURLs(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))
def tearDown(self):
self.driver.quit()
def test_multiple_urls(self):
urls = [
"https://www.wikipedia.org/",
"https://www.google.com/",
"https://www.github.com/"
]
for url in urls:
# Navigate to the URL
self.driver.get(url)
wait = WebDriverWait(self.driver, 10)
if __name__ == '__main__':
unittest.main()
I’ve created a Freestyle Project with a Build Steps as Execute Shell with the following commands:
By no response, I meant there is not output. The cd\ is to go to the root of the path. More details about my code is that the python file is executed within an anaconda virtual environment. I don’t know if this affects the procedure. I stack on how to configure the project to setup a job capable of executing a python file.
I’ve installed the appropriate libraries to make it run outside the virtual environment and following this steps on cmd I could make it work, however, I put the same commands inside the execute shell
Well, this script has not print, however, the one executed does. About the pipeline, I didn’t configured one? it should be linked to the created project? How should I configured it? Apologies for too much questions.
You wrote you’re on windows but then you mentioned to use “execute shell”. Shell will only work on Unix, in a Freestyle project you need to use “execute windows batch”.
You posted a picture where one can see that you might have a misconfiguration in your job. You assigned a label where to execute the job but there is no agent available that has this label. So the job will never start.
@mawinter69 I’ve changed shell to batch and I’ve created an agent with the project name. I could executed it, however, I get this console output:
Started by user [rparada](http://localhost:8080/user/rparada) Running as SYSTEM Building in workspace C:\ProgramData\Jenkins\.jenkins\workspace\pythonCookies [pythonCookies] $ cmd /c call C:\Windows\TEMP\jenkins3692175436805402094.bat C:\ProgramData\Jenkins\.jenkins\workspace\pythonCookies>cd\ C:\>cd C:\Users\user\ C:\Users\user>py -m multicooki No installed Python found! C:\Users\user>exit 112 Build step 'Execute Windows batch command' marked build as failure Finished: FAILURE
I have installed all possible python plugins (with restart). The code works locally following the same steps. Why it says No installed Python found?
hard to tell why it is not found.
When you installed python did you install it as administrator making it available for all users? If not are you running your agent with the same user account used to install python?
I was wrong, I didn’t configure an agent it was the in-built node. I’ve seen different ways to configure the agent. Please, could you recommend me a link? I’ve seen this procedure How to Install Jenkins Agent on Windows - YouTube