BITBUCKET_BRANCH is empity in release/* branch

ceci82 March 9, 2018

I don't understand why the $BITBUCKET_BRANCH is empity in my release/1.1 branch.

 

# This is a sample build configuration for Java � Maven.# Check our guides at https://confluence.atlassian.com/x/zd-5Mw 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: maven:3.3.9
pipelines: branches: release/*: - step: caches: - maven - sonar script: - git clone -b $BITBUCKET_BRANCH ssh://bitbucket.org/${BITBUCKET_REPO_OWNER}/data-model.git - mvn -B -f data-model/data.model/pom.xml install - mvn -B -f std.proxy/pom.xml jacoco:prepare-agent verify -Psonar sonar:sonar master: - step: caches: - maven script: - git clone -b $BITBUCKET_BRANCH ssh://bitbucket.org/${BITBUCKET_REPO_OWNER}/data-model.git - mvn -B -f data-model/data.model/pom.xml install # installo il data-model nel repository locale dell'immagine docker # Ricavo le informazioni sull'identificaivo del progetto e della versione - "export PROJECT_ARTIFACT_ID=$(mvn -B -f web.server/pom.xml org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.artifactId | grep -Ev '(^\\[|Download\\w+:)')" - "export PROJECT_VERSION=$(mvn -B -f web.server/pom.xml org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '(^\\[|Download\\w+:)')" # Questo è il nome del pacchetto che verr� generato - export FULL_NAME=${PROJECT_ARTIFACT_ID}-${PROJECT_VERSION}.war - echo "Rename package file name" - mv sdt.proxy/target/${FULL_NAME} sdt.proxy/target/${PROJECT_ARTIFACT_ID}-${PROJECT_VERSION}-${BITBUCKET_COMMIT}.war - mvn -B -f web.server/pom.xml package -Pstage - curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"web.server/target/${PROJECT_ARTIFACT_ID}-${PROJECT_VERSION}-${BITBUCKET_COMMIT}.war"
definitions: caches: sonar: /root/.sonar/cache

3 answers

1 vote
ceci82 September 14, 2018

Thank you very much i solved it

Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 14, 2018

Brilliant! :D 

If you remember how you solved the problem, can you note it down here?

1 vote
Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 5, 2018

Can you please format your code with the "Code block" format option in the future.

I've formatted it for you here: (There may be some mistakes)

# This is a sample build configuration for Java Maven.
# Check our guides at https://confluence.atlassian.com/x/zd-5Mw 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.imagemaven:3.3.9
pipelines: 
branches: 
release/*: 
step: 
caches:
maven
 - sonar 
script: 
git clone -b $BITBUCKET_BRANCH ssh://bitbucket.org/${BITBUCKET_REPO_OWNER}/data-model.git 
mvn -B -f data-model/data.model/pom.xml install 
mvn -B -f std.proxy/pom.xml jacoco:prepare-agent verify -Psonar sonar:sonar 
master: 
step: 
caches: 
maven 
script
git clone -b $BITBUCKET_BRANCH ssh://bitbucket.org/${BITBUCKET_REPO_OWNER}/data-model.git 
mvn -B -f data-model/data.model/pom.xml install # installo il data-model nel repository locale dell'immagine docker # Ricavo le informazioni sull'identificaivo del progetto e della versione 
"export PROJECT_ARTIFACT_ID=$(mvn -B -f web.server/pom.xml org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.artifactId | grep -Ev '(^\\[|Download\\w+:)')" 
"export PROJECT_VERSION=$(mvn -B -f web.server/pom.xml org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '(^\\[|Download\\w+:)')" # Questo è il nome del pacchetto che verr� generato 
export FULL_NAME=${PROJECT_ARTIFACT_ID}-${PROJECT_VERSION}.war 
echo "Rename package file name"
mv sdt.proxy/target/${FULL_NAME} sdt.proxy/target/${PROJECT_ARTIFACT_ID}-${PROJECT_VERSION}-${BITBUCKET_COMMIT}.war 
mvn -B -f web.server/pom.xml package -Pstage 
curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"web.server/target/${PROJECT_ARTIFACT_ID}-${PROJECT_VERSION}-${BITBUCKET_COMMIT}.war"
definitions: 
caches: 
sonar/root/.sonar/cache
0 votes
Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 5, 2018

Hi Stefano,

Can you run the 'env' command at the start of your build. You should see a list of environment variables and their values. $BITBUCKET_BRANCH should be populated. It is probable that it is being incorrectly referenced somewhere, making it appear empty.

Which command does it specifically appear empty in? If it's the clone command, are there any specific error messages?

Thanks,

Phil

Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 5, 2018

You may also want to look at this question for information on cloning another repository into your build environment: https://community.atlassian.com/t5/Bitbucket-questions/How-can-I-use-SSH-in-Bitbucket-Pipelines/qaq-p/347345

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events