How to place an artifact in a remote server and unzip - jenkins

Hi have requirement to Continous deployment using Jenkins and below are the steps to achieve.
1.Jenkins job download the artifact from Nexus and place it in a remote server
2.Unzip the artifact present in the remote server.
3.Perform Gradle task in remote server

You could try using Ansible maybe https://docs.ansible.com/ansible/latest/modules/copy_module.html
If it is Windows:
https://docs.ansible.com/ansible/latest/modules/win_unzip_module.html
You have modules for every situation:
https://docs.ansible.com/ansible/latest/modules/modules_by_category.html
You could do it with Jenkins, scripting the code, and probably storing the login in the Jenkins credentials.

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

Integrating Jenkins with Gitlab

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.

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 :)

How to deploy a jar on Windows server through Jenkins job?

We have a jenkins job which is getting triggered after every push to gitlab.
It creates a build. Upon successful build we want to copy the jar to some Windows server.
We are able to set SSH credentials for Linux server. How do we do it for Windows server.
Thanks
Install the slave on windows machine & trigger the .bat file through jenkine's job.

Jenkins & Artifactory

On a server running ubuntu 12.04 I have installed jenkins 1.532.1 and artifactory 2.6.4.
Both of then are running fine separately. I also have maven 2.
With jenkins, I can build maven java project with sources on subversion.
With maven I can use Artifactory.
The problem is with the artifactory plugin for jenkins.
I added an artifactory server with credentials. Using connection check tell me : "Found Artifactory 2.6.4". It seems to be ok.
But when I create a maven job, in post build actions, I choose Deploy artifacts to artifactory. My server is already selected in the artifactory server but nothing is available in the repositories.
What can I do. Do I have to configure something special in Artifactory ?
I had also this issue, the problem comes from a refresh of Jenkins Plugin.
To deal with that issue, you should:
open your job
add a task for artifactory
save your job
Open again your job
Now you should be able to see your repositories.
Conclusion: You should add/save and reload your job to see your list of repo of artifactory.
I also have this problem, when switching from one artifactory server to another and it looks like a bug for me.
But if I save the settings once without a "non-selectable" repository and access the configuration of the job again, the repositories will be shown.
Ok, so after a very long time I tried again and ... I don't know why but now (I'm quite sure it was not working few months ago) the solution given by aorfevre and user3424040 are working.
I have also upgraded jenkins to 1.565.1 and the artifactory plugin to 2.2.3 and now there is a Refresh Repositories button in the Deploy artifacts to Artifactory task.
For the "Generic-Artifactory Integration" I had to configure Artifactory a bit. I added a group 'deployers' and a user 'deploy' in that group. Also I added a Permission Target for the LOCAL repositories where the group was granted deploy permissions.

Resources