If you develop a Jira app then you use Atlassian SDK. If you want to test your app you run Atlassian Jira from Atlassian SDK. In this article I will show you how you can 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 is an example of a Dockerfile (you can find it here):
FROM openjdk:11 # Maintainers on this project are the following: MAINTAINER Alexey Matveev <firstname.lastname@example.org> 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?
This line says that I am building this image from the openjdk:11 image, which means that you will have openjdk 11 installed. If you want to use another version of Java then use something like this to use openjdk 8:
or something like this:
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 <email@example.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)... 184.108.40.206, 220.127.116.11, 18.104.22.168 Connecting to packages.atlassian.com (packages.atlassian.com)|22.214.171.124|: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  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  [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:
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 would like to run my app not through the atlas-run-standalone command but atlas-debug command. How to 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 was started we open http://localhost:2990/jira in our 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. I made changes to a soy template that is why I do not have to package my app. The changes should be visible now. Let’s have a look:
Everything works as expected!
That is all for now.