Quantcast

cannot run a python script from Jenkins

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

cannot run a python script from Jenkins

sreeramk
Hello

   Looks like I'm having issues running a python script in Jenkins.  I am running Jenkins version 2.47. I have tried both declarative pipelines as well as regular jenkins jobs and the issue is the same.  I already tried importing from signal suggested in this stackoverflow thread.  

   The Jenkins agent on which I'm running this script is a RHEL-6 box.  Its built for a specific purpose and I don't want to run a 'yum update' on it.  If there are specific packages I need to update, I could do that.  

   Anyway, when I login to the box and run 'sudo reposync.sh' it works fine.  The reposync.sh script calls reposync python script with arguments.  

   But when I create a Jenkins job and use execute shell with command 'sudo reposync.sh', I get the error below.  I've called other python scripts like this 'sudo -u <username> python <script.py>' and it works.  but not this one.  I have attached the reposync script if anyone wants to take a look.  Thanks for your help.  


Error:

04-17-2017-10:23 + reposync --repoid=rhel-ha-for-rhel-6-server-rpms -l --downloadcomps
04-17-2017-10:23 Traceback (most recent call last):
04-17-2017-10:23   File "/usr/bin/reposync", line 352, in <module>
04-17-2017-10:23     main()
04-17-2017-10:23   File "/usr/bin/reposync", line 195, in main
04-17-2017-10:23     my.doSackSetup(arches)
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 650, in doSackSetup
04-17-2017-10:23     return self._getSacks(archlist=archlist, thisrepo=thisrepo)
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 687, in _getSacks
04-17-2017-10:23     self.repos.populateSack(which=repos)
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/yum/repos.py", line 324, in populateSack
04-17-2017-10:23     sack.populate(repo, mdtype, callback, cacheonly)
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 165, in populate
04-17-2017-10:23     if self._check_db_version(repo, mydbtype):
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 223, in _check_db_version
04-17-2017-10:23     return repo._check_db_version(mdtype)
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1263, in _check_db_version
04-17-2017-10:23     repoXML = self.repoXML
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1462, in <lambda>
04-17-2017-10:23     repoXML = property(fget=lambda self: self._getRepoXML(),
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1454, in _getRepoXML
04-17-2017-10:23     self._loadRepoXML(text=self)
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1444, in _loadRepoXML
04-17-2017-10:23     return self._groupLoadRepoXML(text, self._mdpolicy2mdtypes())
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1419, in _groupLoadRepoXML
04-17-2017-10:23     if self._commonLoadRepoXML(text):
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1237, in _commonLoadRepoXML
04-17-2017-10:23     result = self._getFileRepoXML(local, text)
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1015, in _getFileRepoXML
04-17-2017-10:23     size=102400) # setting max size as 100K
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 836, in _getFile
04-17-2017-10:23     size=size
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/urlgrabber/mirror.py", line 408, in urlgrab
04-17-2017-10:23     return self._mirror_try(func, url, kw)
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/urlgrabber/mirror.py", line 394, in _mirror_try
04-17-2017-10:23     return func_ref( *(fullurl,), **kwargs )
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 993, in urlgrab
04-17-2017-10:23     return self._retry(opts, retryfunc, url, filename)
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 894, in _retry
04-17-2017-10:23     r = apply(func, (opts,) + args, {})
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 990, in retryfunc
04-17-2017-10:23     fo.close()
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 1667, in close
04-17-2017-10:23     self.opts.progress_obj.end(self._amount_read)
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/urlgrabber/progress.py", line 151, in end
04-17-2017-10:23     self._do_end(amount_read, now)
04-17-2017-10:23   File "/usr/lib/python2.6/site-packages/urlgrabber/progress.py", line 296, in _do_end
04-17-2017-10:23     self.fo.flush()
04-17-2017-10:23 IOError: [Errno 32] Broken pipe

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/aef31c50-5556-4df1-92bd-90e9bdb66bc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

reposync (13K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: cannot run a python script from Jenkins

jerome-2
Not sure but it look like the scripts use IO redirection, which could not be standard output/error inside the Jenkins flow execution. Check if you can spawn a bash shell that run this python script on it's own and exit after. You may want to find a way to check the results into your bash command.  Maybe this will help the script to properly redirect the IO. Again I'm not sure about his but it would be my first guess for this.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a0e63d33-99f7-46b6-baf8-eb4a9f8c5742%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...