Since manually executing steps of my plugin with demo projects takes some time, I'd like to execute it on a separate server using mvn hpi:run. To access Jenkins on my desktop, I'd like to tunnnel e.g. using ssh server -L 8080:server. Unfortunately, I cannot access the server with tunnelling and even on the server itself, curl localhost:8080 works and curl server:8080 does not work (and ssh server works, so it is not a connection problem).
Since ufw is disabled, I assume that the Jenkins which is run by maven usually only listens to 127.0.0.1. To change this, according to https://wiki.jenkins.io/display/JENKINS//Starting+and+Accessing+Jenkins, either setting --httpListenAddress=0.0.0.0 or setting $HTTP_HOST should be possible (https://serverfault.com/questions/408657/how-to-access-jenkins-remotely-on-ubuntu-12-04-server).
Unfortunately, both versions
mvn clean hpi:run -DhttpListenAddress=0.0.0.0
export HTTP_HOST=0.0.0.0 && mvn clean hpi:run
did not succeed. Additionally, I guessed -Djetty.host=0.0.0.0 could work (how to make jetty server accessible from LAN?) since the port of Jenkins can be set using -Djetty.port, but it also did not work:
mvn clean hpi:run -Djetty.host=0.0.0.0
Is there any option to make a Jenkins plugin directly remote accessible when using hpi:run, or is it necessary to deploy it to a local Jenkins server everytime?
Following worked for me:
mvn -Dhost=0.0.0.0 hpi:run
Related
I was wondering if I can ssh a local instance of Jenkins. When I go to Jenkins CLI menu in the UI, there's a comment saying the below:
You can access various features in Jenkins through a command-line
tool. See the documentation for more details of this feature. To get
started, download jenkins-cli.jar, and run it as follows:
java -jar jenkins-cli.jar -s http://localhost:8080/ -webSocket help
So I tried it and it worked but it only gave a list of limited commands which I can execute. So I searched more and found I can use -ssh instead of -webSocket but I get the same result as -webSocket.
What I want to do is accessing the Jenkins bash so I can test my build scripts.
I'm trying
ssh 127.0.0.1 -p 23 // I set this port in the settings
but I keep getting :
shell request failed on channel 0
is it impossible what I'm trying to do? if not, how can I achieve it?
I'm currently using JHipster on their DevBox (XUbuntu) through a proxy.
I configured everything I could think about in it to use it through a proxy, mainly with the vagrant-proxyconf plugin and by exporting MAVEN_OPTS in a shell script inside /etc/profile.d.
npm install works fine, same for apt-get or Firefox.
However, mvn, telnet or ping keep giving me "Connection timed out" errors, with repo1.maven.org or google.com, even if I give the proxy options as parameters of mvn directly.
Ok found the problem...
To use Maven through a proxy you can set the MAVEN_OPTS environment variable like this: -Dhttp.proxyHost=<domain> -Dhttp.proxyPort=<port> -Dhttps.proxyHost=<domain> -Dhttps.proxyPort=<port> for a proxy URL like this: <protocol>://<domain>:<port>.
I simply used <protocol>://<domain> instead of <domain>...
But ping and telnet still won't work, even if the HTTP(S)_PROXY environment variables, lower and uppercase, are set. Well, I don't really need them so it's just strange but not harmful.
I'm trying to create an automated deployment via Jenkins that deploys an application to Glassfish-2.1.
The problem comes when Jenkins is running the following commands:
sh /usr/local/glassfish/bin/asadmin start-domain --user admin --passwordfile /usr/local/glassfish/passwordfile.txt domain1
sh /usr/local/glassfish/bin/asadmin deploy -s --contextroot admin /tmp/artifacts/$admin_war_file_name
But Jenkins just hangs, apparently waiting for the password. However, I can run this script manaually on the server and it works.
Also, I was curious if this ok from a security standpoint? Should I actually be storing the master password (if in fact I can even get Jenkins to run these commands in the first place!)
Any help is greatly appreciated.
I need to create a Build Server in CentOS 6.4 Minimal I sucessfully installed:
Java compiler (OpenJDK 1.7.0)
Git or Mercurial
Maven
Jenkins
Now I need to to the following:
At given intervals (eg daily at midnight) is the latest revision in the version control system (tip, HEAD, ...) compiled with Maven. In addition, Java Docs and packages (jar, war) need to be created.
Then Jenkins with all tests conducted and reported.
Make sure there is a report of previous builds
Ensure that the Java Docs and packages can be downloaded (jars, wars, ...) of the latest build
I can't use a GUI on CentOS Minimal so I need to configure the job in xml files? Could please someone show me the way... I'm not a linux server guru.
It's a bit impractical to configure Jenkins via XML by hand, because Jenkins' configuration is spread over multiple files, and the format of the configuration files changes between releases.
Given that Jenkins is a web application, you should be able to visit port 8080 (Jenkins' default port, assuming you didn't change it) on the server where you installed Jenkins (e.g. http://mycentosserver.example.com:8080), and configure it via the web interface.
If you're unable to access the web interface because of a firewall or similar, but you are able to SSH to the server (presumably you can, given that you were able to install stuff on it), you could set up an SSH tunnel to forward a port on your local machine to port 8080 on the server. For example, from your local machine, run the following command. You will then be able to access Jenkins on your local machine at http://localhost:28080 . If you're on Windows, you can use Putty to do the same thing.
ssh -L 28080:127.0.0.1:8080 mycentosserver.example.com
If you can't access the web app directly, and you can't SSH tunnel, I'd recommend setting up Jenkins on a server where you can access the web app, configuring it, and copying the XML config files from /var/lib/jenkins on that server across to your Centos server.
at the moment jenkins build my project and at the end the artifact is deployed on a remote tomcat via jenkins deploy plugin.
the problem is that after several redeployments this process fails (sometimes tomcat hangs or (un)deployment fails). in all cases stopping tomcat and manually undeploying helps.
Is there a way to stop tomcat before building/deploying, delete the old war and appfolder, and restart tomcat before deploy plugin wants to deploy the artifact?
thx in advance
You could write a batch file that does all the things mentioned:
stop tomcat
delete war files
start tomcat again
Then you can add a new pre/post build task in job configuration as execute batch and simply point it to run your batch file.
Added:
You can use PsExec - http://technet.microsoft.com/en-us/sysinternals/bb897553 It allows you to run processes remotely. Put batch on remote machine and from local one using Jenkins run sth like this: PsExec.exe \xx.xx.x.x C:\MyScript.bat
one addition to accepted answer:
it is important to reroute the output and error output of PsExec call (took me 2 days of debugging). See http://jenkins.361315.n4.nabble.com/remotely-executing-commands-td3476417.html
it seems that if called from java (like jenkins/tomcat) or .net PsExec hangs or quits with error. so the call should look like:
c:\someBatchWithPsExec.bat >>log.txt>&1
or explicitly on every call:
PsExec.exe -u [domain\remoteuser] -p [password] /accepteula \remoteMachine net [stop|start] Tomcat7 >>log.txt>&1
i guess if jenkins runs with domain\user u don't have to mention it in command?! (just tried it but it didn't work - the net commands fail)