How to authenticate SVN Repository through API - jenkins

We are developing a replica of Jenkins and we have a need to authenticate SVN & GIT repository URLs. I see Jenkins is able to do it through allowing the user to have credentials created(POST) and validated through(GET) a call. However, I am unable to validate the SVN/GIT repo without the jobname.
I am able to fetch the global credentials added to Jenkins. But they are only retrieved for job basis. So if I want to see the list of credentials of a particular job, I can do it using the following JSON.
http://${JENKINS_URL&PORT}/job/${JOB_NAME}/descriptorByName/hudson.scm.SubversionSCM$ModuleLocation/fillCredentialsIdItems
But I would like to fetch the credentials without depending on the job name. Please let me know if I have to provide any more information. Any help is much appreciated.

Related

Parameterized Remote Trigger plugin doesn't respect Build Token Root

I'm trying to trigger a job from one Jenkins (A) on another one (B). I've installed 2 plugins:
Parameterized Remote Trigger
Build Token Root
My issue is, that I'm able to trigger build on Jenkins (B) using for example curl and token only, which means the Build Token Root plugin is working as expected, but Parameterized Remote Trigger seems to don't respect this.
I probably should mention that I've tried different auth options, Trust All certs, etc.
My Jenkins (A) config:
Logs are the same with and without Build Token Root support enabled.
Logs I'm getting:
I was able to get this working by allowing Anonymous users Overall Read and Job Read access. It appears this is necessary because the Parameterized Remote Trigger plugin attempts to call additional APIs apart from just the /build and /buildWithParameters and those calls are the ones that fail.
It makes sense that, in order to have the default blocking capability, you need to call additional APIs to poll, but even setting blockBuildUntilComplete : false did not fix the issue. Considering that Parameterized Remote Trigger plugin plainly says it "plays well" with the Build Token plugin in its documentation, it really is not an easy feat to make them work together.
In my opinion, using the two together isn't an ideal solution because of the necessity for allowing unauthenticated users to browse your jenkins instance via the ui - I suspect you could (although I haven't tried it) get an API Token for a user with only Overall Read and Job Read access instead of giving all Anonymous Users the rights, but this includes the overhead of managing a user and an API Token, which defeats our primary motivation to use the Build Token plugin in the first place.

Additional Identities Plugin - how to configure?

I'm struggling with duplicated users in my Jenkins and Not sending mail to unregistered user ... problem.
I installed the plugin as per this answer but cannot configure it properly by reading the plugin documentation.
My jenkins collects data from Active Directory and some users have duplicated entry, e.g.:
john.doe, john.doe#mycompany.com -> duplicated user which is detected by Jenkins
doej, john.doe#mycompany.com -> correct user which is used when logging in
Jenkins after collecting responsible people from git changes in job ends with
Not sending mail to unregistered user john.doe#mycompany.com
I tried adding additional identity to user doej by setting:
Identity: john.doe#mycompany.com
Realm: <empty>
but it doesn't work.
How should I configure correctly the Additional Identities Plugin?
Seems it's not possible to configure the additional identity plugin in Jenkins for merge the duplicate user
As Jenkins is missing a way to ensure users unicity(unique) since they are created from various sources: authentication method (LDAP in my case), code commits (Subversion, Mercurial, Git, ...).
Depending on the way the user is retrieved by Jenkins (from a commit on a given SCM or its authentication), multiple identities are created for the same real user.
As a consequence, some features are not fully or badly working (login, notifications, user's builds, continuous integration game, ...) and configuration of users is a pain as it must be done multiple times for each real user.
Still the required features are:
a merging features. Allow to merge multiple Jenkins users into a single account.
a user pattern per SCM. Allow to choose how to extract a username from a commit for each SCM and how to optionally match existing one instead of creating a new user.
an id pattern per notification type. Allow to define how to generate the default id used for notification from the user data (from his jenkins id, his name, his scm id, ...): for instance, his mail or his jabber id, ...
Reference: [JENKINS-10258] Allow users unicity - Jenkins Jira
Solution is Jenkins 1.480 but this is still in Vulnerabilities state and have bug as well.
Jenkins 1.480 introduces an extension point to resolve jenkins user "canonical" ID when searching for user in Database by id or full name. This plugin uses this extension point to let user configure external identities as user properties.
You can reach out to Jenkins community or Support team to know the status or when they will final release

How to get all running builds for current user in jenkins api?

I know how to get all builds from a specific job and know how to get the list of builds from the current user in the Jenkins UI by going to https://jenkins.${domain}.com/user/${username}/builds, however, there doesn't seem to be an API for that specific address because if you go to https://jenkins.${domain}.com/user/${username}/builds/api it comes up with a 404.
Is there a way via the api to query all of the builds for a specific user?

Dashboard using output results from Jenkins API

I am new to Jenkins API. I just had assignement in company where PL asked me to create a new job in Jenkins where I will run all the testing,build related things on my code and it should create dashboard where all figures and graph should be shown. He said that its feasible. Can anyone please guide me to do so.
Checkout Sectioned-Vew-Plugin.
Create a Job on Jenkins and add /api after the Url. You could see the API Information related to the Job you have just created. The API will contain the Get End points for Retrieving the data. Its available in JSON as well as XMl which you can parse and use as the source of Info for your dashboard. You can also trigger a new Build by using the Post API.

How to pass through Jenkins credentials?

I'm trying to follow the advice given in Set Hudson Build Description via Web API but I'm getting a 403 presumably because the request has to be authenticated. Since the script is being run from an authenticated Jenkins session, how do I pass those credentials through?
Looks like you need to pass user and api token in your request. Here's an example (not in Python, but I guess you can manage the translation).
Use the 'Execute system Groovy script' Build task which executes in the same VM so you don't have to re-authenticate or manually pass through tokens or credentials.

Resources