<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Julio Capote on Medium]]></title>
        <description><![CDATA[Stories by Julio Capote on Medium]]></description>
        <link>https://medium.com/@capotej?source=rss-423d7def417e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*mX8Yagk8kLyk39sp.png</url>
            <title>Stories by Julio Capote on Medium</title>
            <link>https://medium.com/@capotej?source=rss-423d7def417e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 04:25:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@capotej/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Continuous Delivery with Maven, Buildkite and packagecloud]]></title>
            <link>https://medium.com/building-buildkite/continuous-delivery-with-maven-buildkite-and-packagecloud-fc8c86f1e9b1?source=rss-423d7def417e------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc8c86f1e9b1</guid>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[automated-testing]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[continuous-delivery]]></category>
            <dc:creator><![CDATA[Julio Capote]]></dc:creator>
            <pubDate>Tue, 18 Jul 2017 22:46:24 GMT</pubDate>
            <atom:updated>2017-07-18T22:46:24.066Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How to set up a continuous delivery pipeline for your </em><a href="https://maven.apache.org/"><em>Maven</em></a><em> project using </em><a href="https://buildkite.com/"><em>Buildkite</em></a><em> and </em><a href="https://packagecloud.io/"><em>packagecloud</em></a><em>.</em></p><p>Setting up your Maven project for continuous delivery with Buildkite and packagecloud allows you to:</p><ul><li>Map every commit to a published artifact, and vice versa.</li><li>Reduce the risk of a “bad deploy” by having a centralised, automated and repeatable process that’s versioned, and tested, alongside your code.</li><li>Drastically shorten the feedback loop between making a change, and verifying its behavior in another context (a staging environment, another developer’s machine, etc).</li></ul><p>Using a managed Maven repository, like packagecloud, alongside Buildkite gives your team:</p><ul><li>A tailored web interface built for browsing artifacts, along with automatically generated installation instructions for Maven, SBT, Gradle and Leiningen.</li><li>Flexible authentication/permissions system, giving every team member their own set of credentials which can be revoked individually. No need to share secrets!</li></ul><p>In this post I’ll show you how to setup your Maven project with Buildkite and packagecloud. Download the example Maven project from GitHub to follow along on your own machine:<br><a href="https://github.com/computology/buildkite-maven-project">https://github.com/computology/buildkite-maven-project</a>.</p><h3>Create a Maven repository on packagecloud.io</h3><p>Before we begin we’ll need to create our Maven repository on packagecloud and get our API token. This will allow us to deploy our artifacts from our Buildkite agent machine. <a href="https://packagecloud.io/l/maven-repository?utm_campaign=cmkt&amp;utm_medium=link&amp;utm_source=buildkite">Sign up with this link</a> to get a free Maven repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nbiZbNilhGnAvmJmpxlWhQ.png" /></figure><p>Once you have an account on packagecloud, you can visit your <a href="https://packagecloud.io/api_token">Api Token</a> page to get your API token, which you’ll need in the next step.</p><h3>Setup a Buildkite Agent server</h3><p>For our example, we’ll be using installing Buildkite on an <strong>Ubuntu 16.04</strong> system using the <a href="https://buildkite.com/docs/agent/ubuntu">Installing Buildkite Agent on Ubuntu documentation</a>.</p><h4>Step 1 : Update system packages and install Maven</h4><p>As one does with any new server we upgrade our system packages to the latest versions, and then install Maven:</p><pre>sudo apt-get update &amp;&amp; apt-get upgrade -y </pre><pre>sudo apt-get install -y maven openjdk-8-jdk</pre><h4>Step 2: Install Buildkite agent</h4><p>Using the instructions from the <a href="https://buildkite.com/docs/agent/ubuntu">Installing Buildkite Agent on Ubuntu documentation</a>, let’s install the Buildkite Agent:</p><pre>sudo sh -c &#39;echo deb https://apt.buildkite.com/buildkite-agent stable main &gt; /etc/apt/sources.list.d/buildkite-agent.list&#39;</pre><pre>sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 32A37959C2FA5C3C99EFBC32A79206696452D198</pre><pre>sudo apt-get update &amp;&amp; sudo apt-get install -y buildkite-agent</pre><h4>Step 3: Configure and start the Buildkite agent</h4><p>Once installed, we’ll need to to set the agent token. You can retrieve this token on your Buildkite Agents page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*2QPQEEiRSafkcg0Oi1UmGg.png" /></figure><p>Then, we’ll configure our agent with that token, and then start your agent:</p><pre>sudo sed -i &quot;s/xxx/INSERT-YOUR-AGENT-TOKEN-HERE/g&quot; /etc/buildkite-agent/buildkite-agent.cfg</pre><pre>sudo systemctl enable buildkite-agent &amp;&amp; sudo systemctl start buildkite-agent</pre><p>You should now see the agent connected on your Buildkite Agents page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*wlNMJCytevwYEAtoK68klQ.png" /></figure><h4>Step 4: Add packagecloud API token hook to our Buildkite Agent</h4><p>We’ll expose our packagecloud API token through an environment variable using a <a href="https://buildkite.com/docs/agent/hooks#global-hooks">global hook</a>. Hooks are scripts that the Buildkite agent runs at different stages of a build. For more information, check out the <a href="https://buildkite.com/docs/agent/hooks">full documentation on hooks</a>.</p><p>To setup our global hook, paste the following into a file located at /etc/buildkite-agent/environment. Theenvironment hook is the <a href="https://buildkite.com/docs/agent/hooks#available-hooks">first hook the Buildkite Agent runs</a> and, as its title suggests, is the best place to setup your environment variables. Make sure this file is executable and owned by buildkite-agent.</p><pre>#!/bin/bash</pre><pre>set -euo pipefail</pre><pre>echo &#39;--- Setting up packagecloud API token&#39;</pre><pre>export EXAMPLECORP_PACKAGECLOUD_API_TOKEN=&#39;xxxxxxxx&#39;</pre><p>You can secure this approach even further by using a credentials manager store and retrieve your secrets, like <a href="https://www.vaultproject.io/">Vault</a>. But for the sake of simplicity, we’ll just put our API token inside the hook.</p><h4>Step 5: Generate an SSH key for our Buildkite Agent</h4><p>In order to authenticate with GitHub to pull our project, we’ll need to generate an SSH key for the user running our Buildkite Agent (buildkite-agent by default), as per the <a href="https://buildkite.com/docs/agent/ssh-keys#creating-a-single-ssh-key">Buildkite Agent SSH Keys documentation</a>:</p><pre>sudo su buildkite-agent</pre><pre>ssh-keygen -t rsa -b 4096 -C &quot;ci@example.com&quot;</pre><pre>cat ~/.ssh/id_rsa.pub</pre><pre># Later you&#39;ll add this key to GitHub as a Deploy Key</pre><h3>Create a pipeline for our Java project</h3><h4>Step 1: Create a new pipeline on Buildkite</h4><p>Our pipeline is straightforward, it just runs a single step:<br>mvn -s .buildkite.settings.xml deploy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HLlEIaZtOo7AUAAj7yENEg.png" /></figure><p>After the pipeline is created, you’ll be presented with instructions for setting up Webhooks on GitHub, so that Buildkite can automatically trigger builds every time code is pushed up to your repository. Copy/Paste the generated Payload URL, since we’ll need it for the section below.</p><h3>Prepare Github repository for Buildkite</h3><h4>Step 1: Add webhook URL</h4><p>As per the Buildkite instructions, go to the <em>Webhooks</em> section of your GitHub repository Settings page and add the <em>Payload URL</em> generated by Buildkite:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AGQMl7g3EkC7lPvp1BcI7g.png" /></figure><h4>Step 2: Add the deploy key to the repository</h4><p>Visit the <em>Deploy Keys</em> section of your GitHub repository Settings page and add the SSH key we generated earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nel0Htbc5rx9OVGMlEXSfg.png" /></figure><h3>Prepare your Java project for continuous delivery</h3><p>The pipeline is configured to export our packagecloud API token, and run on GitHub commits and pull requests. All that’s left is to configure Maven to use this environment variable, and publish to packagecloud.</p><h4>Step 1: Add the .buildkite.settings.xml file</h4><p>Copy the content below (<a href="https://github.com/computology/buildkite-maven-project/blob/master/.buildkite.settings.xml">GitHub source</a>) into a .buildkite.settings.xml file in your project. This instructs Maven to use a password value from the environment variable EXAMPLECORP_PACKAGECLOUD_API_TOKEN, which we setup in our agent hook, for any distributionManagement repositories with an id of packagecloud-exampleCorp.</p><pre>&lt;settings xmlns=&quot;http://maven.apache.org/SETTINGS/1.0.0&quot;<br>  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;<br>  xsi:schemaLocation=&quot;http://maven.apache.org/SETTINGS/1.0.0<br>  http://maven.apache.org/xsd/settings-1.0.0.xsd&quot;&gt;<br>  &lt;servers&gt;<br>    &lt;server&gt;<br>      &lt;id&gt;packagecloud-exampleCorp&lt;/id&gt;<br>      &lt;password&gt;${env.EXAMPLECORP_PACKAGECLOUD_API_TOKEN}&lt;/password&gt;<br>    &lt;/server&gt;<br>  &lt;/servers&gt;<br>&lt;/settings&gt;</pre><h4>Step 2: Add the maven-packagecloud-wagon dependency</h4><p>Add the following to your pom.xml file. This allows Maven to natively deploy artifacts to the packagecloud API.</p><pre>&lt;build&gt;<br>  &lt;extensions&gt;<br>    &lt;extension&gt;<br>      &lt;groupId&gt;io.packagecloud.maven.wagon&lt;/groupId&gt;<br>      &lt;artifactId&gt;maven-packagecloud-wagon&lt;/artifactId&gt;<br>      &lt;version&gt;0.0.6&lt;/version&gt;<br>    &lt;/extension&gt;<br>  &lt;/extensions&gt;<br>&lt;/build&gt;</pre><p><em>Note: This is only needed for uploading artifacts. Any Maven-compatible build tool can use this repository without a plugin.</em></p><h4>Step 3: Add your packagecloud repository</h4><p>Add the repository you created to the distributionManagement section of your pom.xml. The id that we set here has to match the id in our .buildkite.settings.xml file. In our case, we are using packagecloud-exampleCorp and pushing artifacts to the exampleCorp/main repository we created earlier in this post.</p><pre>&lt;distributionManagement&gt;<br>  &lt;repository&gt;<br>    &lt;id&gt;packagecloud-exampleCorp&lt;/id&gt;<br>    &lt;url&gt;packagecloud+https://packagecloud.io/exampleCorp/main&lt;/url&gt;<br>  &lt;/repository&gt;<br>  &lt;snapshotRepository&gt;<br>    &lt;id&gt;packagecloud-exampleCorp&lt;/id&gt;<br>    &lt;url&gt;packagecloud+https://packagecloud.io/exampleCorp/main&lt;/url&gt;<br>  &lt;/snapshotRepository&gt;<br>&lt;/distributionManagement&gt;</pre><h4>Step 4: Push some code!</h4><p>When we push new code to our project, or create a pull request, it will trigger our Buildkite Agent to pull the code and run the step we’ve defined in our pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1NVfhdUbaDeVUQvR8rmAoQ.png" /><figcaption>Successful build!</figcaption></figure><p>You can also browse the packagecloud repository (see our public <a href="https://packagecloud.io/exampleCorp/main">exampleCorp/main</a> repository) and see the generated artifact along with its install instructions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1b0E34tr1qI-EiAIsh4MZA.png" /><figcaption>The published artifact and install instructions</figcaption></figure><h3>Conclusion</h3><p>With this setup complete your entire team will have an easily deployable set of artifacts for every commit, speeding up the integration cycle between interdependent teams and microservices. You’ll also reduce the risk of a “bad deploy” by having a centralised, automated and repeatable process that’s versioned, and tested, alongside your code.</p><p>Head to <a href="https://packagecloud.io/">packagecloud.io</a> and <a href="https://buildkite.com/">buildkite.com</a> to learn more. And you can find the source code for the example project <a href="https://github.com/computology/buildkite-maven-project">on GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc8c86f1e9b1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/building-buildkite/continuous-delivery-with-maven-buildkite-and-packagecloud-fc8c86f1e9b1">Continuous Delivery with Maven, Buildkite and packagecloud</a> was originally published in <a href="https://medium.com/building-buildkite">Building Buildkite</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>