How to use python and java on drone.io?

505 Views Asked by At

I develop a python project which uses the package owlready2. For some of its functionality owlready2 explicitly makes calls like java -jar ... via the subprocess-package.

On my local machine this works fine. Now I want to setup CI with drone.io.

My current .drone.yml looks like this:

---
kind: pipeline
name: python-3-8

steps:
- name: test
  image: python:3.8
  commands:
  - pip install -r requirements.txt
  - pip install .
  - python -m unittest yamlpyowl.tests

In the test summary I get the error:

...
File "/usr/local/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'java'

which is quite logical as I use the image "python:3.8".

Question: How can I make java available on the testing machine?

2

There are 2 best solutions below

0
On BEST ANSWER

What you have to work with is defined by the Docker image you're specifying. You're using the standard python3.8 Docker image, so you only have Python available to you.

What you need is to find or produce a Docker image that contains both Python and Java toolsets, and make that available somewhere that Drone can get to it. That would likely be on DockerHub, which you can create an account on and use for free. I don't know if there is an image already on DockerHub that includes both toolsets. I would suggest that you go onto the DockerHub web site and search for such an image. If you can't find one, then you can create a Docker image of your own containing whatever you want/need, push it to DockerHub, and then reference it in your Drone build file.

0
On

Following the answer of @Steve I created an custom docker image in the repo: carvk/java_python.

Now the working .drone.yml read

---
kind: pipeline
name: python-3-8

steps:
- name: test
  image: carvk/java_python:openjdk15_python38
  commands:
  - pip install -r requirements.txt
  - pip install .
  - python -m unittest yamlpyowl.tests