I am trying to run a jenkins job which has a post deployment activity of running a few shell script commands. Jenkins is hosted on a windows OS. Can anyone tell me how Jenkins can connect to the Solaris environment on another machine and execute the shell script? Is this possible?
I am trying to build a Java WAR file on windows and then deploy it on tomcat on Solaris machine.
The WAR file is built. I need to write a shell script to copy that WAR file to Solaris machine.
Does anyone know how to integrate https://wiki.jenkins-
ci.org/display/JENKINS/XShell+Plugin
I suggest you use Artifact Deployer. It can copy files to a remote location and it does support Windows.
To answer your original question, yes, Jenkins can execute shell scripts on remote hosts. The most straightforward method that comes to mind is the Jenkins SSH Plugin, or the Jenkins Publish Over SSH Plugin. Either of those plugins will allow you to execute arbitrary commands over Secure Shell (SSH) to a host that supports SSH (like Solaris).
For your specific use case, however, it may be better to use a more specialized development plugin, such as the Deploy Plugin. Especially if you're using Maven to build your project in Jenkins, Apache publishes a Maven plugin that can automate deployment to Tomcat.
Related
I have a project in Java and I also used Gradle and TestNG. It works perfectly without jenkins.
After that I configured Jenkins and now I can run the code with Gradle command in Jenkins on my Local.
Then I tried to run the code on Slave machine. I can see the Slave machine in Jenkins nodes. I also configured Gradle and Java to run on Slave machine. I have to mention that I don't use Version Control in this project.
When I start the job in Jenkins to run on Slave machine, it starts the job but the problem is, it cannot find for example the gradle.build, as it's located in my Local machine and not in Slave machine.
The question is, should I use Version Control? is it going to solve the problem? or should I use Copy Artifact Plugin ?
Complementary Question: If I make a local git for my network on the same machine that runs Jenkins, it is going to be a problem?
Thanks for your help :)
Slave machine need your file gradle.build, so either place it there manually by SFTP.
If your gradle.build going to change regularly then its prefer to use version control like git by which jenkins will fetch the latest files.
Again its not mandatory but recommended to use version control like git to prevent from unnecessary errors
In my local machine, i just running the java application in eclipse and working perfectly.
But in my staging machine, i have a spring boot application and running in the centos server, which i am accessing by putty
when i tried running the command
> mvn clean package -DskipTests
after the above step, what the next step, i need to do
Actually i did was,
nohup java -jar target/cs.jar &
so that, jar was created in the target folder. Then when i tried to hit the endpoint from the postman its not working
As you said there might be some internet issue on the Staging Server. Maven may try to get dependencies from internet, but since it is not able to get to internet it is hanging.
Can you try to use following command on your linux server
$wget http://www.google.com
if it works correctly then you know that internet is there on that machine. Your maven should work then .
If not then, I would suggest build the whole thing on your local and transfer the build files to the server. In the server you can just execute
$ java -jar target/myproject-0.0.1-SNAPSHOT.jar
I am assuming that you can package the whole application in a jar file.
To move the jar file from windows machine to server machine you can use winscp tool.
I am trying to set up the environment with Java, git, Jenkins and maven by mentioning the IP address of linux VM. I have written a code to connect to VM, create folders, and move files to folders.
Now I want to install all Java and others software programmatically. Ib tried to install Java using yum -y install java-1.7.0. There is no error but then Java is not installed.
Please suggest what needs to be done so that Java gets installed and java_home path is set programmatically.
Any help is appreciated.
We've been doing this at the office this week. It sounds like you want a solution which would include JscH because you've started down that path. What I have to offer you is a solution that uses Jenkins.
We set up a target machine (two actually) as Jenkins slaves. It's rather easy to do, but you do need to install a JVM. You might look at docker.
Once the Jenkins slave is connected to the jenkins master, we just instruct it to run scripts. Some commands require sudo and so we set that up so that it does not require a password to be entered. Alternatively, you could run the jenkins slave jar after already having sudo -- not recommended.
We made a pom.xml to fetch .jar files and tar.gz files out of maven and copy them into a specific location. Then we executed scripts that manipulated them. The scripts came out of version control via Jenkins, but other files we pulled out of version control using a script.
All in all, I have the following tips for you:
Debug a script by executing it without Jenkins, and then run it under Jenkins for some final debug.
Put plenty of echo statements into your scripts so that you can see what has gone wrong.
You're totally relying on the Jenkins log and print debugging. This is very time consuming. So you would do well to pay attention to point #1.
Good luck :-)
I have a JRebel+Tomcat server run via IntelliJ on my Work (*NIX) machine, and occasionally I'd love to have JRebel update Classes/Resources when I'm at my home (*NIX) machine remotely connected via SSH.
e.g.
home $ ssh work
work $ cd workspace/foo/bar/baz
work $ hey-jrebel-go-update-classes
I handle this today by VNC'ing into my work machine, then in IntelliJ executing "Update Classes and Resources" on my running Tomcat instance, then log back out.
It's rather silly since I'm already SSH'd in. Is there a way to kick off this process via command-line?
JRebel features Remoting facility, which can be used to sync the changes via HTTP to the remote machine. For that, you should enable JRebel on remote Tomcat (via -javaagent:jrebel.jar) and enable JRebel remote plugin that create an HTTP endpoint for negotiating with the IDE plugin. -Drebel.remoting_plugin=true will do.
For more information you can check the tutorial for setting up Remoting with IntelliJ IDEA and Tomcat.
Otherwise, without remoting enabled, you can deploy the app with the rebel.xml config file which will point to the location where the exploded application is and JRebel will make Tomcat to load the resources from that specific location, so you could just synchronize from IntelliJ to that remote location via SSH. JRebel will then work as usual - monitoring the changes in the specified location and reloading the classes/resources as soon as they are being used in the application.
I'm not completely following what you are attempting to do. But if I follow, you basically want to issue a command to a remote server via SSH and, ideally, launch it from within IntelliJ IDEA. You could either:
Use the Terminal window (Tools > Open Terminal), start an ssh connection, and then issue the command manually.
Create an External Tool definition that uses plink (or an equivalent) to execute the ssh command to your remote server. You can create an External Tool Definition in Settings > [IDE Settings] > External Tools. See the screenshot below for an example. The definition (or its group if using groups to add structure to your definitions) will appear on the Tool menu. You can also map a shortcut to it via Settings > [IDE Settings] > Keymap > External Tools. For a multiple command sequence, you can either
write a local script that does it and use the External Tool definition to launch the script
write a remote script and use the plink in an External Tool Definition to run it
put the commands to run in a local file and use plink -m {file} to run them.
I have an build file located on a remote system. I want to run it there itself.It would be good if I can invoke it using a java program from my local system only.I tried using google but no success.Is it possible at all?
(extending comments on jenkins into answer)
I suggest Jenkins with master slave configuration to fully automate your build process. It comes with hundreds of plugin (You have plugins for static code analsys, test, test report, publishing , deployment.., supports many VCS).
Jenkins exposes operations via web-gui. It also has command line tool to aid in automation . You can easily add multiple machines into build and extend your workflow..
If your slaves are on windows, only trouble you have is an FAQ: https://wiki.jenkins-ci.org/display/JENKINS/Windows+slaves+fail+to+start+via+DCOM