Continuous Delivery using JFrog Artifactory with Shippable

- By Manisha Sahasrabudhe

BACK TO BLOG HOME

We recently added a native integration with JFrog's Artifactory. You can push your versioned package to Artifactory after CI as explained in my previous blog. From Artifactory, you can deploy the package to a Test environment, and then promote the package through various environments and finally to production. You can also pull dependencies from Artifactory as part of your CI/CD workflows on Shippable.

JFrog's Artifactory is one of the most advaced repository managers available today. It is open source and especially popular with Java app developers and also Enterprises that want to self host a repository manager for their projects.You can learn more about Artifactory here.

This blog continues from where the earlier blog Pushing to JFrog Artifactory after CI left off. So it assumes that you have forked the sample project, set up CI, and pushed HelloWorld.war to your Artifactory account. This blog will deploy the WAR file to a beta environment running on a node cluster on Digital Ocean.

Enable sample project and push WAR to Artifactory

1. Complete all steps in the Pushing to JFrog Artifactory after CI blog

Create virtual machine(s)

2. Next, you should create one or more nodes on Amazon EC2 or Digital Ocean or anywhere you choose. Your will deploy your application to this node or nodes. We chose Digital Ocean's droplets while creating this sample but you can choose any IaaS of your choice. Our node had the following config:

  • Distribution: Ubuntu 16.04.1
  • Size: $20/mo 2CPUs, 2GB RAM, 30GB SSD
  • Block storage: None
  • Datacenter region: Our servers are on the east coast, so we recommend you choose one close to that,
  • Additional Options: None
  • SSH key: Add your machine's SSH key if you do not want to sign in to the node with a password each time
  • Choose number of droplets you want to deploy the application to, and names for each.

Install Tomcat 8 on your node(s)

3. Follow instructions to install Tomcat 8 on all your nodes in the cluster. Please note that as of the time this blog was published, the latest version of Tomcat is  8.5.9, so you will need to use the right version in the curl statement of the instructions.  

Add a node cluster integration to Shippable

4. You now need to add an integration for your nodes to your Shippable account so that your account has permissions to deploy to your nodes. To do this, follow instructions from the 'Add an account integration' section of the Node Clusters integration page.  Write down the integration name since this will be needed in the next step.

Edit the pipeline configuration

Your pipeline configuration is in the pipelines branch of your forked sample repository. You will need to make the following changes to the configuration:

5. Update shippable.resources.yml

  • Update the cluster resource demo-war-test-cls with the integration name from the previous step.
    - name: demo-war-test-cls
      type: cluster
      integration: #your node cluster integration
  • Update the demo-war resource that points to your WAR file on Artifactory. Also update the repository name if you pushed HelloWorld.war to a different repository from builds:
    - name: demo-war
      type: file
      integration: #your node cluster integration
      pointer:
      sourceName: builds/HelloWorld.war #update the repository name if needed
      seed:
      versionName: initial

6. Take a look at shippable.jobs.yml demo-war-manifest is a manifest job which creates a new manifest every time the WAR file on Artifactory is changed. demo-war-test-deploy is the deploy job which is triggered every time a new manifest is available. This job deploys the application to all nodes in your cluster.

Seed your pipeline

7. Next, you will need to add your pipeline config to your Shippable subscription. To do this, follow steps described in the 'Adding a seed repository' section in our docs. Please make sure you select the pipelines branch while setting up your sync repository.

Connect your CI to the newly created pipeline

Now that you have seeded your pipeline, you should connect it to your CI. On completing this step, every code change to your sample application will trigger a deployment to the node cluster we set up in previous steps.

8. Create an API token for your account. To do this, go to your Account Settings by clicking on the gear icon in the top navbar. Then click on API tokens in the left sidebar menu and create a token. Copy the token since you won't be able to see it again.

9. Next, create an Event Trigger integration. Go to Integrations in the left sidebar menu of Account Settings and then click on Add Integration. Select Event Trigger from the list and complete the settings as shown below. Please make sure you update the Authorization textbox in the format apiToken <token-value>. The resource name should be set to the file resource demo-war. Save the integration.

Screen Shot 2017-01-11 at 10.26.35 PM.png

10.  Update shippable.yml in the master branch of your forked repository.  Uncomment the notifications section and include the event trigger name you created in the earlier step.

 notifications:
  - integrationName: #your event trigger integration name
  type: webhook
  payload:
  - versionName=$BUILD_NUMBER
  on_success: always

Commit and push to the master branch of your forked repository. 

Run your end to end pipeline

11. This will automatically run a CI build for the forked repository. This will push a new version of HelloWorld.war to your Artifactory account. Your pipeline will now detect tha new WAR file version and trigger the manifest job demo-war-manifest. This will in turn trigger the deploy job demo-war-test-deploy.  

jfrog-artifactory-continuous-delivery.png

 

Verify your deployed application

Your application should be deployed to http://<your-node-url>:8080/HelloWorld if your pipeline deploy job finishes successfully.

 hello-world-artifactory.png

Additional steps

If you're interested in learning more about extending this pipeline through multiple environments, creating releases, promoting versions through environments, etc, check out our Continuous Delivery Pipelines documentation.

Try this tutorial today and let us know what you think! You can get a Shippable account for free by signing in below.

Try Shippable 

Topics: continuous deployment (CD), continuous integration (CI), continuous delivery, artifactory, java