Issue
I am able to use Jenkins.instance.getJob('job-name').getAuthToken()
in order to get the auth token that is already saved for the job. But I didn't find any setter function to set that value. Nor do I know how to actually enable the Trigger builds remotely (e.g., from scripts)
option programatically. The code online is erratic at best (for me that is). Any help would be much appreciated. Thanks.
Solution
I had tried editing the config file of the job using this answer. Then I found out I could do the following:
AbstractItem it = (AbstractItem)Jenkins.getInstance().getItem('url-trigger-test')
if(it.authToken instanceof hudson.model.BuildAuthorizationToken) {
println(it.authToken.getToken())
it.authToken = new hudson.model.BuildAuthorizationToken('anotherToken')
it.save()
}
Hope this helps someone. Thanks.
Answered By - Ciado
Answer Checked By - Candace Johnson (JavaFixing Volunteer)