github-webhook | GitHub WebHook deployable on CloudFoundry | REST library
kandi X-RAY | github-webhook Summary
kandi X-RAY | github-webhook Summary
GitHub WebHook deployable on CloudFoundry
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- HttpHandler is the http handler
- flattenData recursively recursively flattens the flattened map .
- Matches returns true if the trigger matches the event .
- The kingpin constructor
- LoadBytes loads a YAML configuration from a byte array
- Execute runs the trigger
- Start the status loop
- validateTrigger tests that the trigger is valid
- LoadFile loads configuration from a file
- validateSignature returns true if the request is equal to the given payload .
github-webhook Key Features
github-webhook Examples and Code Snippets
Community Discussions
Trending Discussions on github-webhook
QUESTION
In GitHub Enterprise, we have Project A under Organization A. When I submit a PR (pull request) to Project A, the continuous-integration/jenkins/pr-merge
is triggered which runs a Jenkins pipeline to build the code and perform unit tests. This allows us to prevent the PR from being merged into master if the unit tests fail.
For example, this is what I see on a PR for Project A in GitHub that includes a broken unit test:
Now I am trying to configure Project B under Organization B to behave the same way. However, it is not working. This is what I see on a PR for Project B in GitHub that includes a broken unit test:
Notice that Project B's PR did not kick off the continuous-integration/jenkins/pr-merge
.
GitHub -> Settings -> Branches -> Branch protection rules
Project A in GitHub has a branch protection rule for master
with only one setting enabled:
- Require pull request reviews before merging
Interestingly, the "Require status checks to pass before merging" setting is not enabled. Out of curiosity, I enabled it (without saving it) and noticed that "continuous-integration/jenkins/pr-merge" showed up below it as an option.
I configured Project B to have the exact same branch protection rule for master
with only "Require pull request reviews before merging" enabled. Out of curiosity, I enabled "Require status checks to pass before merging" (without saving it) and it doesn't even show continuous-integration/jenkins/pr-merge
as an option. It just says "No status checks found. Sorry, we couldn’t find any status checks in the last week for this repository."
GitHub -> Settings -> Hooks -> Webhooks
Project A in GitHub has a webhook configured with:
- Payload URL
https://jenkins.mycompany.com/github-webhook/
- Content type
application/json
- Let me select individual events: Pull requests, Pushes, Repositories are checked
- Active: checked
I created a webhook for Project B with the exact same settings. After I submitted a PR for Project B, I see a couple of items under "Recent Deliveries" for Project B's webhook with green checkmarks and "200" response codes, so I think it is configured correctly.
CloudBees Jenkins Enterprise
In Jenkins Enterprise, Project A's pipeline is of type "GitHub Organization" and has the following settings:
- API endpoint: kubernetes-cbs-automation (https://git.mycompany.com/api/v3)
- Credentials: [credentials specific to Project A]
- Owner: [Project A's GitHub organization]
- Behaviors: Repositories: Filter by name (with regular expression): Regular expression: [name of Project A's GitHub repo]
- Behaviors: Within repository: Discover pull requests from origin: Strategy: Merging the pull request with the current target branch revision
- Project Recognizers: Pipeline Jenkinsfile: Script Path: ci-cd/jenkins/ProjectA-pipeline.groovy
- Property strategy: All branches get the same properties
- Scan Organization Triggers: "Periodically if not otherwise run" checked: Interval: 1 day
- Orphaned Item Strategy: "Discard old items" checked
- Child Orphaned Item Strategy: Strategy: Inherited
- Child Scan Triggers: "Periodically if not otherwise run" checked: Interval: 1 day
- Automatic branch project triggering: Branch names to build automatically: .*
I created an item under Project B in Jenkins Enterprise of type "GitHub Organization" with the same settings (except any settings specific to Project A were replaced with the appropriate Project B specific settings).
What is wrong/missing?Given that GitHub PRs for Project B are failing to launch the continuous-integration/jenkins/pr-merge
, it seems like there is some configuration that I am missing. Unfortunately, our GitHub/Jenkins admins have not been able to figure out what is wrong.
UPDATE
We have confirmed that Project B is actually launching a build on the Jenkins agent when a PR is submitted. The problem is that GitHub is not showing the continuous-integration/jenkins/pr-merge
on the web page for the PR. We need that so the PR can be blocked if the build fails, and also so that we can quickly see what went wrong.
ANSWER
Answered 2021-Dec-08 at 20:18Posting as answer the resolution we got in the comments.
The issue was that the user who's token was used in Jenkins did not have the right level of access to post status checks on the repository.
Differences between the Orgs and Projects
- OrgA/ProjectA - the user is a Member of the organisation (OrgA) also added in the Collaborators section of the repo with Read access, as well as member of a Team with Write access on the repo itself (ProjectA).
- OrgB/ProjectB - the user was a Member of the organisation (OrgB) and also in the Collaborators section on the repo itself (ProjectB) but with Read access.
This caused the issue on projectB status checks not being populated with Jenkins' information from the builds:
continuous-integration/jenkins/pr-merge
missing from the status checks of GitHub repository.
Summary:
When setting up a connection between GitHub and Jenkins we need to provide the user holder of the token with the required access.
In this case we want to update the github status which needs Write access level:
The token of the user should have scope repo:status
QUESTION
I used the following helm chart to install Jenkins
https://artifacthub.io/packages/helm/jenkinsci/jenkins
The problem is it does't build docker images, saying there's no docker. Docker was installed on host with sudo apt install docker-ce docker-ce-cli containerd.io
ANSWER
Answered 2021-Apr-08 at 20:25You are running Jenkins itself as a container. Therefore the docker command line application must be present in the container, not the host.
Easiest solution: Use a Jenkins docker image that contains the docker cli already, for example https://hub.docker.com/r/trion/jenkins-docker-client
QUESTION
Background:
I'm developing a custom AWS github-webhook via Terraform. I'm using AWS API Gateway to trigger an AWS Lambda function that validates the GitHub webhook's sha256 signature from the request header. If the lambda function successfully validates the request, I want a child lambda function to be invoked via the async invocation destination feature provided by Lambda.
Problem:
Even though I've configured the async invocation with the target child Lambda function, the child function is not triggered when the parent Lambda function is successful. This is reflected in the fact that the child Lambda function's associated CloudWatch log group is empty.
Relevant Code:
Here's the Terraform configuration for the Lambda function destination:
...ANSWER
Answered 2021-Mar-22 at 23:37From your description it seems to me that you are invoking parent function synchronously. Lambda destinations are only for asynchronous invocations:
You can also configure Lambda to send an invocation record to another service. Lambda supports the following destinations for asynchronous invocation
So you have to execute your parent function asynchronously for your child function to be invoked.
QUESTION
I am trying to verify the Github webhook secret, but each time I trigger an event in Github, the value of req.headers['x-hub-signature'])
changes, which doesn't make sense.
ANSWER
Answered 2021-Feb-16 at 13:32req.headers['x-hub-signature'])
is not a hash of the secret, but req.body
signed with the secret. That is why it is different on each event.
QUESTION
I'm trying to use a post-receive git-hook to automate the deploy of a simple maven project by triggering a Jenkins pipeline I set up. The source is hosted on a GitHub repo while Jenkins on a container running on my PC. So far, the hook is not triggered after I push to master branch.
Thing is if I try and run the script manually it just works! I also tried setting chmod +x with Git Bash (after all I'm on Windows) to the post-receive file, unfortunately without success: the hook still does not get triggered. What might be the issue?
I already tried looking for answers on similar topics here on stackoverflow, but nothing solved my issue. FYI, below the post-receive script (nothing fancy, as you can see):
...ANSWER
Answered 2021-Feb-06 at 15:19A post-receive
hook is run on the server side, not on the client side. That means that it's run at GitHub, assuming you're pushing to GitHub, ant not on your local machine.
Normally, you'd want a GitHub webhook to notify you of the push event, but you cannot use one here because the machine is running on localhost and such an event has to be able to on a public IP address since GitHub has to send an HTTP request to it.
QUESTION
I have setup Jenkins and integrated with Github, and I am able to trigger builds on "Freestyle Projects" from a github webhook, however I have been unsuccessful in triggering one using the "Pipeline project".
In the logs (/log/all), I can see that my Jenkins instance is receiving the PushEvent from Github:
...ANSWER
Answered 2020-Aug-18 at 19:03I checked off the "Lightweight Checkout" in the last section of the Pipeline, ran a manual build which fixed the issue. Builds are now triggered from Github webhook.
I did not have to setup Github Credentials in the Github Plugin to make this work.
QUESTION
I am setting up webhook integration between a private GitHub repository and a Jenkins build. I configure jobs exclusively using Job DSL groovy scripts (I'm open to switching to another programmatic job configuration mechanism, but I will not accept any answer that requires me to configure jobs manually). II would like to set up a commit status context and a set of custom messages based on build status.
The Job DSL API documentation embedded in Jenkins is not helpful, only giving me this signature: githubPullRequest(Closure closure)
, but not telling me how to construct a suitable closure.
Here are the relevant sections of my job DSL:
...ANSWER
Answered 2020-Aug-13 at 20:29Got it figured. There were several issues, but the crux of the problem was authentication: the various plugins and components accept and require different types of credentials. The setup I have working for me now uses a combination of personal access tokens and SSH keypairs to authenticate to GitHub.
Here's how to set up authentication:
- Generate a new public-private keypair. I did this on my local machine, but you can do it anywhere. The private key file's contents will provide access to your GitHub account, so use appropriate caution when you decide where to keep the file, and clean up after yourself accordingly.
- Go to GitHub and log in as the user you want Jenkins to use to authenticate to GitHub.
- Navigate to
Settings -> SSH and GPG keys
. (Note: that's the user's settings, not a repo's settings) - Create a new SSH key. Give it a name (I named mine after the Jenkins instance) and paste in the contents of the public key generated in step 1.
- Navigate to
Settings -> Developer settings -> Personal access tokens
- Generate a new token. Grant it access to "repo". Make sure you capture the token value somewhere safe -- I saved mine in my password manager. If you lose it, you'll have to go through all of these steps again to make a new one and configure Jenkins to use it.
- My company uses a private GitHub org with SAML-based auth and SSO. If this is true for you as well, make sure you enable SSO on the token for the appropriate org(s).
- In Jenkins, go to
Manage Jenkins -> Manage Credentials
. - Create a new "SSH Username with private key" credential in the System / Global domain. In the "Username" field, enter the GitHub username. For the private key, choose "Enter directly", choose "Add", and paste in the text contents of the private key file generated in step 1.
- You'll give the credential an ID and a description as part of creating it. The ID is used in XML config files, and the description is used in the Jenkins configuration UI. I like to use the same value for both so that the value stored in the XML config files is the same as the value I see in the user interface. IDs can be uppercase and lowercase letters plus separator characters. For best readability, i-like-to-use-kebab-case.
- Create a new "Secret Text" credential in the System / Global domain. In the "Secret" field, enter the token value GitHub generated in step 6. Again, give it a description and an ID.
- In
Manage Jenkins -> Configure System -> GitHub Pull Request Builder -> Credentials
, choose the token-based credential you created in step 9.
Here's the Job DSL that worked for PRs, using the jenkins-ghprb
plugin:
QUESTION
I set up the Github webhook in Jenkins and I created a job with the following configuration:
However, every time I push something from any branch, the job build a new version (using the branch which I specified).
I set up the job by reading some related questions on Stackoverflow but all those questions are quite old and without a clear solution:
GitHub WebHooks triggered globally instead of per branch
Trigger Jenkins job on GitHub PUSH to specific branch
Is it possible to trigger Push only from a specific branch?
...ANSWER
Answered 2020-Feb-19 at 11:22You are using a GitHub Webhook to trigger a preconfigured job. Your Job has the Branch "JENKINS-TEST-AUTODEPLOYMENT" hardcoded, so it will always build this branch only, no matter which branch you are pushing on GitHub.
How about using GitHub Branch Source Plugin? With this Plugin, Hooks will be auto-created in github for the corresponding repos. Each Branch will have a job in jenkins, which is also auto-created as long as you have a Jenkinsfile inside your Repo. With this your desired state should be easily achievable.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install github-webhook
Make sure you've read and followed the pre-requisites
Clone this repo
Run ./vssh. This will ssh into the disposable vm
Run script/cibuild to run the build
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page