REST API Forbidden

47 views
Skip to first unread message

Neil Hayes

unread,
Aug 31, 2015, 5:20:33 AM8/31/15
to Jenkins Users

I have Jenkins running on Windows, with Jenkins own database and security enabled, Roles based.

Each developer has an  application on their desktop where they can select a set of tests to run, all stored in TFS and SQL server, when they have chosen their required tests a C# COM aware dll is called to fire off the required job using a user and token and the REST API

All developers use the same user and token (It's hard-coded into the application).


I use this code below wrapped in a try catch.

    var authInfo = User.TrimEnd() + ":" + Token.TrimEnd();
     authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
     System.Net.WebClient webClient = new WebClient();
     webClient.Headers.Add("Authorization", "Basic " + authInfo);
     webClient.UploadString(URL, "");


The jobs fire and all is well.......then suddenly at some stage during the day or week the serve will return an error 403 Forbidden (C9). This the breaks for every other developer because we are using the same user name and token.

If I go into Jenkins and delete the user and re-add it with the exact same name, it picks up the original token....everyone can work again. I don't see anything in the Jenkins system log

Questions & Suggestions.

My C# is not great, if there is a better example of C# I'll happily give it a go.?

How can I trap the cause of this Jenkins user going into forbidden mode?

Is there another way to "release the lock" shall we say?

Regards

Neil
Reply all
Reply to author
Forward
0 new messages