How we can trigger jenkins job which takes source code from one repository, whenever a developer push changes to their beanstalk-git repository? - jenkins

I want to run(trigger) my jenkins job whenever a push happens to developer repository.
Firstly,
i'm storing all my automation scripts in my personal GitHub.
All of my developer's code is another GitHub, i.e in beanstalk which is top of GitHub
Now whenever dev's pushes their changes to their repository, then i want trigger my jenkins job which takes source code from my personal GitHub.
So, after some research on it, i came to know Webhooks will help in this.
Bu in my case as per their are two separate repositories, i couldn't able to get what exactly i have to do.
Any solution appreciated.

One of the solution, I can think of is you can build a WebHook and Git integration on your Dev's repository to trigger your Jenkins job, and in the build steps you can perform the check-out of your git repository source code using git commands.

Related

create github pull request from a jenkins pipeline job

I want to create a PR to my git repository from a jenkins pipeline.
I know it's a bit revers flow than the general flow where we trigger jenkins job based on PRs.
But in my case, user will manually trigger a job & I will create clone an existing git repo. After that, will update some files (via the same job pipeline). And then I want these changes to be pushed to my github repo & have a PR ready to be reviewed by the devs.
Is there any way to do this ?
I am trying around hub but want to know if there's any other way of achieving this?

how can i push code in to jenkins and it will automatically deploy code in to github in it possible?

I am new to jenkin's but what i am looking for is as below
1.How to create project or how to push your code in to jenkin's?
2.How it will directly push this code into github's branch?
I have followed some tutorial but nothing is clear.
Please help me.
Jenkins is not a repository, Jenkins is just a CI tool, basically build server, you cannot "store" codes in Jenkins, but yes, it is able to pull codes from repositories and eg. build it. (or push artifact- war/jar/ whatever to some machine via ssh eg.- look for publish over ssh plugin for this)
Create eg. freestyle project, and then take a look into "Source code management" section, there you can choose git, github, svn, whatever.. Will fill credentials and repo URL, then in "Build" step you will choose what you need to do.
For build check this
If you really mean how to push the changes back to repository, than I have found this- its done with git plugin.
I am not sure, but either you didnt understood what the jenkins is for, or you are using not proper name convetions. Hope that helps.
We found this solution works
It uses Add post-build action ⇒ Git Publisher

Triggering CI builds using Jenkins on remote build machine

I am trying to implement CICD with Jenkins. I have my code in git repo. The moment I make a change to git repo files, I wish to trigger a Build that should run on remote machine.
This means If I change a file in Git Repo 10 times, I should have 10 Builds, each build corresponding to one change.
Can anyone tell me how this can be done ?
I tried to make use of post-commit hook, but its not working.
What flavor of GIT? Do you use? If you share you config details of webhook and Jenkins additional info can be provided. Per my experience it is a two step process.
Enable the webhook in GIT
Create a job with appropriate configuration to map to the repository and get triggered on commit

Github Jenkins plugin with Github Enterprise

I have a Jenkins server with the following github plugins:
github-api
github
github-pull-request
I want to trigger a build after a merge (from a PR). This is because I have some build chains that I don't execute when building a PR so after a merge I need to create new deployment packages.
In the enterprise github there doesn't seem to be the same interface (as regular github) for webhooks I don't seem to be able define what events the github plugin (webhook) should listen for so I think its just the default 'push' event. Is this done somewhere else or is it a limitation of the enterprise version?
UPDATE
I have the github plugin working now but its builds for every push if I check the box. This disucssion https://groups.google.com/forum/#!topic/jenkinsci-users/gew5gWVDxw8 suggests that I should be able to use the git scm and github plugin together. Github plugin will register a change, scm plugin will poll server to determine if this change was tho the watched branch. I also tried this suggestion How can I make Jenkins CI with git trigger on pushes to master?
When I try and configure this no branch is ever built!
At least for me it's not exactly clear from your question what you actually exactly want.
It sounds like you only want builds to be triggered if there are some new commits on github on a specific branch.
If this is all you're looking for, you can just setup a webhook (Jenkins (Github Plugin)).
In you Jenkins job, just specify the branch you're tracking (Branches to build).
Assuming you setup github's hoock to jenkins correctly, this should trigger your build job on each commit on github enterprise.
If your hook doesn't seem to work: To check if and what your github server actually would send to your jenkins server, you can temporarily replace the url to your jenkins server in github's webhook with something like requestb.in (this will let you inspect github's hook payload)

Pre-checked RoR builds with Git and Hudson?

On .NET projects, I've used TeamCity and Subversion to run pre-checked builds.
For those unfamiliar with pre-checked builds, the idea is that when you commit, a build is run with your changeset against trunk.
If that build passes, then your changeset is applied to trunk. If it doesn't pass, you're notified and can try again.
That way, builds from trunk should always be green, and no-one else on the team is interrupted by build breakage.
My question is: has anyone achieved a similar workflow on a Ruby on Rails project, using Git and Jenkins (a.k.a. Hudson)? If so, could you please share some hints / tips / documentation?
You might want to have a look at a Jenkins/Gerrit combination. Gerrit is a code review system that you can setup so it will not push your commit to master unless your commit is approved. You can set it up so that Jenkins first has to approve it.
We are starting to use it for a C++ project where Jenkins first tries to build the patch, if it succeeds it is pushed to the main repo. This also doesn't stall git on the client side.
http://jenkins-ci.org/
https://wiki.jenkins-ci.org/display/JENKINS/Gerrit+Trigger
To truely do this, you want to use a Git pre-receive hook. An excellent one (which runs PHP tests when code has been pushed) is detailed in: a blog post on codeutopia.net
However, the last sentence of the entry states:
it will cause the git push to be delayed until its completion.
Which is no fun if your test suite takes minutes to run, and seriously annoying when it takes 10 or 20 minutes (because git on the dev's machine will sit there and wait and not let go until the pre-receive hook exits).
Now, you may be able to write some sort of Hudson script to revert the failing commit when a build breaks. A former team experimented with such an idea, but never implemented it.

Resources