def jenkins_connection(): """ Return an initialized python-jenkins object. """ configp = config() try: user = configp.get('rhcephpkg', 'user') token = configp.get('rhcephpkg.jenkins', 'token') url = configp.get('rhcephpkg.jenkins', 'url') except configparser.Error as err: raise SystemExit('Problem parsing .rhcephpkg.conf: %s', err.message) jenkins = Jenkins(url, username=user, password=token) # These "password" and "url" attributes are not formally part of # python-jenkins' API, but they are nice to make available to consumers # (for logging/debugging, for example.) jenkins.password = token jenkins.url = url return jenkins
def jenkins_connection(): """ Return an initialized python-jenkins object. """ configp = config() try: user = configp.get('rhcephpkg', 'user') token = configp.get('rhcephpkg.jenkins', 'token') url = configp.get('rhcephpkg.jenkins', 'url') except configparser.Error as err: raise SystemExit('Problem parsing .rhcephpkg.conf: %s', err.message) jenkins = Jenkins(url, username=user, password=token) # These "password" and "url" attributes are not formally part of # python-jenkins' API, but they are nice to make available to consumers # (for logging/debugging, for example.) jenkins.password = token jenkins.url = url return jenkins
def connect(credentials): """ Since a user can have simple authentication with a single user/password or define a set of IRC nick to Jenkin's users with API tokens, this helper untangles this and returns a connection. If no authentication is configured, just a connection is returned with no authentication (probably read-only, depending on Jenkins settings) """ connection = Jenkins( credentials['url'], username=credentials['username'], password=credentials['password'], ) connection.password = credentials['password'] # try an actual request so we can bail if something is off connection.get_info() return connection
def connect(credentials): """ Since a user can have simple authentication with a single user/password or define a set of IRC nick to Jenkin's users with API tokens, this helper untangles this and returns a connection. If no authentication is configured, just a connection is returned with no authentication (probably read-only, depending on Jenkins settings) """ connection = Jenkins( credentials['url'], username=credentials['username'], password=credentials['password'], ) connection.password = credentials['password'] # try an actual request so we can bail if something is off connection.get_info() return connection