Hello! Alexey Matveev here.

If you develop a Jira app, you use Atlassian SDK. If you want to test your app, you run Atlassian Jira from Atlassian SDK. In this article, I’ll show you how to combine those steps and run a Jira instance from Atlassian SDK in a docker container.

To repeat the steps in this tutorial, you need to have docker installed on your PC.

 

Build docker image

To build a docker image, you need a Dockerfile. Here’s an example of a Dockerfile (you can find it here):

FROM openjdk:11

# Maintainers on this project are the following:
MAINTAINER Alexey Matveev <ru.matveev.alexey@gmail.com>

RUN echo "deb https://packages.atlassian.com/atlassian-sdk-deb stable contrib" >>/etc/apt/sources.list \
    && wget https://packages.atlassian.com/api/gpg/key/public  \
    && apt-key add public \
    && apt-get update \
    && apt-get install --yes atlassian-plugin-sdk \
    && mkdir /opt/atlas \
    && cd /opt/atlas


CMD ["atlas-debug"]

What is going on in this docker file?

FROM openjdk:11

This line says that I’m building this image from the openjdk:11 image, which means that I will have openjdk 11 installed. If you want to use another version of Java, then use something like this to use openjdk 8:

FROM openjdk:8

or something like this:

FROMjava:8-jdk

In this case, you will use Oracle JDK 8.

RUN echo "deb https://packages.atlassian.com/atlassian-sdk-deb stable contrib" >>/etc/apt/sources.list \
    && wget https://packages.atlassian.com/api/gpg/key/public  \
    && apt-key add public \
    && apt-get update \
    && apt-get install --yes atlassian-plugin-sdk \
    && mkdir /opt/atlas \
    && cd /opt/atlas

This line does the job. It installs the latest version of Atlassian SDK to our new image. If you want to use a certain version of Atlassian SDK, then change it to this one:

RUN echo "deb https://packages.atlassian.com/atlassian-sdk-deb stable contrib" >>/etc/apt/sources.list \
    && wget https://packages.atlassian.com/api/gpg/key/public  \
    && apt-key add public \
    && apt-get update \
    && apt-get install --yes atlassian-plugin-sdk=8.2.2 \
    && mkdir /opt/atlas \
    && cd /opt/atlas

Ok. Done with the Dockerfile. Let’s build our image.

Move to the folder where this Dockerfile is placed and run the following command:

docker build --tag atlassian-sdk ./

As a result of the command, an image with tag “atlassian-sdk” will be created. If you want to tag your image somehow else then replace Atlassian-SDK with your own name.

Here is the output of the build command in my PC:

Alexeys-MBP-2:docker-atlassian-plugin-sdk alexm$ docker build --tag atlassian-sdk ./
Sending build context to Docker daemon  197.1kB
Step 1/4 : FROM openjdk:11
 ---> a16650ebd079
Step 2/4 : MAINTAINER Alexey Matveev <ru.matveev.alexey@gmail.com>
 ---> Running in fb1180b01fdf
Removing intermediate container fb1180b01fdf
 ---> ddeb6031a34b
Step 3/4 : RUN echo "deb https://packages.atlassian.com/atlassian-sdk-deb stable contrib" >>/etc/apt/sources.list     && wget https://packages.atlassian.com/api/gpg/key/public      && apt-key add public     && apt-get update     && apt-get install --yes atlassian-plugin-sdk     && mkdir /opt/atlas     && cd /opt/atlas
 ---> Running in 6b2f4dfbc825
--2020-08-13 09:58:27--  https://packages.atlassian.com/api/gpg/key/public
Resolving packages.atlassian.com (packages.atlassian.com)... 52.215.192.157, 52.215.192.155, 52.215.192.156
Connecting to packages.atlassian.com (packages.atlassian.com)|52.215.192.157|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/plain]
Saving to: ‘public’

     0K .....                                                  58.4M=0s

2020-08-13 09:58:27 (58.4 MB/s) - ‘public’ saved [5352]

Warning: apt-key output should not be parsed (stdout is not a terminal)
OK
Get:1 http://deb.debian.org/debian buster InRelease [122 kB]
Get:2 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 https://packages.atlassian.com/atlassian-sdk-deb stable InRelease [3648 B]
Get:5 http://security.debian.org/debian-security buster/updates/main amd64 Packages [218 kB]
Get:6 http://deb.debian.org/debian buster/main amd64 Packages [7906 kB]
Get:7 https://packages.atlassian.com/atlassian-sdk-deb stable/contrib amd64 Packages [1788 B]
Get:8 http://deb.debian.org/debian buster-updates/main amd64 Packages [7868 B]
Fetched 8378 kB in 9s (902 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  atlassian-plugin-sdk
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 49.2 MB of archives.
After this operation, 68.0 MB of additional disk space will be used.
Get:1 https://packages.atlassian.com/atlassian-sdk-deb stable/contrib amd64 atlassian-plugin-sdk all 8.2.2 [49.2 MB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 49.2 MB in 39s (1268 kB/s)
Selecting previously unselected package atlassian-plugin-sdk.
(Reading database ... 12561 files and directories currently installed.)
Preparing to unpack .../atlassian-plugin-sdk_8.2.2_all.deb ...
Unpacking atlassian-plugin-sdk (8.2.2) ...
Setting up atlassian-plugin-sdk (8.2.2) ...
If you previously installed a version prior to version 4.0, you will need to remove all references to the atlassian-plugin-sdk directory from your PATH environment variable.
Removing intermediate container 6b2f4dfbc825
 ---> 4bd50cfcd874
Step 4/4 : CMD ["atlas-debug"]
 ---> Running in 0091181fa408
Removing intermediate container 0091181fa408
 ---> 9441e53a1b65
Successfully built 9441e53a1b65
Successfully tagged atlassian-sdk:latest


Use this image

Let’s run a standalone Jira with this image:

docker run -i -t -p 2990:2990 atlassian-sdk:latest atlas-run-standalone --product jira

After Jira is started you can see the following messages:

[INFO] [talledLocalContainer] Tomcat 8.x started on port [2990]
[INFO] jira started successfully in 1187s at http://localhost:2990/jira
[INFO] Type Ctrl-C to shutdown gracefully

You can open http://localhost:2990/jira in your browser and see this Jira instance running in docker:

Now we can try to install our plugin to this instance.

Go to the folder of your plugin and run the following command:

atlas-install-plugin

After some time of working I have the following output:

[INFO] Install Plugin: Uploading 'sil-tablegrid-next-generation-connector-1.0.4.jar' to server via UPM: http://localhost:2990/jira
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.156 s
[INFO] Finished at: 2020-08-13T12:47:33+03:00
[INFO] ------------------------------------------------------------------------

Now open manage apps in your Jira instance and you should see the plugin there:

As you can see the sil-groovy-runner app is there. But why is it disabled?

I believe in your case it will be enabled. In my case, this app should be installed on a Jira instance with SIL® Engine available. I do have this dependency in the pom.xml, and I run my app, not through the atlas-run-standalone command but atlas-debug command. How do you do it?

Stop the current container and remove it.


Run with atlas-debug

Move to the folder of your app and run the following command:

docker run -i -t --volume $(pwd)/:/opt/atlas:delegated -p 2990:2990 -p 5005:5005 atlassian-sdk:latest /bin/sh -c 'cd /opt/atlas; atlas-debug'

Here we mount the folder of our app to the /opt/atlas folder in the container and run atlas-debug from this folder in the container. Also, we mount 2990 and 5005 ports so that you would be able to use those ports from the host. 5005 is needed to debug your app.

After Jira is launched, open http://localhost:2990/jira in your browser and go to Manage Apps.

Our plugin is installed and enabled.

Now, let’s try to make a change to our app and see if the change will be seen in the docker.

Let’s open Groovy Editor in my app:

Before the Groovy Editor text field, let’s write WELCOME!

I made changes to the code and saved the file. Note: I made changes to a soy template which is why I don’t have to package my app. The changes should be visible now. Like so:

Success! Everything works as expected. Reach out if you find any issues that you need help to resolve.

 

ALEXEY MATVEEV
|  Software Developer for Cprime Apps

 

 

 

 

 



Tagged with: , , ,

Categorized in: , , , , ,