<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Snapshot on Jean-Christophe Gay</title><link>https://jeanchristophegay.com/en/tags/snapshot/</link><description>Recent content in Snapshot on Jean-Christophe Gay</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><copyright>© 2026 Jean-Christophe Gay</copyright><lastBuildDate>Tue, 18 Aug 2026 23:08:47 +0200</lastBuildDate><atom:link href="https://jeanchristophegay.com/en/tags/snapshot/index.xml" rel="self" type="application/rss+xml"/><item><title>Deploy Maven SNAPSHOT with Travis CI</title><link>https://jeanchristophegay.com/en/posts/deploy-snapshot-travis-ci/</link><pubDate>Wed, 29 Jul 2015 21:23:00 +0200</pubDate><guid>https://jeanchristophegay.com/en/posts/deploy-snapshot-travis-ci/</guid><description>&lt;p&gt;Guide to deploy SNAPSHOT binaries on &lt;a href="https://oss.sonatype.org" target="_blank" rel="noreferrer"&gt;OSS sonatype&lt;/a&gt; repository with &lt;a href="http://travis-ci.org/" target="_blank" rel="noreferrer"&gt;Travis CI&lt;/a&gt;.&lt;/p&gt;

&lt;h1 class="relative group"&gt;Maven configuration
 &lt;div id="maven-configuration" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#maven-configuration" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h1&gt;
&lt;p&gt;Maven must be setup to use your personal account to access sonatype repository.
Create a &lt;code&gt;etc/deploy-settings.xml&lt;/code&gt; file and use variables to set username and password:&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-xml" data-lang="xml"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nt"&gt;&amp;lt;settings&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;servers&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;server&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;id&amp;gt;&lt;/span&gt;ossrh&lt;span class="nt"&gt;&amp;lt;/id&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;username&amp;gt;&lt;/span&gt;${env.OSSRH_USER}&lt;span class="nt"&gt;&amp;lt;/username&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;password&amp;gt;&lt;/span&gt;${env.OSSRH_PASS}&lt;span class="nt"&gt;&amp;lt;/password&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;/server&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;/servers&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nt"&gt;&amp;lt;/settings&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;This file will be passed to &lt;code&gt;mvn&lt;/code&gt; with the option &lt;code&gt;--settings&lt;/code&gt;.&lt;/p&gt;

&lt;h1 class="relative group"&gt;Identification
 &lt;div id="identification" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#identification" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h1&gt;
&lt;p&gt;We have two solutions to store ours username and password for Travis CI.&lt;/p&gt;

&lt;h2 class="relative group"&gt;Repository settings
 &lt;div id="repository-settings" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#repository-settings" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;In Travis CI repository settings &lt;code&gt;https://travis-ci.org/user/repository/settings&lt;/code&gt;, we can define &lt;a href="https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings" target="_blank" rel="noreferrer"&gt;environment variables&lt;/a&gt; &lt;code&gt;OSSRH_USER&lt;/code&gt; and &lt;code&gt;OSSRH_PASS&lt;/code&gt;. They will be hidden in logs by default.&lt;/p&gt;

&lt;h2 class="relative group"&gt;Encrypt username and password
 &lt;div id="encrypt-username-and-password" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#encrypt-username-and-password" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Obviously we don&amp;rsquo;t want to store our sensible data in clear text, &lt;a href="http://docs.travis-ci.com/user/encryption-keys/" target="_blank" rel="noreferrer"&gt;Travis CI&lt;/a&gt; allow us to encrypt data.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;gem install travis
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And here comes Ruby&amp;hellip; if you&amp;rsquo;re not a ruby developper, things can go wrong from here (at least with OS X).&lt;br&gt;
In my case I faced the error:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt; gem install travis 
Fetching: multipart-post-2.0.0.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
 You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The problem comes from the bundled version installed by Apple, Ruby users are certainly using &lt;code&gt;rvm&lt;/code&gt;, &lt;code&gt;rbenv&lt;/code&gt; or some other tool. But for others who don&amp;rsquo;t want to waste time trying to figure out the Ruby ecosystem, just:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;brew install ruby
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Relaunch a shell and &lt;code&gt;travis&lt;/code&gt; gem installation should succeed&amp;hellip;&lt;/p&gt;
&lt;p&gt;We can finally ask &lt;code&gt;travis&lt;/code&gt; to encrypt our username and password:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;travis encrypt --add -r jcgay/send-notification &amp;quot;OSSRH_USER='toto'&amp;quot;
travis encrypt --add -r jcgay/send-notification &amp;quot;OSSRH_PASS='s3cret&amp;amp;'&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If commands are executed from the project folder, option &lt;code&gt;-r&lt;/code&gt; is not necessary and you can use &lt;code&gt;--add&lt;/code&gt; to automatically write encrypted keys in &lt;code&gt;.travis.yml&lt;/code&gt;.
&lt;code&gt;jcgay/send-notification&lt;/code&gt; is the project you want to encrypt keys for.&lt;/p&gt;

&lt;h1 class="relative group"&gt;Configuration de Travis CI
 &lt;div id="configuration-de-travis-ci" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#configuration-de-travis-ci" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h1&gt;
&lt;p&gt;We don&amp;rsquo;t want to deploy SNAPSHOT when Travis is building a pull-request. We can read &lt;code&gt;${TRAVIS_PULL_REQUEST}&lt;/code&gt; variable to skip deployment when its value equals &lt;code&gt;false&lt;/code&gt;.
Same goes when Travis is building a release, as they are made outside Travis in my case, I don&amp;rsquo;t want a deployment when &lt;code&gt;${TRAVIS_TAG}&lt;/code&gt; variable is not empty.&lt;/p&gt;
&lt;p&gt;So our &lt;code&gt;.travis.yml&lt;/code&gt; contains:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;env:
 global:
 - secure: GT8Hi5kgx2cLAGzh2ggZNTgiLm8J5fd64SYG3bkhgwZGbV/HRD8r8a1SYv1iQ72JqrDhlHQ7q8h17nDBFLjy99h/XKN4MacBu9CZhnPO7lXpuRefD3W/db6zWSk17a5DAKAt+1UOeyfohEkzx+JHcTfbvMg6hy+3DEPaVMUtV04=
 - secure: fQ4bSOcHWEURfsDQVhWA152GCiezQfh9YC45a2zae8oOk+6bIrHmrkJSyVYpUCLGdqO3Df+JTy6bfoqyJEsX7PkzGPZ10odSHw5qDqfTIolt7UympKtUvUNi6h5G6virGhBWjjs5REGjrgWdTlqKjNT2Ax/VlzNRskqaVAhEhl0=
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and one more step as &lt;code&gt;after_success:&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;after_success:
 - &amp;quot;[[ ${TRAVIS_PULL_REQUEST} == 'false' ]] &amp;amp;&amp;amp; [[ ${TRAVIS_TAG} == '' ]] &amp;amp;&amp;amp; mvn deploy -DskipTests --settings etc/deploy-settings.xml&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Enjoy fresh deployed SNAPSHOT !&lt;/p&gt;</description></item></channel></rss>