def create_credentials_on_jenkins(jenkins_api, _uuid):
cred_exist = has_credentials_on_jenkins(jenkins_api, _uuid)
if cred_exist:
return cred_exist
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
payload = '''json={
"": "0",
"credentials": {
"scope": "GLOBAL",
"id": "%s",
"username": "root",
"password": "123456",
"description": "test",
"$class": "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl"
}
}''' % _uuid
url = jenkins_api._build_url(
'credentials/store/system/domain/_/createCredentials'
)
request = Request(url, payload, headers)
jenkins_api.jenkins_open(request)
return has_credentials_on_jenkins(jenkins_api, _uuid)
评论列表
文章目录