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

pipeline fails without error message when set the variable

Victor Scurtu September 17, 2023

Here is the command which works in a git bash and fails in the pipeline.
No error messages in the log.

CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout);

 

However this line works fine in both:

- PREVIOUS_VERSION=$(cat previous_version.txt);

Please advise.

 

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 18, 2023

Hi Victor,

Is there a property <version> in the pom.xml of your repo, at the commit that this build is running for? I can reproduce this error if the pom.xml doesn't have the <version> property for the <project>.

In case that property exists at the commit that this build is running for, I would suggest the following:

  • Add at the beginning of the script in the bitbucket-pipelines.yml file the command set -x
  • Add the expression as a separate command in the script in the bitbucket-pipelines.yml file so we can see if there is any output
  • Add the following command as well, which, instead of -q uses -X, to see more verbose output
    mvn help:evaluate -Dexpression=project.version -X -DforceStdout

Afterwards, you can post the output of the commands here so we can take a look.

It would also be useful to know the following:

  • Does this build run on Atlassian infrastructure or are you using one of our Runners?
  • In case it runs on Atlassian infrastructure or on a Linux Docker runner, what Docker image are you using as a build container for the step with this command?

Please feel free to let me know if you have any questions.

Kind regards,
Theodora

Victor Scurtu September 22, 2023

Thank you Theodora!

1. Yes, The version property is in pom-file.

<version>0.0.8-SNAPSHOT</version>

2.  The build runs on Atlassian infrastructure and the image pulled by pipeline is

image: maven:3.6.3

3. I set -X, but still no joy. Here is the raw output.
**********************************************************************************

+ umask 000

+ GIT_LFS_SKIP_SMUDGE=1 retry 6 git clone --branch="azure-pipelines" --depth 50 https://x-token-auth:$REPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/$BITBUCKET_REPO_FULL_NAME.git $BUILD_DIR
Cloning into '/opt/atlassian/pipelines/agent/build'...

+ git reset --hard 765842d2ee65f64ea9ae230bea06b18f20d49ce5
HEAD is now at 765842d minor bug fix. added verbosity in bitbucket pipeline

+ git config user.name bitbucket-pipelines

+ git config user.email commits-noreply@bitbucket.org

+ git config push.default current

+ git config http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy http://localhost:29418/

+ git remote set-url origin http://bitbucket.org/$BITBUCKET_REPO_FULL_NAME

+ git reflog expire --expire=all --all

+ echo ".bitbucket/pipelines/generated" >> .git/info/exclude

+ chmod 777 $BUILD_DIR


Default variables:
BITBUCKET_BRANCH
BITBUCKET_BUILD_NUMBER
BITBUCKET_CLONE_DIR
BITBUCKET_COMMIT
BITBUCKET_GIT_HTTP_ORIGIN
BITBUCKET_GIT_SSH_ORIGIN
BITBUCKET_PIPELINE_UUID
BITBUCKET_PROJECT_KEY
BITBUCKET_PROJECT_UUID
BITBUCKET_REPO_FULL_NAME
BITBUCKET_REPO_IS_PRIVATE
BITBUCKET_REPO_OWNER
BITBUCKET_REPO_OWNER_UUID
BITBUCKET_REPO_SLUG
BITBUCKET_REPO_UUID
BITBUCKET_SSH_KEY_FILE
BITBUCKET_STEP_RUN_NUMBER
BITBUCKET_STEP_TRIGGERER_UUID
BITBUCKET_STEP_UUID
BITBUCKET_WORKSPACE
CI
DOCKER_HOST
PIPELINES_JWT_TOKEN

Workspace variables:
AZURE_ARTIFACTS_PAT
CURRENT_VERSION
PREVIOUS_VERSION

Images used:
build : docker.io/library/maven@sha256:.......xx.xx.x.0a3df6
+ PREVIOUS_VERSION=$(cat previous_version.txt);

+ echo "Previous version $PREVIOUS_VERSION";
Previous version 0.0.8-SNAPSHOT

+ CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -X -DforceStdout);
Searching for test report files in directories named [test-results, failsafe-reports, test-reports, TestResults, surefire-reports] down to a depth of 4
Finished scanning for test reports. Found 0 test report files.
Merged test suites, total number tests is 0, with 0 failures and 0 errors.

Victor Scurtu September 22, 2023

As you may see, there is no error message in the log ... It just fails on that line.

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 25, 2023

Hi Victor,

Thank you for the info. I still cannot reproduce this error (unless the property is missing) when I use image: maven:3.6.3.

I can see in the build log that this build runs for the branch azure-pipelines. Could you please double-check if the property <version> is in the pom.xml of that branch? When viewing the source code of the repo on our website, there is a dropdown to switch branches right above the file list.

Could you also try my other suggestion by adding the following commands in the yml file's script? You can then post the output of the second command here.

- set -x
- CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout);

With the set -x, the second command may print any errors.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events