AzureDevops webhook to jenkins fails on unauthorized access - jenkins

Recently i've updated jenkins to build 2.346.3 .
Since then Azure Devops webhook configured for triggering a build by the trigger "code push" fails with the following output:
Failed Sent at: Wednesday, October 26, 2022 10:52:13 AM Message Jamal Hartnett pushed updates to Fabrikam-Fiber-Git:master. Error Message Unauthorized (401)
I've tried to reach microsoft support to solve this..... the savior will not come from their side...
I am using a multibranch pipeline in jenkins.
The token is valid... as far as i see from the documents in jenkins their instructions is to use the "token" parameter in the URL but i don't see any "token" parameter in the URL azure devops sending the webhook to.
Any suggestions? .
I've tried to create new tokens , using CURL to see if the webhook works following the instructions in jenkins documentions which was succesfully performed without any error.

I had this same issue. The fix is to update the server setting in the hook configuration in AZDO from https://build.company.com to https://build.company.com/?token=<USERTOKEN>.
The user token is one generated in a Jenkins user's profile section.

Related

BitBucket Webhook gives Crumb issues while posting to Jenkins

I am trying to setup webhook from Bitbucket to Jenkins but it is failing while testing them crumb issues. This Jenkins is deployed to Kubernetes 1.17 and Jenkins is the latest image 2.249.1 . Even from PostMan I am getting the same issue. I know there is something wrong in Jenkins Setup only.
Error :
Error 403 No valid crumb was included in the request
HTTP ERROR 403 No valid crumb was included in the request
Assuming you are triggering the job as a pre-push script, if its throwing crumb errors, you need to create personalized API token within Jenkins and would need that to be embedded in the API call from Bitbucket to Jenkins.
Please refer this article for generating a token - https://support.cloudbees.com/hc/en-us/articles/115003090592-How-to-re-generate-my-Jenkins-user-token

Gitlab Jenkins Webhook executed successfully but returned HTTP 403 (Authentication required)

My WebHook was successful but jenkins does not build the project.
I checked the gitLab logs where it appears that the weebhook received a 200 response from jenkins
Status 200 WebHook
Check first if this is similar to jenkinsci/gitlab-plugin/issue 375:
You can either add a special user in Jenkins for this and configure the Webhook in GitLab accordingly or
you can uncheck the checkbox "Enable authentication for '/project' end-point" in the GitLab section of the global Jenkins configuration. But this should be unchecked by default.
Better, from Jun Young Lee:
You can set Secret Token as well and I think this method is better than two other options since no credential exposed or no too open policy.
The OP Alejandro Herrera adds in the comments
I am using LDAP for authentication so it doesn't work with the token.
But I already fixed it: I simply added the authentication parameters in the url like this: https://USERNAME:PASSWORD#Serverjenkins.com/github-webhook

Bitbucket pull request builder plugin keeps triggering same commit build

I need to integrate Bitbucket with Jenkins. So that whenever a PR is opened it will trigger a build in Jenkins. Then commit status of the last commit in the PR will be updated as failed or success and this commit wont trigger the build again. (This works beautiful with Github but seems to be a nightmare for me with Bitbucket)
So far I did:
Installed Bitbucket pull request builder plugin.
Set everything up like its described in https://github.com/jenkinsci/bitbucket-pullrequest-builder-plugin#readme
User has write permissions to the repository (we added shh pub key to organization and its in the group that has write permissions)
Problems
Build is triggered over and over again for the same PR/commit
Commit status is not updated on bitbucket
Let me know if I can provide more information.
In my case, the Jenkins URL was set to http://jenkins:8080 and when such a URL was sent to BitBucket via their API, BitBucket returned the error "Invalid URL" (Look in Jenkins Logs: http://yourjenkins:8080/log/all) Which is not handled by the BitBucket Pull Request Builder plugin and thus kept continuously rebuilding all of our pull requests because it thought that build was not in progress. After setting Jenkins URL to http://jenkins.domain.tld:8080/ or http:///jenkins, the BitBucket API started accepting the URL and everything started to work.
But in your case it may be possible that some other error is the cause. You can check your Jenkins Error log to see the failure.
See the following issue: Build status notification fails with Enter a valid URL

Jenkins Multibranch Pipeline - GitHub Enterprise Issues?

I have spent days troubleshooting/researching this issue. I can't seem to figure out what's going on here. I'm trying to setup a multibranch pipeline project pointed at our internal GitHub enterprise servers. The same issue occurs in other project types too like the "GitHub Organization". It's some sort of security issue that I can't figure out.
Let's start with what I know...
I have (to my knowledge) configured the GitHub Plugin configuration correctly with a TOKEN (also configured per documentation)... I can successfully "Verify Credentials" and it comes back successful. http://imgur.com/br13adk
I keep getting this validation issue on the GitHub Enterprise Servers Validation
http://imgur.com/GnffTeV
I can connect successfully to any ONE repository hosted on my enterprise github server. When I try to configure a multi-branch project from a GitHub source, I ALWAYS get BLANK for repositories....
http://imgur.com/2Q9s1mo
I configured a custom logger to see what was going on and it seems like the branch source plugin is always going out to api.github.com...
Jan 25, 2016 11:48:23 AM WARNING org.jenkinsci.plugins.github_branch_source.Endpoint$DesciptorImpl doCheckApiUri
Jan 25, 2016 11:48:23 AM WARNING org.jenkinsci.plugins.github_branch_source.Endpoint$DesciptorImpl doCheckApiUri
Jan 25, 2016 11:54:58 AM WARNING org.jenkinsci.plugins.github_branch_source.AbstractGitHubSCMSource$AbstractGitHubSCMSourceDescriptor doFillRepositoryItems
Server returned HTTP response code: 401 for URL: https://api.github.com/user
Jan 25, 2016 11:54:58 AM WARNING org.jenkinsci.plugins.github_branch_source.AbstractGitHubSCMSource$AbstractGitHubSCMSourceDescriptor doFillRepositoryItems
Server returned HTTP response code: 401 for URL: https://api.github.com/orgs/nhudacin
Jan 25, 2016 11:54:58 AM WARNING org.jenkinsci.plugins.github_branch_source.AbstractGitHubSCMSource$AbstractGitHubSCMSourceDescriptor doFillRepositoryItems
Server returned HTTP response code: 401 for URL: https://api.github.com/users/nhudacin
I've configured the API endpoint for the GitHub plugin (as seen in the first screen shot), for the PR Builder plugin and the credentials are working (or so it seems). I'm thinkin it's a probably with the enterprise API endpoint configuration.
Any help?? I'm going CRAZY here!
I'm having a similar issue as Nick H.
In my production Jenkins instance
Jenkins version 2.17 Latest weekly release with all plugins up to date as of Aug 10 i.e
GitHub Branch Source Plugin 1.8.1
PipelineMultibranch 2.8
I get :
WARNING: Server returned HTTP response code: -1, message: 'null' for URL: https://api.github.com/users/ORG
Even when I have configured the API endpoint on GitHub Enterprise Servers to be http://github.MYDOMAIN/api/v3/
On the other hand, on a fresh local install of Jenkins
with the same configuration I get:
Aug 11, 2016 3:19:14 PM org.jenkinsci.plugins.github_branch_source.GitHubSCMSource$DescriptorImpl doFillRepositoryItems
WARNING: Exception retrieving the repositories of the owner ORG on with credentials USER/****** ( test credentials)
Edit: I found a way to make it work, it was not very intuitive, I found it after browsing the code and matching the strings to the plugin UI
What you need to do is, after you get the Invalid credentials red error press Advanced... button
Then a combo box with the API endpoints defined in the Manage Jenkins-> Configure System -> GitHub Enterprise Servers will appear.
Select the API endpoint for you GitHub Enterprise instance, choose Checkout credentials that have access to that instance and the list of all the repositories will appear.
Save it, and start a Branch indexing discovering the branches that have a JenkinsFile on it.
NOTE: in order to have this working every push a web hook needs to be installed in github Enterprise, you can do that by going
Manage Jenkins-> Configure System -> GitHub and press the second Advanced... button
Now a Re-register hook for all jobs button will appear. Just press that and it should add the hook that will be triggered every time you push into your matching repos.
Hope this helps
I don't have much knowledge about this particular scenario, but in this commit you can see, that they switched from regex validation to anonymous connection to endpoint. And if your server is in private mode, it will fail.

HipChat integration with Jenkins

I'm trying to add the HipChat plugin to my Jenkins builds, but it doesn't post anything.
In the global configuration I've set the HipChat server to api.hipchat.com, added an API token und default room ID, set the build server URL to https://xxx.ci.cloudbees.com/ and the send as name to Jenkins.
In the build job configuration I've tried setting the same room ID and leaving the field blank (so it should use the default). I've activated all notify checkboxes and added HipChat Notifications as the (only) post-build action.
However, I'm not receiving any build updates in the given room. So I've added a custom Jenkins logger, logging ALL from jenkins.plugins.hipchat. For every build I start, I get a single log entry like this:
Aug 28, 2014 6:08:20 PM INFO jenkins.plugins.hipchat.HipChatNotifier$HipChatJobProperty prebuild
Invoking Started...
Any ideas what I'm doing wrong or how I could debug this further?
PS: I'm running on Cloudbees — not sure if this makes any difference.
The Hipchat notifier plugin for Jenkins uses the HipChat API v1, not the newer API v2. I had the same problem while trying to use a v2 token.
Try creating an admin token in Hipchat for Jenkins (e.g., https://my-hipchat-group.hipchat.com/admin/api) instead of creating a room token (e.g., https://my-hipchat-group.hipchat.com/admin/rooms/tokens/665113).
I was able to get the HipChat API v2 token working with a manually built hpi from the https://github.com/yagince/hipchat-notifier-plugin project.
This seems to have been addressed in the 0.1.9 and newer versions of the hipchat plugin at https://wiki.jenkins-ci.org/display/JENKINS/HipChat+Plugin. I'm using it with a v2 API token.

Resources