-
-
Save Alxkkor/0882542c79d4ea5b373d5ebbe9eeea04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
except ImportError: | |
sys.stderr.write("\nError: please install python requests module first: http://www.python-requests.org/\n") | |
from requests.auth import HTTPBasicAuth | |
from string import Template | |
import getpass | |
import json | |
currenttime = time.asctime(time.localtime()) | |
urllib3.disable_warnings() | |
LARRY_TOKEN = "a2310b1f6b7d584495ebbf9b347244e9fee" | |
TEMPLATE_FILE = "plugin_usage_template.html" | |
DETAIL_TEMPLATE_FILE = "detail_plugin_jobs_template.html" | |
INDEX_HTML = "index.html" | |
DETAIL_DIR = "detail" | |
SHALL_DETAIL = True | |
LIMIT_JOBS = 20 | |
SYSTEM_VIEW_CFG = "views.config_xml" | |
prop = { | |
"user" : "larry", # will set to current user as default | |
"token" : LARRY_TOKEN, | |
"dir" : "jenkinsBackup", | |
"config" : "jenkins.cfg", | |
"passwd" : False, | |
"url" : "https://jenkins-server/", | |
} | |
def withoutPort(url): | |
return re.sub(r'\:\d+([^\d]|$)', r'\1', url, count=1) | |
def get_job_config(url,name): | |
config_url = "%s/job/%s/config.xml" % (url,name) | |
#with vcr.use_cassette('fixtures/debug3.yaml'): | |
# j = jenkins.Jenkins(url, 'rdccaiy', 'a231094d044ca829d367f35829085036') | |
r = requests.get(config_url,verify=False,auth=HTTPBasicAuth(prop["user"], prop["token"])) | |
if r.ok: | |
return r.text | |
else: | |
raise Exception("can't fetch data from %s using user: %s, token: %s" % (config_url,prop["user"], prop["token"])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment