Executing shell script using Jenkins UI - jenkins

I would want to execute the shell script using Jenkins.
For example, I have a shell script MakeTest.sh which is on the server "test1.test2.net" location "/home/rt", how would I execute it? My Jenkins and script to be executed are in different servers.
Thanks!

Using git, you can download the file into the workspace of your job.
After you just have to launch the script ./MakeTest.sh

Related

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

Call Jenkins CLI from within pipeline

Is it possible to call Jenkins CLI commands within a pipeline?
Upon migrating jobs to new Jenkins instances I would like to enable users to migrate their own jobs from an old Instance.
Yes, you can write pretty much any shell code you want, including calling the CLI jar from a shell instruction.
sh "java -jar /path/to/jenkins-cli.jar your-usual-command"

Run a db script using jenkins

I need to run a db script to take oracle database backup in a remote server using Jenkins in Windows environment. Is it possible? I created a Free style project in Jenkins and installed SQLPlus script runner plugin. But it didn't work. Can anyone please advise me how to do this?
If you have a simple shell or python script to run from jenkins then you can do it like this :
Configure jenkins job to run as shell script
and write something like
#!/bin/sh
sh <location_of_shell_script_for_backup>
You can change sh as per your requirement.

Execute Shell script from workspace on remote machine after build successful (Jenkins)

The scenario is - I have a job A which runs my ant script and packages the artifact's for me.
I am also using parametrized Triggered plug in to Trigger my "Job B" which will deploy my artifact on remote machine.
The job A is working fine and also Job B.
The tasks that i have to perform with Job B are
GIT checkout (which contains my deployment scripts) (successfully doning).
Copying artifacts from previous build to Remote machine. (successfully doing)
Run shell script on remote machine(script present in workspace folder )- Facing issues.
I browsed various plug ins for the same but no one is allowing me to run shell script after , "SCP to remote machine" which is present in Post build action.
I would like to execute the same sequence, however if you guys have any other suggestions please share.
Thanks in Advance.!
As part of Publish Over SSH Plugin, you can execute a script after the files had been copied over.
Under Post-build Actions
Add Send build artifacts over SSH
Select a preconfigured server (done in global configuration)
Select files to copy from workspace
Enter Exec command
If one of the files you copy is your shell script, you can enter it here as an "exec command"
To solve my query i used Jenkins SSH Plugin. This provides a configuration tab where i can add multiple hosts and after that used them in my job level configuration.
Link to Plugin
you get privilege to execute shell script on remote host as pre-build step or post build step.
updated the path of publish over ssh it worked for me

How to start Selenium in a Jenkins job

I am using Jenkins and Ant to execute my Selenium tests. I would like to make a job that would do the following:
starts Selenium server
executes tests and
kills Selenium server after all tests are run.
I am able to start the Selenium server manually with the following command:
java -jar selenium-2.16.1\selenium-server-standalone-2.25.jar
But I cannot find a Jenkins plugin that would do the start/stop for me. All I can find are some Selenium reporting plugins.
Not sure if there is a plugin, but you can just run the launch and kill commands via the Jenkins job.
Under Build, if you add an Execute shell build step, you can run your commands from there.
Note - The path to the selenium server is relative to the current work directory.
Looking at your error trace, looks like you are running this on a windows PC. you need to be running this as a "execute windows batch command" then run java -jar selenium-2.16.1\selenium-server-standalone-2.25.jar Assuming that you have your jar file on the workspace. or you beed to point it at the right path

Resources