can't connect webhooks bitbucket to Jenkins - jenkins

I am configuring Jenkins and webhook like this but my web-hooks are not working.
here is my webhook configuration
but I have errors like
enter image description here
what i do?

Did you generate the credentials from bitbucket? if so, then you must give it all the permissions and generate your job with those credentials
In the image I give access to everything to the user for the repository, try to do something similar and validate the url

Related

Jenkins and Bitbucket.org webhooks 404/200 error

I've been struggling with a webhook configuration for quite some time now and would to reach to you all for some help.
I have configured a webhook in my bitbucket repo to push to jenkins so that jenkins can receive the notification and begin a build of the project.
At first we had some networking issues, which have been corrected. i then started to get a 403 error (crumb issue). After some research i was able to add my login and API token to the webhook url and now getting a 404 error. The url cannot be found.
my webhook url looks something like this.
https://username:apitokenhere#serverwherejenkinsis.com:8080/projectname/bitbucket-hook/
404 error
But when i use the webhook URL
https://username:apitokenhere#serverwherejenkinsis.com:8080/bitbucket-hook/
I get a 200 message
Is there a config file that i need to change within jenkins to "listen" to that URL? my project is build properly with the option of "bitbucket webhook trigger" selected. I have also selected "Poll SCM" where i found some sites suggesting this option. But when i push a commit on my repo, i dont get any feedback from jenkins.
Any help is greatly appreciated.
I wanted to post an update as i have figured out what my problem was.
the webhook url did not need my credentials to end the bread crumb error. in fact the hook url is pretty basic.
https://serverwherejenkinsis.com:8080/bitbucket-hook/
I did not need to have the project name in the URL. ALSO, the project name in jenkins needed to match exactly what the project name is within bitbucket.

Bitbucket Server - How to get the Bitbucket Server instance

I'm new to Bitbucket Server.
Currently, I'm trying to configure a Jenkins job to build my repository, which is located in my personal space of Bitbucket Server (I'm not admin of BitBucket Server).
I followed the video here: https://www.youtube.com/watch?v=0-FugzVYJQU.
Inside Jenkins setting, I have put the URL to my company bitbucket server, personal access token, Credentials as per hint from Video... But the connection still fails.
My question is:
1 - Do I need the admin right of Bitbucket Server to setup these procedures or did I configure something wrong?
2 - If possible, how to get the Bitbucket Server instance when I don't have the
admin right of Bitbucket Server?
Sorry English not my native language.
Thank you for your help :)
Jenkins Setting - Bitbucket Server instances entry
Regarding your question 1,you don't need any admin access to bitbucket server to setup this procedure.If you are cloning from any repository, you need to make sure that the credential you are using, should have at least read access to particular repository.
For your second question, if you are setting up any jenkins job and Bitbucket team is different, you need to ask them for url or IP. Even you dont know ip, bitbucket server URL should be fine to connect with as long you are using correct credentials.
There can be multiple issue like firewall/no connectivity/security rules if jenkins is not able to connect though you are using correct credentials.
1 - Do I need the admin right of Bitbucket Server to set up these
procedures or did I configure something wrong?
You do not need admin rights of Bitbucket Server. You can add your own personal access token(PAT). Make sure your PAT has admin access.
If possible, how to get the Bitbucket Server instance when I don't have the admin right of Bitbucket Server?
You have to configure your Bitbucket instance manually. Its explained from here in the video.
If your repository is in your personal space, make sure while creating a job, the project name is ~<yourusername>. Example ~jsmith. Repository name will be populated using this.
Regards,
Bitbucket Server Developer

How to see who modified global credentials in Jenkins

I have a Jenkins server with multiple users that are able to create and modify Global credentials. Is there any way I can audit and see who did what with the credentials - who modified them, who added new creds, etc. Preferably, presented in nice way similar to Job Config History plugin. Thanks
I had a similar question a few days ago. You can use the Audit Trail Plugin (GitHub) to audit changes to credentials. It logs the HTTP requests that modify credentials. However, it doesn't have a "config history"-style visualisation.
(Soon, it may also be able to log what jobs access the credentials)
You can do that using the Job Configuration History Plugin.
Link should be something like:
https://your.jenkins.url/jobConfigHistory/history?name=credentials
What I noticed is that all changes are shown as if they were been done by 'System' - though they all were done by a specific user.

Get Project's Credentials using Jenkins API

I'm building a Jenkins plugin that one of the features is to commit and push some files generated during the build. I already have the code to commit and to push (using Git client from org.jenkinsci.plugins), however when I execute
PushCommand push = gitClient.push();
push.ref(__MY_BRANCH__);
push.to(new URIish("origin"))
push.force();
push.execute();
I get an error not having permissions to push. So, my question is: how can I re-use the credentials of a project to proper configue gitClient or the pushCommand ?
--
Thanks,
Jose
You need to provide credentials to the GitClient.
For example, here you can see the Git plugin calling the GitClient#addDefaultCredentials() method, using credentials obtained from CredentialsMatchers.
You mention you want to re-use the credentials from the same job so — assuming that the Git plugin has been configured with those credentials — your plugin should have access to the AbstractBuild where you can use something like build.getProject().getScm()​.getUserRemoteConfigs().get(0)​.getCredentialsId to fetch the configured credentials ID.
You'll need to cast the SCM to GitSCM, but otherwise that should work fine.

Jenkins & Bitbucket: Build on link

I'm trying to bring up the bitbucket -> jenkins link. But i've no change, tried it in different settings (see on the pictures)
it works if i call
http://URL/jenkins/job/PROJECTNAME/build?token=buildfromjenkins
May you know wheres the problem?
Jenkins Config (working)
Configured Link
Configured a Service
Do not add token parameter in the endpoint. Remove the parameters in the endpoint URL and add your token in Token box. Then It will work.

Resources