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
Community Members
Community Events
Community Groups

BitBucket Pipelines Gradle build



I'm wondering how to build a Java code repository with Gradle using Bitbucket pipelines.

I've currently got this code, but the build is always failing:


# This is a sample build configuration for Gradle.
# Check our guides at for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: java:8

    - step:
        script: # Modify the commands below to build your repository.
          - gradlew --version
          - gradlew build


I've also have the gradlew.bat and gradlew file in my repository and in the folder gradle under wrapper the gradle-wrapper.jar (and some scripts to be executed from the build.gradle).

Because I want to try Bitbucket pipelines on my Minecraft Mod out, gradle would also have to download some stuff to be able to compile the src code.

Currently it works all well on my local Windows machine, but on Bitbucket I'm getting the following error:

bash: gradlew: command not found

Thx in advance.

2 answers

1 accepted

2 votes
Answer accepted
xtjhin Atlassian Team Jan 11, 2017

Hey @MinecraftPlaye,

The gradlew is a script so you will need to execute it like a script.


    - step:
        script: # Modify the commands below to build your repository.
          - ./gradlew --version
          - ./gradlew build

Let me know how that goes

Sadly, it does not work:

bash: ./gradlew: Permission denied

Hm, wat I'm wondering, if it dienies me the permission to do that, will it denie me the permission to change a file with the gradlew setup (actually, after building it increases the version number automatically in the file wink )


I just did some changes after some research: I added the bash keyword before every single of the two commands and now it's working. wink

Like Brijesh Joshi likes this
xtjhin Atlassian Team Jan 12, 2017

Great to hear it's working! smile

Another workaround for the permission denied is to commit the gradlew file with executable permissions.

To make a file executable in Windows maybe try


Here is my gradle script, to build and create EAR file for my project.

# You can specify a custom docker image from Docker Hub as your build environment.
image: qlik/gradle
    - step:
          - gradle clean
          - gradle test
          - gradle ear

Previously above script was working perfect (i was getting my ear ) from last two months , but today when i start build, it fails on clean command i.e

gradle clean 

+ gradle clean/tmp/ line 22: gradle: command not found+ gradle clean/tmp/ line 22: gradle: command not found


Can any body help me ? 

@Kashif-Ur-Rehman can you rerun that Pipeline? Is that issue still occurring?

@Philip Hodder, yes , i rerun this yesterday and today, and now it is working fine.
I dont know reason, that why same script was not running previous week ..

Do you have any idea ? 

My apologies @Kashif-Ur-Rehman. That was a bug that we accidentally introduced into the system last week. Specifically, we made a change to the way that we mount volumes inside the Docker container of your pipeline. We were able to detect, revert, and fix the issue before it was exposed to most of our users, but you seem to have unfortunately been affected by it.

Your script itself was not the problem and you should not encounter this issue anymore. smile

Oh I see, BTW, previous week I was changing my script with different docker images, I thought may be docker image got change, but it was not.

Any how, thanks for detailed explanation. 

Im am also experiencing this issue in some of our Pipeline branches:

/opt/atlassian/pipelines/agent/tmp/ line 16: grails: command not found

Is there a way how I can fix this by myself @Philip Hodder?  



It should be fixed for you too now. But if not (let me know if you're still seeing it), installing dependencies (such as grails) as part of you pipeline, or burning them inside your Docker image, should be a sufficient work around.

0 votes

Hello everybody!

I've recently gotten the same issue. 3 weeks ago my pipeline was working and now it throws an error message "bash: gradle: command not found".  @Philip Hodder is this problem similar to the previous ones?

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events