You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Steinar Bang <sb...@dod.no> on 2017/08/26 21:51:56 UTC
Making karaf update snapshots from remote repositories Was: Karaf Feature vs. OBR
>>>>> Steinar Bang <sb...@dod.no>:
> Now I've done it differently (...and perhaps more correctly...?):
> 1. I've installed karaf-4.1.2 on a debian 9 "squeeze" system, using the
> debian package created by this script: https://github.com/steinarb/karaf-deb-packaging
> The .deb package creates the user "karaf" that karaf is running as
> 2. I've used "ssh -p 8101 karaf@localhost" to log in to the console of
> karaf and then
> a. Changed the config to add the snapshot repository, and set the
> globalUpdatePolicy to always:
> config:edit org.ops4j.pax.url.mvn
> config:property-append org.ops4j.pax.url.mvn.repositories ", https://maven.bang.priv.no/repository/@snapshots, http://maven.vaadin.com/vaadin-addons"
> config:property-set org.ops4j.pax.url.mvn.globalUpdatePolicy always
> config:update
> b. I've then installed my application (pulled in from the snapshot
> repository added above):
> feature:repo-add mvn:no.priv.bang.ukelonn/ukelonn.karaf/LATEST/xml/features
> feature:install ukelonn-db-postgresql
> feature:install ukelonn
> c. I've set karaf up to listen for snapshot changes
> bundle:watch *
> The application starts up fine, and everything is downloaded from the
> snapshot repository.
> But as far as I can tell from the logs of the repository, there is
> nothing accessing https://maven.bang.priv.no/repository/ to check if
> there are updates to the snapshots.
I added "aether.updateCheckManager.sessionState=false" to
/etc/karaf/system.properties as outlined in [1].
Then I stopped and started the karaf service
systemctl stop karaf
systemctl start karaf
But as far as I can tell from the HTTP server access log, nothing is
polling maven.bang.priv.no.
References:
[1] <https://stackoverflow.com/questions/24791950/how-to-work-with-frequent-local-snapshot-bundle-deployments-on-karaf#comment67335318_24796028>
Re: Making karaf update snapshots from remote repositories Was: Karaf Feature vs. OBR
Posted by Steinar Bang <sb...@dod.no>.
To summarize my experiences so far:
1. I have a travis ci build that does maven snapshot deploys using ftp
to a directory on the same server where karaf is running.
2. I serve the maven repository area out with HTTP and HTTPS using
nginx.
3. I added the maven repository served out by nginx like so:
config:edit org.ops4j.pax.url.mvn
config:property-append org.ops4j.pax.url.mvn.repositories ", https://maven.bang.priv.no/repository/@snapshots, http://maven.vaadin.com/vaadin-addons"
config:property-set org.ops4j.pax.url.mvn.globalUpdatePolicy always
config:update
4. After this, I could install my webapp with these commands:
feature:repo-add mvn:no.priv.bang.ukelonn/ukelonn.karaf/LATEST/xml/features
feature:install ukelonn-db-postgresql
feature:install ukelonn
bundle:watch *
5. After this, the webapp started and run
6. I did a new travis-ci build that deployed a new snapshot version
into the maven repository
7. The snapshot changes weren't picked up automatically by karaf
(ie. "bundle:watch *" had no effect)
8. Giving the command "bundle:update" for each bundle made the bundles
reload from the new snapshot:
bundle:update no.priv.bang.ukelonn.api
bundle:update no.priv.bang.ukelonn.db.liquibase
bundle:update no.priv.bang.ukelonn.db.postgresql
bundle:update no.priv.bang.ukelonn
9. I uninstalled and reinstalled karaf to start with a clean slate
10. I added the repository where travis-ci deploys the snapshots with a
file URL (since it is on the same machine as karaf is running)
config:edit org.ops4j.pax.url.mvn
config:property-append org.ops4j.pax.url.mvn.repositories ", file:///usr/local/www-maven/repository/@snapshots, http://maven.vaadin.com/vaadin-addons"
config:property-set org.ops4j.pax.url.mvn.globalUpdatePolicy always
config:update
11. I reinstalled my webapp, this time from the "file:" repository
feature:repo-add mvn:no.priv.bang.ukelonn/ukelonn.karaf/LATEST/xml/features
feature:install ukelonn-db-postgresql
feature:install ukelonn
bundle:watch *
12. I deployed a new maven snapshot version to the "file:" repository
from a travis-ci build
13. At the time of writing its approximately 30 minutes since the
travis-ci job completed, but karaf hasn't loaded any new snapshots
yet, so "bundle:watch *" doesn't seem to work for snapshots that are
loaded from a "file:" maven repository, that isn't the maven local
repository
Re: Making karaf update snapshots from remote repositories Was: Karaf Feature vs. OBR
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:
>>>>> Steinar Bang <sb...@dod.no>:
> [snip!]
>> But the conclusion is that I'm pretty sure neither bundle:watch nor
>> bundle:update works for watching a remote repository, or update a
>> bundle installed from a remote repository.
> (But I will be very happy to be proved wrong...)
The bundle:watch command doesn't work for watching snapshots being
deployed to a remote repository.
However, the bundle:update command works just fine for updating a
snapshot installed from a remote maven repository.
Pushing changes to master, triggered a new travis build that deployed to
the maven repository at https://maven.bang.priv.no/repository/
I did "ssh -p 8101 karaf@localhost" to log into the karaf console, and
then gave the following commands to update all of my snapshot bundles:
bundle:update no.priv.bang.ukelonn.api
bundle:update no.priv.bang.ukelonn.db.liquibase
bundle:update no.priv.bang.ukelonn.db.postgresql
bundle:update no.priv.bang.ukelonn
After this I verified that the GUI of the webapp showed the new changes
I wanted deployed.
It isn't "bundle:watch *", but it is a lot simpler than doing git pull
and "mvn clean install" as user karaf (I did it by creating shell
scripts I started from the karaf console).
(After looking at the code, I have no idea why "bundle:update" works,
but I can see that it does...)
Re: Making karaf update snapshots from remote repositories Was: Karaf Feature vs. OBR
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:
[snip!]
> But the conclusion is that I'm pretty sure neither bundle:watch nor
> bundle:update works for watching a remote repository, or update a
> bundle installed from a remote repository.
(But I will be very happy to be proved wrong...)
Re: Making karaf update snapshots from remote repositories Was: Karaf Feature vs. OBR
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:
[snip!]
> But as far as I can tell from the HTTP server access log, nothing is
> polling maven.bang.priv.no.
As far as I can tell from the source code of karaf 4.1.2[1][2],
bundle:watch only works for files in the local repository.
The bundle:update command also looks like it only works for a local
file, unless the --raw flag is used[3] (But the "--raw" flag
description looks unrelated to local vs. possibly remote, and there is
no guarantee that it works for remote locations. It's just that I can't
be positive that it doesn't work).
I know that the bundle:install command works for a remote repository,
because I've installed my application from a remote repository (that is:
I've installed the application using feature:install, so I'm just
assuming that installing of bundles from remote repositories work), but
I can't tell how it works, because it disappears into
BundleContext.install() to do the installation[4].
But the conclusion is that I'm pretty sure neither bundle:watch nor
bundle:update works for watching a remote repository, or update a bundle
installed from a remote repository.
References:
[1] <https://github.com/apache/karaf/blob/karaf-4.1.x/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleWatcherImpl.java#L156>
[2] <https://github.com/apache/karaf/blob/karaf-4.1.x/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleWatcherImpl.java#L216>
[3] <https://github.com/apache/karaf/blob/karaf-4.1.x/bundle/core/src/main/java/org/apache/karaf/bundle/command/Update.java#L67>
[4] <https://github.com/apache/karaf/blob/karaf-4.1.x/bundle/core/src/main/java/org/apache/karaf/bundle/command/Install.java#L84>