Pushing to JFrog Artifactory after CI

- By Manisha Sahasrabudhe on January 11, 2017

We recently added  a native integration with JFrog's popular artifact repository, Artifactory. You can now add your JFrog credentials to your Shippable account and then perform the following actions as part of your CI/CD workflow:

  • Pull dependencies from Artifactory
  • Push files, versioned packages, or artifacts to Artifactory
  • Trigger your continuous delivery pipelines if a file/package stored in your Artifactory account changes

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.

Let us see how this works with a sample project which builds the sample code and creates a .war file which is then pushed to Artifactory. Follow the step by step directions below to set up CI for the project and push to Artifactory.

Fork and enable the sample project from GitHub

1. Fork the sample project.

2. Create an account or sign in to your existing account on the Shippable website.

3. Enable your forked repo as a project on Shippable. 

Add an Artifactory integration

4. Create an Account Integration to store your authentication credentials for JFrog Artifactory. While creating the integration, make sure you choose the subscription where you forked the sample repository so the credentials can be used there. Write down the name you choose for your integration since this is required for the next step.

Edit the yml config

Your shippable.yml contains the build configuration for your project. At a high level, the yml specifies drydock/u14 as the build image, installs Apache Maven and reads from pom.xml at the root of the repository to create a HelloWorld.war. This WAR file is then pushed to Artifactory. The integrations section includes a pointer to the integration for Artifactory. Read more about shippable.yml.

5. Change shippable.yml in your forked repository to include your integration name from the step above:

    - integrationName: #your artifactory integration name
      type: artifactory

Include your integration name instead of the comment. 

6. This yml assumes that your Artifactory account has a repository called builds. You can either create this repository and ensure that the credentials you used in the integration (step 4) have permissions to push to it. Alternatively, edit shippable.yml to replace builds with the repository name you want to push to. 

7. Commit and push to your forked repository. 

Run a build  

8. Commiting the changes above should trigger a build on Shippable automatically. Go to your Shippable account and navigate to your Subscription where the repository was forked. You can do this by clicking on the menu icon at the top left of your Dashboard and clicking on the Subscription name.

9. You should see the build you triggered on your Subscription's page. 


Verify the result

10. You can now go to your Artifactory account and verify that HelloWorld.war was pushed to the repository you specified.

That concludes part I of this tutorial showing you how you can push a WAR file to JFrog's Artifactory. Similarly, you can push any file you want to your Artifactory account. If you're using Docker, you can push your Docker image to Artifactory as well.

In part II of this tutorial, I will show you how to trigger your Continuous Delivery pipelines when your WAR file hosted on Artifactory changes. Stay tuned.

Topics: Github, Docker, Bitbucket, artifactory, java