Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,872
Community Members
 
Community Events
165
Community Groups

Execute permission check fails on executable file

Edited

I've built custom docker image based on `ubuntu:21.04` for qt based android app development but encountered with weird bug when running `androiddeployqt` inside a pipelines.

java executable fails to test against execution permissions.

Here is log of pipeline execution:

Images used:
build : docker.io/siexp/docker-qt-android@sha256:d4752bfd6936dcfc8a9331c3a4b5099377a8f66a9ac23eb5dc527f569e1d06e1
+ JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre

+ ls -la /usr/bin/java
lrwxrwxrwx. 1 root root 22 Jun 16 13:14 /usr/bin/java -> /etc/alternatives/java

+ ls -la /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
-rwxr-xr-x. 1 root root 14632 Apr 21 10:25 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

+ if [ ! -x "$JAVA_HOME/bin/java" ] ; then echo "not an exec $JAVA_HOME/bin/java" ; fi
not an exec /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
...

+ /opt/Qt/5.15.2/android/bin/androiddeployqt --input android_deployment_settings.json --output android-build --apk $BITBUCKET_CLONE_DIR/build/debug.apk --android-platform android-29 --gradle

...
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-8-openjdk-amd64/jre

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

 

Problem is that  `/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java` is executable (I'm able to run it inside pipeline) however test for executable `-x` fails. I suppose it somehow related to selinux

P.S.

When I run pipeline commands inside docker locally everything works fine

1 answer

0 votes
Mark C Atlassian Team Sep 22, 2021

Hi @Mark Tsyrulnyk

Thank you for reaching out to the community.

Would it be possible for you to try to add the "export" command while setting your environment variable?
This is to make sure the variable is accessible to any process you run.

From:

JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre

To:

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre

Let me know how it goes.

Regards,
Mark C

This was my first guess when I tried to figure out what is a problem, unfortunately this is not a cause.

 

As you can see from the logs binary exist and JAVA_HOME variable is set

+ ls -la /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
-rwxr-xr-x. 1 root root 14632 Apr 21 10:25 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

+ if [ ! -x "$JAVA_HOME/bin/java" ] ; then echo "not an exec $JAVA_HOME/bin/java" ; fi
not an exec /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

 the problem is exactly in `-x` check.

 

My workaround was to modify `gradlew` file and comment out JAVA_HOME checks in there

Mark C Atlassian Team Sep 27, 2021

Hi @Mark Tsyrulnyk

I see.
I actually tried your base image (siexp/docker-qt-android) and the following commands with the -x flag.
However, I didn't receive the echo message "not an exec".

image: siexp/docker-qt-android@sha256:d4752bfd6936dcfc8a9331c3a4b5099377a8f66a9ac23eb5dc527f569e1d06e1

pipelines:
  default:
    - step:
        script:
          - JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
          - ls -la /usr/bin/java
          - ls -la /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
          - if [ ! -x "$JAVA_HOME/bin/java" ] ; then echo "not an exec $JAVA_HOME/bin/java" ; fi
          - echo "Done"

Are you using Bitbucket Pipelines Caches by any chance whereas you're caching the directories below?

  • /usr/bin/java
  • /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

Regards,
Mark C

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,130 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you