In one of our project we have to integrate Bitbucket webhook with Tekton pipeline that means whenever developer commits any changes to Bitbucket repository, Tekton pipeline is triggered and will perform several steps to build.
Earlier we have used GitHub webhook with Tekton and it was working fine.
For Bitbucket webhook, we are getting below error:
failed to replace JSONPath value for param pusher-name: $(body.actor.name): name is not found".
I checked the payload coming from Bitbucket webhook and found there is no such field name.
I used bitbucket-push cluster trigger binding plugin.
Can anyone help us to resolve this issue?
You can use tekton triggers and event listener for that.
With BitBucket, the author name should be somewhere in the actor.username, actor.display_name or actor.nickname
Here's a sample bitbucket push payload
You may have other errors. Switching from one git provider to another, you may have to re-do your interceptors, triggertemplates, ...
Meanwhile, it's unclear what you refer to, by "I used butbucket-push cluster trigger ...". Where did you find this? Checking Tekton Triggers samples, there's no author.name. Sounds like your issue relates to GitHub-specific configurations.
Related
I am using jenkins generic webhook trigger git. i want to trigger build only when a push is made on branch which starts with PO.Used optional filter as ^(ref\heads\PO-[a-z0-9_-])+$ but was not working, can someone please help. when Optional filter is blank. the build gets triggered on master branch.
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 !
I'm trying to trigger a Jenkins Pipeline build (NOT MultiBranch Pipeline) when a specific format of tag is pushed to my GitHub repository. So any branch pushed to the repository will trigger a build if it is tagged with a format of Major.Minor.Patch e.g. 123.123.123
I've setup a webhook which works fine and hits Jenkins (I can see it in the Github Hook Log on Jenkins configuration page). But unfortunately it does not trigger the build.
I've tried setting the refspec to:
+refs/tags/*:refs/remotes/origin/tags/*
And I've accompanied this with a branch identifier:
:origin/tags/[0-9]+\.[0-9]+\.[0-9]+
I have read every article I can find, and scoured StackOverflow but I'm at a loss. I can make it work by setting the branch identifier to **/tags/** but this is too open and triggers a lot of redundant builds.
If anyone can assist in achieving this goal it would be massively appreciated. Also, I'm not certain whether I should be using Pipeline to MultiBranch Pipeline to achieve this?
Starting to lose faith that Jenkins is a good choice so before I jump ship please help!
Thanks!
I prefer using the generic webhook trigger plugin
This allows you to assign a token to a specific Pipeline job so that it will be triggered when your GitHub webhook sends a http request the job's corresponding url:
http://JENKINS_URL/generic-webhook-trigger/invoke?token={token-goes-here}
The Github docs describe the http payload content for a push event
You can parse the http payload using a JSONPath expression to obtain the tag string and then filter whether to run the Jenkins job using the Major.Minor.Patch regex
I've not tested it but here's what the pipeline code might look like:
triggers {
GenericTrigger(
genericVariables: [
[key: 'tagString',
value: '$.ref',
expressionType: 'JSONPath']
],
token: 'example-token',
printContributedVariables: true,
printPostContent: true,
// only trigger if tag follows Major.Minor.Patch regex
regexpFilterText: '$tagString',
regexpFilterExpression: '<tag-regex-here>'
)
}
Hoping to gather insight from professionals. My end goal is to trigger a jenkins build whenever a bitbucket pull request happens. If anyone could give me an ELI5(explain like I am 5) answer it would be greatly appreciated. Sorry if this is the wrong format, I am new to jenkins and stackoverflow.
What I have done so far:
Created webhook in bitbucket and gave the url to my jenkins job. example: http://jenkinsURL:8080/job/boulevard-dev/generic-webhook-trigger/invoke?token=myPull_Request_Token
Pull request webhook trigger
In Jenkins, under source code management I have: Source Code Management Settings. This is currently fetching a ton of branches, failing, then building the master branch when the job starts?
For build triggers, other stackoverflow articles have pointed me to the "Generic Webhook Trigger". https://github.com/jenkinsci/generic-webhook-trigger-plugin
I am not entirely sure how this generic webhook trigger should effectively be setup? Hoping someone has experience using it and could explain what is needed.
This is what have seen referenced in other articles.Build Triggers settings Build triggers settings 2
Questions:
What does a correct setup / example of the generic webhook trigger look like?
Currently, my job triggers when a change is made to master or merged to master, how can I specify to my job that I want the bitbucket pull request branch to be built?
Also, I found this, not sure if its related to my issue or not? https://jira.atlassian.com/browse/BCLOUD-5814
As per your requirement, you can trigger a Jenkins build whenever a bitbucket pull request happens by following the below steps, in my case, it's working fine.
Step(1) - Configure Jenkins
(i) Add your bitBucket repo and branch to source code management
(ii) On build Triggers setup Poll SCM to * * * * * for run every minute to check pull request from bitBucket.
Step(2) - configure Bit Bucket Hook
(i) Go to settings and add a new hook, now setup pull request trigger as per your requirement.
Step(3) - Make a pull request and see the new job automatically triggered on Jenkins.
I have a scenario where I'm setting up Jenkins for my app. I have BitBucket set up and firing appropriate webhooks.
I want to start a build whenever a push is made to the repo as well as whenever someone creates/updates a pull request.
I've looked at the BitBucket Plugin. It works good if I have the BitBucket webhook to fire for all pushes.
Then I added the BitBucket Pull request plugin to build on every pull request create/update. So I changed the BitBucket webhook preferences to fire on pushes and PR creates/updates.
Unfortunately, these plugins have conflicting settings, hence they cannot be used at the same time (as per my research, the minute I send custom webhooks from BitBucket, the first one stops working, but the second one works)
Has anyone been able to set this up correctly? Maybe there's a plugin for what I want, but I couldn't find it.
I want to keep writing a proxy in front of Jenkins to manage webhooks the last option, only if there really is nothing I can do.
Thanks for the help!