Jenkins Pipeline file - jenkins

I am in the process of writing a declarative jenkinsfile to build a pipeline project. Some of the steps within a few of the stages will require some remote commands to be run. The remote ssh sites have been configured in the main jenkins configuration.
How can I declare these steps within my jenkinsfile? I know I can run shell commands locally using sh but it's the remote servers that i need to know about?

You need to install ssh-agent plugin then you will be able to execute remote commands using ssh. Check this for examples

Related

How to run jmeter script parallely on Jenkins

I want to run jmeter script parallely through jenkins.
currently i have tried BZM-concurrency thread group and Parallel controller to achive this on my local machine, which is working fine. please help me to run it through jenkins, it get finish with success but script never starts. Do i need any plugins on jenkins to achieve this?
my set is shown below, let me know is there any other way to achieve this.
You need the same plugins in Jenkins master (and all the slave if any) which are used in the test plan, the easiest is just to copy the existing JMeter installation folder to Jenkins instance(s)
Alternatively you can install the required plugins using JMeter Plugins Manager
If your Jenkins doesn't have the GUI - it is possible to install the plugins via the command-line

How to write jenkinsfile that will access openshift and run few commands

I am new to Jenkins, can someone help me to write Jenkinsfile that access openshift run few of commands, and return the report
I know commands to run manually in open shift but don't know how to do in Jenkins
There are a few good introductions available on how to access OpenShift using the OpenShift Jenkins Plugin or on how to run generic commands using sh:
Using OpenShift Pipeline Plugin with External Jenkins
Building Declarative Pipelines with OpenShift DSL Plugin
More generic: Jenkins Pipeline: running external programs with sh

Jenkins plugin to copy files to windows server

I have a situation where in I need to copy set of files to a windows server through Jenkins. I see a lot of Jenkins plugins that will do this kind of job through ssh but not in my case. Jenkins is also hosted in a windows server and end server is also a windows, so I believe ssh is not an option. Any plugin available in the market to get the job done or writing our requirements in powershell/MSDos script is the only option?
Thanks in advance!
just execute a bat command with the following
copy C:\localfile.bak \\remotemachine\c$\Path\remotefile.bak
in the Using the Execute Windows batch command option in the build Step
How to run bat file in jenkins

How to send build artifacts over ssh using Jenkins pipeline

I was using Freestyle project method for configuring jobs in Jenkins. I have used Publish Over SSH plugin to send war file to remote system. Now i moved to pipeline configuration. I would like to know how can i do the same in pipeline configuration. Can anyone tell how to write pipeline script for publish over ssh?
Any help would be greatly appreciated.
You can use the raw Unix command scp, as described there : Example syntax for SCP. scp is Unix utility for secure copy... over SSH, which is exactly what Publish Over SSH uses behind the scenes !
Example :
scp your_username#remotehost.edu:foobar.txt /some/local/directory

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