jenkins-community-slave: use requests library to download slave.jar
Do not mix two different HTTP libraries in one script. This fixes a warning: /var/lib/jenkins/slave.py:82: DeprecationWarning: URLopener style of invoking requests is deprecated. Use newer urlopen functions/methods This simple implementation has the disadvantage that it stores the whole file in RAM, but this isn't an issue for the 1.5MB slave.jar.
This commit is contained in:
parent
5232428b19
commit
6b3b5e706e
@ -2,7 +2,6 @@ from jenkins import Jenkins, JenkinsError, NodeLaunchMethod
|
|||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import urllib.request
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
import shutil
|
||||||
import requests
|
import requests
|
||||||
@ -34,8 +33,9 @@ def slave_download(target):
|
|||||||
if os.path.isfile(slave_jar):
|
if os.path.isfile(slave_jar):
|
||||||
os.remove(slave_jar)
|
os.remove(slave_jar)
|
||||||
|
|
||||||
loader = urllib.request.URLopener()
|
r = requests.get(os.environ['JENKINS_URL'] + '/jnlpJars/slave.jar')
|
||||||
loader.retrieve(os.environ['JENKINS_URL'] + '/jnlpJars/slave.jar', '/var/lib/jenkins/slave.jar')
|
with open('/var/lib/jenkins/slave.jar', 'wb') as f:
|
||||||
|
f.write(r.content)
|
||||||
|
|
||||||
def slave_run(slave_jar, jnlp_url):
|
def slave_run(slave_jar, jnlp_url):
|
||||||
params = [ 'java', '-jar', slave_jar, '-jnlpUrl', jnlp_url ]
|
params = [ 'java', '-jar', slave_jar, '-jnlpUrl', jnlp_url ]
|
||||||
|
Loading…
Reference in New Issue
Block a user