Jenkins and Bitbucket.org webhooks 404/200 error - jenkins

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.

Related

can't connect webhooks bitbucket to 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

Jenkins GitHub Webhook not triggering builds

I have a Jenkins server (2.249) setup and I have connected my GitHub account and tested the connection and it works fine, but for a normal pipeline job where you enter the GitHub repo url, Jenkins seems to add an extra slash at the end? So I can't get my normal pipeline job to build on a push event, I've checked the logs and it says:
skipped [repo-name] because it doesn't have a matching repository.
So I've starting to think its because Jenkins is adding an extra slash at the end of my repo url? The webhook on the GitHub side works as it gives back a green tick and it works on another multibranch job for push events, just not the normal pipeline jobs.
Don't know if the problem is still on after more than one year but because I've just faced the same issue, here is an answer that help me to understand : https://serverfault.com/a/884717
Just to resume the answer : you have to complete the git part (scm) of your Project Configuration :
For my part: as the project is a private one, in an organisation that I can't update to add a personal token (as I'm not the owner of the resource - organisation), I choose to use the git+ssh url with a ssh key access to this repo. The next trick for github is to add the github's IPs to the jenkins user know_hosts file !
The reason behind the need to add twice the repository url is obscure. But I could only see that in https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/com/cloudbees/jenkins/GitHubRepositoryNameContributor.java#L113 the method parseAssociatedNames will try to get the Jenkins'job associated names from :
com.cloudbees.jenkins.GitHubRepositoryNameContributor$FromSCM
com.cloudbees.jenkins.GitHubTrigger$GitHubRepositoryNameContributorImpl
org.jenkinsci.plugins.github_branch_source.GitHubSCMSourceRepositoryNameContributor
I think the third one is for multibranch pipelines. I don't really know for the second but indeed the first one is fromSCM configuration !

Trigger Jenkins job via Slack command - 403_client_error

I'm trying to do a pretty simple thing I believe - trigger a Jenkins job from a slash command in slack. I want to type /dump in slack and that should trigger particular jenkins job. I'm using Slack Slash command to achieve this and the setup is very simple - type command, type URL, select POST/GET method.
I tried two methods - first was to use Build Authorization Token Root Plugin following this tutorial - in this case I configured Slack slash command to make GET request on the URL: http://jenkins_url:8080/job/db-dump-setup/build?token=MY_TOKEN - If I put the URL to my browser, the job gets triggered, if I run the /dump command, slack responds with:
slackbot [3:41 PM]
Darn - that slash command didn't work (error message: `403_client_error`). Manage the command at text.
The second approach I tried was following this tutorial. In this case I created new user in Jenkins and got API token. When running this command from my terminal: curl -X POST http://USER:TOKEN#slack_url:8080/job/db-dump-setup/build, the job gets again triggered, however when configuring the Slack slash command with the same URL and making POST request, I get the same error: 403_client_error
I tried to google this specific error but didn't find anything useful, also there are no more details for the error or any logs which could help me to troubleshoot this further.
Anyone run into something similar and knows how could I get this resolved?
I was able to resolve this so answering my own question in a case someone else runs into this. In order to make the first case work (Using the GET request), I had to enable the "Allow anonymous read access" in Jenkins, in Manage Jenkins -> Configure Global Security as per the screenshot below.
You should not need to enable anonymous access.Your jenkins requires authentication. Update your url like http://user:auth-token#jenkins-host:port.Auth token can be generated at the following URL JENKINS_HOST/me/configure

user/project names in CircleCI 1.1 API

I'm trying to get information from the Circle CI REST API.
I can get make any call that doesn't require a vcstype/username/project to work properly such as /me?circle-token=<token>, however I can't get any that require vcstype/username/project to return anything except a 404 error.
In particular:
What is my username? Is it my github username (SuperTango)? I login to circleci with github, and the circleci "account settings" webpage doesn't actually show me any username. The /me API response has a field called login (which in my case is also "SuperTango"), but it doesn't have a field named username
What is the actual project name I should use here? Is it the name of the github project?
When trying to get a list of builds for a particular project, I have the following:
my username is "SuperTango"
i'm a github user
the project in github is called "funkware/funkware_app"
The docs say the url is:
GET: /project/:vcs-type/:username/:project
Build summary for each of the last 30 builds for a single git repo.
The base URL for all circleCI API requests is
https://circleci.com/api/v1.1/
Here's what I'm trying for the URL:
https://circleci.com/api/v1.1/project/github/SuperTango/funkware/funkware_app?circle-token=<token>
This URL is not working for me. I get back a 404 response with the webpage. As I mentioned up top, I can make the "/me" call, so I know my circle-token is correct. I don't know what else to try.
This question was already answered in the CircleCI Doc's GitHub project. I'll answer again here for completeness.
What is my username? - This is the username for your repository on GitHub or Bitbucket. This could be a personal user account, or it can be an organization username.
What is the actual project name? - This is the repository name on GitHub or Bitbucket.
For the example provided, the API call would be: https://circleci.com/api/v1.1/project/github/funkware/funkware_app?circle-token=<MY_TOKEN>.

Workflow action not executed in Jira Issue Updater plugin

So currently I am trying to progress my JIRA workflow with the Jira Issue Updater plugin in Jenkins. Attached are my config screenshot and my workflow. However i get this error when I execute a commit triggered build.
JIRA Update Results Recorder
Unable to connect to REST service
java.io.IOException: Server returned HTTP response code: 400 for URL: http://*******:9055/rest/api/2/search?jqlFinished: SUCCESS
This does not have any effect on my Jira workflow.
Thanks for the help in advance and let me know if more information is needed.
Hadi
EDIT: I got a 404 meaning the JQL is incorrect, but when I try to use that in incognito mode I get an empty string, However, if i am locally logged in, I get all issues in xml format.
Workflow
Jenkins Jira Config
I ended up using the JIRA plugin instead.
I used Progress JIRA Issues by workflow action step after build successful phase.
Attaching a screenshot of the configuration.
I am still trying to figure how to pull the issue number from the commit message for this action.
JIRA PLUGIN CONFIG
This is a following question and answer if anybody else gets stuck:
How can I get JIRA issue number from a commit message in Jenkins

Resources