0

I am having issues in executing a Python script from a Jenkins Pipeline. I already have a Jenkins Multi job Pipeline, in which I am introducing an extra Build step which will execute my Python script.

In the 'Build Step' in Jenkins I noticed an option "Execute Python Script" in which I added my Python Script, when I execute the job, it fails at my Python code with a syntax error. Please note that my Python code works well in a local IDE.

I am not sure what I am doing wrong. Can we not execute Python code directly from the Jenkins Build step? Is there any other way I could execute?

Jenkins Python Script Error while executing job

user16120973
  • 27
  • 2
  • 8
  • Apparently you have a syntax error in your Python code, or in the code that tries to execute the Python code. I'm not sure how we can tell you why that is, because you didn't show the code, or the exact error message. – mkrieger1 Jun 16 '21 at 21:02
  • Which Python version are you using to execute the code in your local IDE, and which Python version is Jenkins using? – mkrieger1 Jun 16 '21 at 21:04
  • @mkrieger1 Can we directly add the full Python code in this Jenkins 'Post Build' section or should I save the Python code in a folder & give a execute command ? – user16120973 Jun 16 '21 at 21:06
  • I am using Python 3.9 – user16120973 Jun 16 '21 at 21:06
  • I don't know that. But what about the Python version that Jenkins is using? – mkrieger1 Jun 16 '21 at 21:07
  • https://stackoverflow.com/questions/55148435/jenkins-post-build-python-script-file My error is similar to this, but I am unable to follow the solution – user16120973 Jun 16 '21 at 21:08
  • Why don't you just include the error you actually get in the question? Instead of referring to a "similar" error. And which Python version is used by Jenkins? – mkrieger1 Jun 16 '21 at 21:08
  • Included the screenshot – user16120973 Jun 16 '21 at 21:24
  • See https://stackoverflow.com/questions/50297859/double-asterisks-error-invalid-syntax – mkrieger1 Jun 16 '21 at 21:41
  • For future questions, please include code and error messages as text, not as links to screenshots. – mkrieger1 Jun 16 '21 at 21:42

0 Answers0