Triggering CI builds using Jenkins on remote build machine - jenkins

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

Related

Jenkins Build Trigger after each commit to Github

I want to set in Jenkins jobs triggering Build after each commit
I dont have access to Setting in my repository on Github, so I don't have possibility using WebHook.
What is the best/.easy way to set this in other way?
I have jobs for private repository Github, and clone project by SSH
I also using Github Oauth Token
Jenkins Continuous Integration Server is on running on a Ubuntu host
You can use local git hook pre-push. It runs after you issue the "git push" command. (but executes before pushing)
See example: pre-push hook

post-commit hook : run the jenkins job based on project changed in git repository

I have configured individual jenkins jobs for each project. in my case, whenever there is a commit, all the jobs are getting triggered. how do I make sure only that job pertinent to the project runs and creates the deployable artifacts.
What URL have you configured in GIT repo? Does it contain repo name? Does each project has it's own repository?
When you call curl http://yourserver/jenkins/git/notifyCommit?url=<URL of the Git repository> jenkins will scan all the jobs that are configured to check out the specified URL. Do you have multiple jobs using the same repository?
You can try to use build triggers - you will be able to invoke a job by its name.

Jenkins configuration with remote live server

I want to know how to configure Jenkins with my live preprod instance server ?
Let me to explain you my process and tell me if I'm right and if that's not the good way to do.
1) I have my project project-1 in a server: /var/www/preprod/project-1, this project is in Magento Cms so it contains many files.
2) I copied this project project-1 in a repo Git, repo = project-1.
3) I cloned this project from this repo Git to my local machine: MAMP/htdocs/project-1.
4) I installed Jenkins, and I configured it with git, So when I do some push, Jenkins do a build automatically.
Now what I want to do is after the build, I want Jenkins to upload these changes to my live preprod server, whether automatically and manually.(I want to know the method to do it manually and automatically).
With this method, I develop in my local server, so when I finish some task and it's done, I push it to Git to have the changes history, and after that my need is to push it to the live server.
So tell me please if I'm using the right method, if it's a good practice and what I miss for this continuous deployment & delivery.
You can push it to the server using the Publish over SSH command if your doing a freestyle job https://wiki.jenkins.io/display/JENKINS/Publish+Over+SSH+Plugin, If you are doing an pipeline then you can do a simple scp command...
you can run this after the build is completed and it will run it automatically for you ...
Manually you will be notified when a build is done then you would copy it into your server using the normal way you would do it i.e.copy and paste...
Jenkins is a automation server. The whole point of using jenkins is to automate things so that you "manual" intervention is not required. So automate it where ever possible.
Hope it helps :)

Trigger a new build via Codeship API from Jenkins

I have a CI/CD setup with a Jenkins server to manage our internal CI/CD. We have Codeship performing our CI/CD for our AWS work.
I'm looking to setup jobs on our Jenkins server to manage when new builds are triggered on Codeship.
The aim being, we will have our Jira dashboard integrated with Jenkins in such a way that as an issue's status changes, specific jobs are executed.
So I'm trying to create a job that uses Codeship's API to trigger a new build, but it appears that you can only rerun an old build? How do you trigger a fresh build?
From the docs enter link description here you can only retrieve information and restart previous builds.
You want to run specific jobs, but those must be associated with some specific commit on your repository. You can identify the build for that specific commit and restart it.
Builds are always triggered from your git repository (github or bitbucket), and Codeship is highly dependent on that to keep the flow as simple as possible. You don't need to upload anything anywhere and then command Codeship to run a build on that. All you need is specify a repository and push something.
You could create an internal git server where your developers push to and with jenkins you can push changes from there to a repository connected to Codeship. That way you could control indirectly what gets tested and what does not.

Openshift - trigger Jenkins build on git push

I work with Openshift now and I have a problem.
I created an application server with Jenkins and when I push to the master branch of the git repository the Jenkins build is triggered automatically.
The point is that the build isn't triggered when I push to another branch (not master).
I've read topics like this one (How to configure Git post commit hook) and I do realize what the ways to make Jenkins build on git push are.
Unfortunately I haven't found any information about how this is done in the Openshift Jenkins. This mechanism is already implemented there and I simply want to replace the trigger from the "master" branch to another one.
How can I do it?
You can refer to the "Configuring Which Branch to Deploy" section from the following page:
https://developers.openshift.com/en/managing-deployments.html#configuring-which-branch-to-deploy

Resources