cannot run a python script from Jenkins

1,317 views
Skip to first unread message

Sam K

unread,
Apr 17, 2017, 1:41:33 PM4/17/17
to Jenkins Users
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
reposync

jer...@bodycad.com

unread,
Apr 18, 2017, 1:56:06 PM4/18/17
to Jenkins Users
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.
Reply all
Reply to author
Forward
0 new messages