Search This Blog

Friday, 28 June 2019

Deploy Artifacts from JFrog Artifactory to PCF directly from IntelliJ IDEA using Spinnaker

Spinnaker is an open-source, multi-cloud continuous delivery platform that helps you release software changes with high velocity and confidence. In the demo below we will show how to deploy an Spring boot application deployed to JFrog Artifactory which Spinnaker watches for changes through a trigger and then deploys to PCF

This demo assumes you have the following:
  • A JFrog Artifactory repository configured to accept a Maven artifact—the JAR for your application (Spring Boot JAR in this example)
  • Spinnaker 1.14.7 or later installed on a k8s cluster


Setup JFrog Artifactory 

As a Maven repository, Artifactory is both a source for artifacts needed for a build, and a target to deploy artifacts generated in the build process. For more details on how to set that up refer to this short video if required

In this screen shot below it's shows we are ready to use JFrog Artifactory as our maven repository

Configure Spinnaker

1. Connect to Halyard pod as shown below

$ kubectl exec --namespace default -it myspinnaker-spinnaker-halyard-0 bash

2. Enable the Artifactory repository

$ hal config repository artifactory enable

3. Add a search for your repository

$ hal config repository artifactory search add spring-artifactory --base-url --repo libs-release-local --groupId com.example --username admin --password

4. Enable the Maven artifact provider

$ hal config artifact maven enable

5. Add an artifact account for Maven

$ hal config artifact maven account add spring-artifactory-maven --repository-url

6. Apply your changes

$ hal deploy apply

Configure Spring Boot Application

1. To deploy build artifacts through Artifactory you need to add a deployment element with the URL of a target local repository to which you want to deploy your artifacts. You can find this in the "Set Me Up " wizard for your maven repository in JFrog Artifactory

2. Copy the pom.xml entry and place into your local maven project POM file as shown below

Basic Spring Boot project as follows for this:

Configure Spinnaker Pipeline

1. Create a new pipeline for your application. In the pipeline configuration, add an Artifactory trigger to the Automated Triggers, as shown below. We are referencing what we created above in Spinnaker

2. In the Artifact Constraints dropdown for the Artifactory trigger, select “Define a new artifact…” and populate the Expected Artifact form with the details of the artifact that will be published to the Artifactory repository

3. Add a “Deploy” stage to the pipeline which will simply just deploy our application to PCF.

Now we are ready to Publish the application artifact to the Artifactory repository

Kick if off

To verify our setup we just need to do a "mvn deploy" from the local spring boot maven project as shown below

1. Deploy the artifact JAR using "mvn deploy" as shown below from your local maven project which will publish the artifact to your JFrog Artifactory maven repo.

$ mvn deploy

Output from command above

[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ spinnaker-artifactory-demo ---
Uploading to central:
Uploaded to central: (17 MB at 83 kB/s)
Uploading to central:
Uploaded to central: (1.8 kB at 886 B/s)
Downloading from central:
Downloaded from central: (424 B at 671 B/s)
Uploading to central:
Uploaded to central: (368 B at 218 B/s)
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  03:33 min
[INFO] Finished at: 2019-06-28T09:59:00+10:00
[INFO] ------------------------------------------------------------------------

2. Verify from spinnaker that your artifactory trigger has fired

3. From PCF applications manager we will see our deployed application using the server group settings we used and the artifactory published JAR we used

4. Once pipeline is complete you can view information of what was created and the various stages as shown below

More Information

Deploy Artifacts from Artifactory to CF

No comments: