Jenkins does not trigger build after being poked by GitHub - github

I'm trying to integrate Jenkins with a private repository on GitHub.
I have a Multibranch Pipeline job configured with github's SSH URL: git#github.com:user/repo.git. The GitHub plugin is also installed. On GitHub I added the webhook per-plugin documentation.
Now, whenever a change is pushed to the repo Jenkins logs the event, but not start a build.
My best guess is that it happens due to URL mismatch: the job has SSH url, but github seems to send HTTP URL (http://github.com/user/repo). I do not know how to verify or address it.

I have solved my problem by installing the Git Branch Source Plugin and setting up the GitHub source in the configuration.

First check you are able to access git repo from command line like below,
ssh git#github.com:user/repo.git
If it returns "Permanently added the RSA host key for IP address" . Then its fine else check for ssh key added in git.
If above step is correct then proceed to below task
in project url under Github Project in job config give htttp url ( ex : http://github.com/user/repo ).
in repository url under Source Code Management give git url ( ex : git#github.com:user/repo.git ).
For detailed info
https://medium.com/#marc_best/trigger-a-jenkins-build-from-a-github-push-b922468ef1ae

Related

Setting up Weblate to create pull requests

I want to use Weblate to help with the localization of an open source project that is developed on GitHub. I don't have write access to the repositories of the maintainers and have to submit pull requests for the improvements I make. It look as if Weblate supports creating pull requests, but I can't get it to work.
What I've done so far:
Run Weblate 3.4 (in a Docker container) and setup the SSH keys for GitHub access.
Set Docker environment variable WEBLATE_GITHUB_USERNAME to my GitHub username.
Opened a shell session in the Docker container and run hub clone octocat/Spoon-Knife (both as root and the weblate user; this asks for username and password and the clones the repository; the token is also still there after I restart the Docker containers)
Set up a Weblate project.
Set up a component in the project.
Source code repository = upstream GitHub repo (git#github.com:maintainer/repo)
Repository branch = master
Repository push URL = my forked GitHub repo (git#github.com:me/repo)
Version Control System: GitHub (EDIT: added on Feb 10 2019)
EDIT (Feb 10 2019):
After finding out that you have to specify "GitHub" as Version Control System when creating a component, Weblate now tries to push changes to the fork and create a pull request. Authentication of the hub tool doesn't work. When I click on "push" in Repository Maintance I get an error. Somewhere in the stack trace there is this error:
'github.com username: github.com password for (never stored): '
'Error forking repository: Unauthorized (HTTP 401)\nRequires authentication'
I strongly suspect that Python can't open ~/.config/hub. The file definitely exists. Maybe this has to to with how ~ is resolved by Python?
I've figured it out by myself:
The problem is that '~/.config/hub' is resolved to '/root/.config/hub' when Weblate calls the GitHub hub program. However, the user Weblate is running as is weblate, so it doesn't have access to the root's home directory.
I've fixed this by hardcoding '/home/weblate/.config/hub' as the location of the Hub's config file and by making sure the config file is created at this location.

Connecting github repository with my webpage

Hey how to connect my webpage with github repository ,I mean , when I merge pull request it immediately make change in my webpage.I was using github-pages but now I would like include some php and it doesn't work. Thanks for any help.
Manual: after each push to the repo you´d have to pull on your server for the current version. (You don´t want this...)
Automation: first you need a server (linux/ windows) with git installed and clone the repository to your webserver directory (i.e. apache.webserver: var/www/html). Then you need a script which automaticly pulls the new changes to your server and use a webhook to trigger the script. That way you´d have the current version of your repo on the server all the time. (Push --> Webhook triggers script --> Server repo get´s new changes)
Alternative: create NOT a github BUT a git repository hosted on your own server (tuturial for linux only). You could push into it aswell and you´d have the current version of your site on the server without the path over github.

Setting up Jenkins with a remote Github for Minecraft plugins

I am trying to set up Jenkins to automatically build when I push to github. My environment is as follows :
1) I code in eclipse on my laptop. (windows)
2) I push from my laptop to http://github.com/myaccount/plugin
3) My jenkins is on a vps. (windows)
Is it possible to do this?
When inputting my repository, I am getting the following error :
Failed to connect to repository : Could not init C:\Windows\TEMP\hudson53570147835241625tmp
I have force polling workspace enabled, and still getting the error.
It is possible.
In jenkins:
define git SCM for your repo URL
in build triggers choose 'Poll SCM' (without scheduling)
In github
go to your repo Settings->WebHooks and Services
define a webhook to post to http://<your_jenkins_server>/git/notifyCommit?url=<your_repo_url>
Now push to your repo and see your build triggered.

How to connect to github via netbeans?

So I'm trying to connect to github via netbeans and uploading a project.
The steps I have taken:
right click project - initialize git repository
right-click project - commit
right-click project - remote - push...
When I am in the push menu:
specify git repository location:
git#github.ugent.be:brosseel/oefen2.git
private/public key:
Users/Username/.ssh/id_rsa.pub
NEXT>>
I get:
Error : Cannot connect to the remote repository at git#github.ugent.be:brosseel/oefen2.git
How to troubleshoot that error message?
It should work if your repo exist first on GitHub (and https://github.ugent.be/brosseel/oefen2.git doesn't seem to exist).
You need to initialize an empty repo of that name, and then try to push form NetBeans.
You also can use the https url:
https://github.ugent.be/brosseel/oefen2.git
And put your GitHub username and password.
But again, that supposes you have created a repo of that name on GitHub prior to trying to push to said repo.

How to configure Cloudbees Jenkins to trigger build on push to Github

I tried to follow the instructions in this article:
http://developer.cloudbees.com/bin/view/DEV/GitHub+Commit+Hooks+HOWTO
But I have two problems:
It doesn't work. When I push to github nothing happens on the jenkins side. On Jenkins the GitHub Hook log says 'Polling has not run yet.'
The possible cause for this is that I can't specify the git repository as described in this image:
There is no textfield for a public key, nor the other fields. Instead I have the fields
Repository URL, Name, Refspec
Also I can specify a http url (and everything but the triggering works). But if I specify the git/ssh url as in the image I get the following error:
Failed to connect to repository : Command "git ls-remote -h
git#github.com:schauder/degraph.git HEAD" returned status code 128:
stdout: stderr: Warning: Permanently added
'github.com,207.97.227.239' (RSA) to the list of known hosts.
Permission denied (publickey). fatal: Could not read from remote
repository.
Please make sure you have the correct access rights and the repository
exists.
I copied the url from github so a typo is somewhat unlikely.
I verified that I have the github plugin installed (upgraded to version 1.5)
Any hints how to fix or at least debug the problem?
Update answering questions in the comments:
Yes I checked the checkbox 'Build when a change is pushed to GitHub' in the job configuration.
And Yes I setup the webhook in GitHub. When I click the test button there, nothing happens. When I put the url from the webhook in my browser I get a http 500 saying
Not intended to be browsed interactively (must specify payload parameter)
Plus some lengthy stacktrace.
Another Update
I checked the GIT related plugins installed on the Jenkins side. Everything showing their with GIT in the text is installed and at the most current version
Based on Git error message above, I assume you can't be authenticated. Did you add the CloudBees public SSH key on GitHub as described here?
Clarification by OP
The image referenced in the question seemed to suggest that one puts a public key from GitHub into CloudBees. But actually it is the other way round, and also all the labels seem to be changed, so it is kind of difficult to match that screenshot to what you see in CloudBees.
So what I did is this:
in the Job configuration at Cloudbees there is a Public Key (generated by CloudBee). I it in the CloudBees DEV#cloud Authorization section and labeled CloudBees Public Key. Copy that Key.
Hop over to GitHub and go to Settings > Deploy Keys. Add the key there.
go to Settings > Service Hooks > WebHook URLs. Click on the test button. You are not going to see much on the GitHub side.
Hop back to CloudBees Jenkins. From the main page of the job go to the ´GitHub Hook Log´. There you should see something like:
Started on Mar 15, 2013 8:55:14 AM
Using strategy: Default
[poll] Last Built Revision: Revision 581acde89a62317fd8dabaa3f4c6025d1c9dd413 (origin/master)
Fetching changes from the remote Git repositories
Polling for changes in
Done. Took 0.34 sec
Changes found
And your job should start.
If the last line says No Changes this means the hook worked, but you already build the current version so the build is not triggered again.
If you still have problems, have look at https://wiki.jenkins-ci.org/display/JENKINS/Github+Plugin#GitHubPlugin-TriggerabuildwhenachangeispushedtoGitHub under 'trouble shooting' it tells you how to set up logging on the jenkins side. With this I get all kind of stuff in the Jenkins SystemLog.
I've just published a tutorial on continuous integration for Play applications hosted on GitHub using CloudBees. This is intended to provide a comprehensive guide:
http://ics-software-engineering.github.io/play-example-continuous-integration/