Tag

atlassian

Continuous Delivery

Catch your continuous integration and deployment pipeline today

My review of Bitbucket pipeline beta

Screen Shot 2016-07-24 at 4.30.21 PM

So you would like to build, test and deploy your code continuously  but don’t want to install and configure your local instances of Jenkins or Bamboo (Check out our thoughts on both tools), you don’t have to anymore. Atlassian is replacing its Bamboo on Cloud offering with Bitbucket pipeline. This offering is for small and medium sized businesses.

I recently signed up for the Bitbucket pipeline beta program at bitbucket.org and got accepted a month ago. Read on for my sum up of this new Atlassian offering

Key features:

  1. A continuous integration (CI) and Continuous deployment (CD) engine is ready for use on any of your git or mercurial repositories by just adding a bitbucket-pipeline.yml file in your project root. You pipeline is triggered as soon a change is pushed to any or a selected branch. See the below simple example of the bitbucket-pipeline.yml file.
    image: node:5.11.0
    pipelines:
      default:
        - step:
            script:
              - echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'."
      branches:
        master:
          - step:
              script:
                - echo "This script runs only on commit to the master branch."
        feature/*:
          - step:
              image: java:openjdk-9 # This step uses its own image
              script:
                - echo "This script runs only on commit to branches with names that match the feature/* pattern."
  2. Employs docker images to build, test and deploy your code. Out of the box has images for the following languages Screen Shot 2016-07-24 at 6.07.10 PM 
  3. Support for builds in any docker image. You can build your own docker image with your language support and build it using the pipeline. Docker images for additional languages below are available at  docker hub.

    I needed a docker image that has the atlassian sdk that is built on top of maven to build my sample atlassian plugin. I used a docker image built by Translucent. You can get it at the docker hub. Take a look at my bitbucket.pipeline.yml file below or get the entire source at github

    image: translucent/atlassian-plugin-sdk
    
    pipelines:
      default:
        - step:
            script: # Modify the commands below to build your repository.
              - cd adminUI
              - pwd
              - atlas-version
              - atlas-mvn clean install
  4. Environment variables allow passing security parameters and other configurable variables.  You can write scripts in the yml file or invoke nested scripts from your project folder.
  5. Community support is increasing and well documented
  6. Several integration images are available to test, monitor and deploy your code.Screen Shot 2016-07-24 at 6.26.01 PM

The appeal:

  • Simple to configure and you can start building with a flip of a switch
  • Simple architecture and ability to invoke parallel scripts and trigger different docker images delivers great scalability
  • Industry supported docker images and ability to create your own images makes this offering flexible

 Limitations:

  • No Email and HipChat notifications
  • No Jira integration
  • Build speeds and concurrency is limited

The product is still in Beta, but will appeal to most due to its simplicity and integrated seamlessly into the Bitbucket UI.

Feel free to share your experience

 

Continuous Delivery

5 tips on developing your first Atlassian server plugin

We at Nimble love to develop and experiment with different technologies and share our experiences with our community. This time around developing an Atlassian plugin became our fancy. Atlassian of course offers tools for development, collaboration and continuous delivery such as Jira, Confluence, Bitbucket and Bamboo. Atlassian also offers a rich REST API to build integrations and plugins that one can add/extend their basic tool functionality.

So I started on my journey and found a few gotchas that I think are interesting if you happen to go down that path.

1. The basics

a. Sign up for an account at http://developers.atlassian.com. Atlassian offers two plugin development SDKs for their cloud based and their in-house server based versions.

b. Consider signing up for an account at bitbucket.org if you don’t already have a SCM or if you want to try out a nice cloud based code collaboration tool that provides Git repos to host your code and also offers integration with several tool suites including a cloud based continuous integration and delivery tool. More on this later…

2. Issues with the tutorial

I started exploring the server side development and accessed the tutorial at https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project. The tutorial does a great job at the setup and gets you going, but it is dated.

Most of my time really went into trouble shooting issues with dependencies in pom.xml and conflicting directives in the plugin config file: atlassian-plugin.xml

Following a few sub links in the tutorial:

You are directed to convert the plugin component to a servlet model at https://developer.atlassian.com/docs/getting-started/learn-the-development-platform-by-example/convert-component-to-servlet-module by adding the following lines in the atlassian-plugin.xml

<component key="myPluginComponent" class="com.atlassian.plugins.tutorial.refapp.MyPluginComponent" public="true">
 <interface>com.atlassian.plugins.tutorial.refapp.MyPluginServlet</interface>
</component>
<servlet name="adminUI" class="com.atlassian.plugins.tutorial.refapp.MyPluginServlet" key="test">
 <url-pattern>/test</url-pattern>
</servlet>

Next there are SAL (Secure Access Layer) class components that need to be imported into the project. Look at https://developer.atlassian.com/docs/getting-started/learn-the-development-platform-by-example/control-access-with-sal which directs you to add the following lines to your atlassian-plugin.xml

<component-import key="templateRenderer" interface="com.atlassian.templaterenderer.TemplateRenderer" filter=""/>
<component-import key="userManager" interface="com.atlassian.sal.api.user.UserManager" filter=""/>
<component-import key="loginUriProvider" interface="com.atlassian.sal.api.auth.LoginUriProvider" filter=""/>
<component-import key="pluginSettingsFactory" interface="com.atlassian.sal.api.pluginsettings.PluginSettingsFactory" filter=""/>

Compiling this code promptly delivers an error messsage while using the latest version of Atlassian spring scanner and JDK 1.8.  The error message is that servlet directive and the component import tags are not compatible

After a lot of time troubleshooting, I hit upon the reason. The latest version of spring scanner supports annotations instead of tags. Take a look at the revamp suggested at https://bitbucket.org/atlassian/atlassian-spring-scanner

The Atlassian-plugin.xml file should not contain any of the <component-import> tags  and in your servlet code add annotations such as the below

@ComponentImport
private final UserManager userManager;
	
@ComponentImport
private final LoginUriProvider loginUriProvider;
	
@ComponentImport
private final TemplateRenderer templateRenderer;
	
@ComponentImport
private final PluginSettingsFactory pluginSettingsFactory;

This needs to be updated in the tutorial.

3. Use a RefApp

Instead of developing for a particular tool like jira or confluence, developing for RefApp gives you the flexibility of completing your plugin development irrespective of the tool and then generating a plugin version for the target tool. RefApp provides the shared framework between all Atlassian applications. This means that you can develop your plugin without accidentally relying on dependencies or features specific to one application, or encountering an application-specific bug later on. Developing a plugin with RefApp eliminates guesswork about the functionality of your project. You can rest assured that since all Atlassian applications share at least the framework present in RefApp, your plugin will work as expected.

 4. Leverage bitbucket pipeline

One of the other advantages of hosting your code at bitbucket.org is that you can use Bitbucket pipeline. Bitbucket pipleline is a new offering and still in beta. I happen to be part of the beta program and got an opportunity to kick the tires. In short the tool is a continuous integration and continuous delivery tool that relies on the presence of a bitbucket-pipelines.yml file in your top level of your project. The yml file with the below directives helped me build my plugin on the cloud. The pipeline relies on running builds, tests and deployment with pre-configured docker images. Anytime you update your code, the pipleline runs based on the directives as in the below yml file.

# You can use a Docker image from Docker Hub or your own container
# registry for your build environment.

image: translucent/atlassian-plugin-sdk

pipelines:
  default:
    - step:
        script: # Modify the commands below to build your repository.
          - cd adminUI
          - pwd
          - atlas-version
          - atlas-mvn clean install

 

5. Develop an Atlassian plugin like its 2016

Some interesting ideas to explore once you have the basic tutorial up and running is how to take your plugin to the next level with ideas on how data should be retrieved only using the REST API and UI should be rendered on the client site by adding javascript libraries such as Babel and Webpack

Take a look at the details at the following two write ups….

https://developer.atlassian.com/blog/2016/06/jira-add-on-dev-2016-part-1/

https://developer.atlassian.com/blog/2016/06/jira-add-on-dev-2016-part-2/

You can find my latest code and use to kick start your plugin development at https://github.com/aniljaising/atlassian-plugin-tutorial

I would love to get your feedback on this article as well feel free to ask any questions…