Integrating Jenkins with Gitlab - jenkins

I need to setup a build configuration in Jenkins so that whenever a build is triggered, I get my latest scripts from Gitlab and copy them to the target systems and run that script on the target.
I couldn't find any relevant info for integrating Gitlab to Jenkins. Are there any specific plugins that I could use?
I am using Jenkins version 2.158

Step by Step procedure for doing what you are looking for:
Add the location of the Script from GitLAB. (E.g.)
Run the script over the target machine.
While Building the job, you will get the code at the root (./) of the job's workspace. Copying and running the script over the target machine can be done by remote script executions. following are the cases we having in running script in the remote machine
Windows (jenkins) to windows - use psexec.exe
Windows (Jenkins) to linux - use plink.exe which is command line putty
Linux (Jenkins) to linux - use SCP and SSH
Linux to Windows - use ansible for windows.
E.g,.
$ scp script.sh remote_username#10.10.0.2:/remote/directory
$ ssh -t remote_username#10.10.0.2 /remote/directory/script.sh
All the best.

Integration between Git Repository Management (github, gitlab,bitbucket, etc) and Jenkins has the following steps :
Developer push some source code (java, php, nodejs, etc) to the Git Repository Management.
The Git Repository Management detects this event and notify to some public http endpoint in your Jenkins. Currently webhook is the most recommended way to implement this notification.
Jenkins receive the http post request(from bitbucket for example) and using some plugin or configurations , Jenkins try to determine or get the basic devops parameters like : branch name, commit author, commit message, technology, etc
Whit the extracted devops parameters, Jenkins launchs a preconfigured job. This job use the previously extracted values to build, compile, zip, install or to do whatever is necessary to startup your application.
If you want to implement this flow, check this post:
https://jrichardsz.github.io/devops/devops-with-git-and-jenkins-using-webhooks
Also, if you need. I will gladly to show you a basic integration using some git repository management and jenkins . Just contact me.

Related

Trigger JMeter tests on a remote system via Jenkins

how can we tell Jenkins to download and run JMeter tests on a remote system rather than from the Jenkins server itself?
My requirement is to create a job in Jenkins to download the latest code from a repo to another system where JMeter is installed and run the JMeter tests on that remote system rather than from Jenkins server itself? I can trigger the tests from Jenkins server itself but unable to connect to remote server and download/trigger the server.
You need to get familiarized with the concept of Jenkins Distributed Builds, it's enough to start Jenkins agent proces on the "remote system" and bind your job to execute on that agent instead of Jenkins master.
With regards to tracking changes in the remote repo check out Generic Webhook Trigger and How to Integrate Your GitHub Repository to Your Jenkins Project articles

Integrate jenkins and iib runtime

i want to setup build automation for IIB deployment using jenkins and enterprise github as a code repository.in my case, i have jenkins and iib runtime on different servers.
how do jenkins can run the IIB related run time commands and toolkit commands like mqsicreatebar in another server ?
is there any good approach for the above scenario ?
instead of building all IIb applications, i want to build only the project that was pushed to gitlab using post-receive hook script and generate environment specific bar files. ( using gitlab webhooks now)

Can Jenkins used with python project?

I'm developing a web application using python django. I want a CI service which can automatically pull the latest code from my github and run some test then deploy. I'm not familiar with CI, after searching for a while I found Jenkins seems to be a good solution. Can Jenkins be used for this?
Jenkins can be used with any project.
Regarding pulling the latest code, add the Jenkins GitHub plugin in order to be able to check "Build when a change is pushed to GitHub" under "Build Triggers".
That will launch your job on any new pushed commit on the GitHub repo.
From there, a Jenkins job can execute any command that you would do in command-line, provided the agent on which said job will be scheduled and executed has the necessary tools in its PATH (here python)
An alternative (which does not involved Jenkins) is to setup a webhook and a listener on your server which will detect a "push event" sent by said webhook.

Setup Jenkins to monitor external job

I read the part of the Jenkins wiki that covers setting up a remote job to be monitored by a Jenkins instance. However, the documentation is confusing as it doesn't tell me what to configure on the Jenkins machine or the remote machine (the one that does the job).
Further, the documentation mentions Java commands that can be fired directly and others that need a servlet container. Do I have to install a servlet container on the remote machine?
Maybe it's all there but for me it's like a mix of two documentations. Can you please clarify:
What do I need to do on the remote machine?
What do I need to do on the Jenkins machine?
Thank you.
In Jenkins, you need to create a job using the "Monitor an external job" option. Give this a name, for example "nightly-backup".
On the machine where the external job is running, you need Java installed and some basic Jenkins JAR files, so that the job results can be sent to Jenkins.
As the wiki page says, on some versions of Debian or Ubuntu you can do this with:
sudo apt-get install jenkins-external-tool-monitor
Otherwise, you have to copy a bunch of JARs manually — i.e. those listed on the wiki page — to your remote machine.
Once you have the JARs available on your remote machine, you can execute whichever command you like there, so long as you prefix it with some Jenkins information: where to find the Jenkins installation, the main Java JAR, and the job name:
JENKINS_HOME=http://my-jenkins/ java -jar jenkins-core-*.jar nightly-backup ./backup.sh --nightly /home
Where http://my-jenkins/ is the base URL to Jenkins, nightly-backup matches the name of the "Monitor an external job" you created in Jenkins, and ./backup.sh --nightly /home is the command you wish to run.
The output of this ./backup.sh command will show up in Jenkins automatically once it's complete.
It looks like this is now called "jenkins-external-job-monitor", so you'd type:
sudo apt-get install jenkins-external-job-monitor

Jenkins Remote Deployments

We're trying to setup Jenkins, but we are having a couple issues.
We have a "Jenkins Server" (Master) and have connected it to Fisheye. Jenkins is able to get the Git repo and run the tests.
Is there some kind of built in process for Jenkins to give it capabilites to SSH into a server and run commands like "git pull origin master" ?
Yes there is ssh capabilities in Jenkins. You can add a build step for either running SSH or sending files over SSH (you have to define target server in config). Theres also a post build plugin for sending artifacts over ssh which can be used to also execute remote commands.
I'd recommend a book by John Smart which covers Jenkins setup. Its at http://www.wakaleo.com/books/jenkins-the-definitive-guide
I think you want the SSH Plugin for Jenkins. This will let you define SSH servers in your global configuration, and then define commands to be run before and after the build.

Resources