title: Continuous deployment of OSGi-based application on jenkins
body: <p>After spending a couple of hours trying to understand how to make <strong>continuous deployment</strong> work in the case of an <strong>OSGi-based application</strong>, I am finally posing my first question on stackoverflow, hoping for some indications on what I might have done wrong or missed - somehow I feel being on the wrong track...</p>
  
  <p>This is what I want to achieve:</p>
  
  <ol>
  <li><p><strong>build some bundles</strong> and install them to the maven repository (no problem here, using bnd)</p></li>
  <li><p>now having all the bundles making up my application (passing all tests and so on), I want to <strong>deploy and run</strong> the application, that is, start some OSGi framework using those bundles.</p></li>
  <li><p><em>Starting</em> is not the issue - "mvn pax:provision -Dframework=equinox" does the trick. My application starts jetty, so it is easy to verify via a browser to see if things look ok (additionally to all the tests)</p></li>
  <li><p>But, now, trying <strong>being "continuous"</strong>, the next time I want to apply this procedure, I really should make sure to <em>shut down the running instance</em> of my application first (releasing at least the port being used). So, to <strong>rerun</strong> everything, I somehow have to shut down the old installation first.</p></li>
  </ol>
  
  <p>And this is where my question starts: Is there anything helping me with this? I understand there is the <em>maven-deploy-plugin</em>, but this only seems to be useful when deploying some WAR/EAR file into some standard application container (without the need of restarting it seems). </p>
  
  <p>I really only need to run some script to <em>start up</em> the OSGi enviroment - and then, next time, to <em>shut it</em> down gracefully before I start it again. With tomcat, jetty, jboss and the like, there are some <em>shutdown.sh</em> scripts or <em>mvn jetty:stop</em> instructions, but do I really have to write those kind of scripts myself? This is where I think I am starting to be on the wrong track, somebody must have had those issues before me and solved them I guess ;) </p>
  
  <p>I understood that I could somehow try to use <em>JMX</em> or use the <em>telnet console</em> to access the running instance to issue an "stop 0" command but this <em>feels wrong</em>. </p>
  
  <p>Processes started from jenkins should compile/build/deploy projects, but not start long-running threads I guess, so I somehow have to start some process "outside" which I want to kill first the next time I try it again.</p>
  
  <p>Any ideas? Maybe I am missing something? Thanks in advance for any input on this!</p>