How can i update a jenkins job using the api

前端 未结 6 523
青春惊慌失措
青春惊慌失措 2020-12-24 07:47

I have to create/update a jenkins job using its api because all of my jobs are using parameters which are also used by other scripts and I am trying to centralize the script

6条回答
  •  孤独总比滥情好
    2020-12-24 08:17

    You could use python like this:

    from jenkinsapi.jenkins import Jenkins
    jenkinsSource = 'http://10.52.123.124:8080/'
    server = Jenkins(jenkinsSource, username = 'XXXXX', password = 'YYYYY')
    myJob=server.get_job("__test")
    myConfig=myJob.get_config()
    print myConfig
    new = myConfig.replace('clean', 'string bean')
    myJob.update_config(new)
    

提交回复
热议问题