Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,554,380
Community Members
 
Community Events
184
Community Groups

Bitbucket pipeline/artifactory: environmental variables in gradle.build file not recognized

Edited

I have a bitbucket pipeline script and a version.sh bash script that are playing nicely. The pipeline will call the version script and there are environment variables inside version.sh that are referenced correctly by bitbucket (I added the variables in settings for the repo).

However, I also have variables now in my gradle.build file, but these keep giving me errors in the pipeline when I try a gradle build.

The error I keep getting is could not get unknown property '$context_url' for root project 'my_project' of type org.gradle.api.Project.

The variables are in the artifactory/publish section:

artifactory {    
contextUrl
= $context_url publish {
repository
{
repoKey
= 'repo'
username
= $artifactory_user password = $artifactory_password }
defaults
{
publications
('mavenJava')
publishArtifacts
= true
publishPom
= true } } }

I've tried different syntax in the gradle.build file, such as:

  • $context_url
  • '$context_url'
  • "$context_url"

The variables work locally, I have the variables stored in my personal ~/gradle/gradle.properties file.

Not sure what else to try.

2 answers

In bitbucket, I defined a workspace variable

ORG_GRADLE_PROJECT_artifactory_user

which gradle interprets as the 'artifactory_user' property.

0 votes
Jeroen De Raedt
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Nov 19, 2018

Hi @Matt Takao,

Take a look at this tutorial: https://medium.com/@ubuntudroid/handling-environment-variables-in-gradle-fb1b8bb6c758 (specifically the last section: "In case you want to be able to provide the token in both ways ...). 

This should give you a way to use the variables from your local gradle.properties file when you are developing on your local machine - or from environment variables when running in the Bitbucket Pipelines environment. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events