Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import os
- from elasticsearch import Elasticsearch
- import jenkins
- # change to your here
- jenkinsUrl = "http://localhost:8080"
- elasticUrl = "http://localhost:9200"
- #server = jenkins.Jenkins(jenkinsUrl)
- server = jenkins.Jenkins(jenkinsUrl, username='myuser', password='mypassword')
- es = Elasticsearch([elasticUrl])
- env = os.environ
- body = env.data
- print body
- jobs = server.get_jobs()
- for job in jobs:
- jobname = job['fullname']
- buildinfo = server.get_job_info(job['name'])
- buildnumber = buildinfo['lastCompletedBuild']['number']
- body['JOB_NAME'] = jobname
- body['JOB_URL'] = job['url']
- body['BUILD_DISPLAY_NAME'] = "#" + str(buildnumber)
- body['BUILD_ID'] = buildnumber
- body['BUILD_NUMBER'] = buildnumber
- res = es.index(index="jenkins_env", doc_type='env', id=job['name'], body=body)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement