How to check which Jenkins plugin/service constantly making calls to GitHub API? - jenkins

Our jenkins server (version 2.164.2) keeps making lot of requests to Github so it exceeds the Github API rate limit. Github support team found out that a user-agent string git-credential-manager contributed to 60% of the Api calls. Most of the calls are https://api.github.com/user/subscriptions and the agent is
git-credential-manager (Microsoft Windows NT 6.2.9200.0; Win32NT; x64) CLR/4.0.30319 git-tools/1.20.0 597,376 57.032%
From process explorer, it shows that Jenkins trigger lot of git-credential-manager:
We added some Log Recorders in Jenkins for org.jenkinsci.plugins.github and org.jenkinsci.plugins.github_branch_source but they don't make lot of github calls. Is there anyway to figure out which Jenkins plugins are making those calls?

Is there anyway to figure out which Jenkins plugins are making those calls?
I'm not familiar enough with Jenkins to comment on this, but I can tell you a bit more about the behaviour you're seeing as that might help you identify the root cause.
git.exe is invoking git-remote-https.exe to interact with GitHub over HTTPS, which then invokes git-credential-manager as that's the configured helper script to obtain credentials. git-credential-manager is then invoking api.github.com/v3/user/subscriptions to test if the credential it has (likely stored in the Windows Credential Store) is valid.
https://github.com/microsoft/Git-Credential-Manager-for-Windows/blob/1145b59498378a7ddbccdc45b216e17ef0d0a664/GitHub.Authentication/Src/Authority.cs#L190-L208
I don't believe this is tied to a specific plugin, but more to Jenkins working with private repositories and invoking Git on the machine. If you are working with private GitHub repositories, this could be consuming API calls for the account that is authenticating which results in it being rate-limited.
I'd check for these sorts of operations in your build process:
build setups that don't cache the repository on disk between builds (if that's supported)
builds that that include fetch/push/pull steps (more builds, more API calls)
cloning repositories or submodules on-the-fly in scripts

Related

Deploying configuration via Jenkinsfile to unknown amount of servers

We're setting up multiple more or less static servers in AWS. These are primarily configured via Ansible and that's also the ultimate source of truth when it comes to their existence, grouping, host names and IPs. But then there's Jenkins deploying configuration files to these servers based on new commits added to a git repository.
I'm having an issue with listing the target servers directly in a Jenkinsfile. How shall I proceed? Which are the most common ways of dealing with this?
I understand this is mostly an opinion based topic. But maybe there's a particular Jenkins feature which I don't know about...?
Thank you.
This is very subjective. Following are a few ways to do this.
Store the details somewhere accessible after the Ansible step. Possibly commit to a Github repo and retrieve these details within the Jenkins Job.
Using AWS APIs/CLI to retrieve server details. You can either set up AWS CLI in Jenkins Agent or use something like AWS Step Plugin.
Do an API call to Jenkins after the Ansible script is executed and update the server details in the Job itself.

How to get jenkins pipeline test results into ReportPortal.io instance?

I have an automated Jenkins workflow that runs and tests a java project. I need to get all the data and results that are outputted by Jenkins into Report Portal (RP).
Initially, I was under the impression that you have to install the ReportPortal.io Jenkins plugin to be able to configure Jenkins to communicate with RP.
However, it appears that the plugin will eventually be deprecated.
According to one of the RP devs, there are APIs that can be used, but investigating them on our RP server does not give very clear instructions on what every API does or if it is what is required to get test data from Jenkins to RP.
How then do I get Jenkins to send all generated data to RP?
I am very familiar with Jenkins, but I am extremely new to Report Portal.
ReportPortal is intended for test execution results collection, not for jenkins logs gathering.
In two words, you need to find reporting agent at their github organization which depends on your testing framework (e.g. junit, testng, jbehave) and integrate it into your project.
Here is example for TestNG framework:
https://github.com/reportportal/example-java-TestNG/

Access GitLab Plug-in's API Token from Jenkins Job

I have instances of Jenkins and GitLab which are successfully connected. Part of setting up the GitLab plug-in involves providing an API token. I believe this is used by the plug-in to get details of the commit which is triggering a job.
I need to run a daily Jenkins job which collects some statistics using the API and then (using R) generates a report. So this is not triggered by an event in GitLab.
To complicate issues a little further, the R code will run inside a container (to avoid hving to install R and all the packages on every Jenkins slave),
It does not appear that the plug-in makes the token available to be used in jobs ... and I can see a sane reason for that.
Is it possible to access the API token from the plug-in?
There is a plugin which supports credential injecting (https://wiki.jenkins.io/display/JENKINS/Credentials+Binding+Plugin) to the builds which could be used later as an environment variable. Gitlab api token could be also selected.

Automatically build and validate VS Team Services git pull requests on local jenkins server

I have been struggling with this problem for a few days. I have built successfully my project on Team Services git repository with all tests included, but I was unable to validate my pull requests automatically. Anyway, here' s my project configuration:
https://snag.gy/d49iaL.jpg
https://snag.gy/jWuMNf.jpg
The part that confused me is what should i write in Refspec field for this particular project.
NOTE: I have to do this without service hooks if there's any chance.
It is impossible with TFS for now, where Jenkins could not signal the result of the build which shows up in the code view of the branch.
Supporting Pull Requests
With the "GitHub" or "Bitbucket" Branch Sources, Multibranch Pipelines
can be used for validating pull/change requests. This functionality is
provided, respectively, by the GitHub Branch Source and Bitbucket
Branch Source plugins. Please consult their documentation for further
information on how to use those plugins.
Source Link
Also take a look at this similar question:Validate pull request with jenkins in VSTS and you could vote up the related uservoice to get more attention.

Artifactory Jenkins Plugin

I'm using the Artifactory plugin for my Java projects and also for some RPMs that I'm building (c++).
Some of Jenkins jobs are pushing artifacts using the REST API via CURL.
Is there any way via the plugin and/or via REST, to prevent overriding of an existing artifact (sometimes our versioning mechanism is not working properly, so I need to prevent this scenario)?
You should leverage the permissions for that. In Artifactory "add" and "override" are different permissions. Just prevent the user which pushes from Jenkins from overriding, and you're done.

Resources