How to extract POM version in jobs

Deploying to AWS Elastic Beanstalk (or a PaaS provider that accepts versioning of artifacts) require something like the following:

      - image: circleci/python:2.7
      - attach_workspace:
          at: /tmp/workspace
      - run: sudo pip install awscli
      - run: aws s3 cp /tmp/workspace/myapp-0.0.1-SNAPSHOT.jar s3://my-bucket --region us-east-1
      - run: aws elasticbeanstalk create-application-version --application-name myapp --version-label 0.0.1-SNAPSHOT --source-bundle S3Bucket="my-bucket",S3Key="myapp-0.0.1-SNAPSHOT.jar"

The question is, how can I pass the version information (namely 0.0.1-SNAPSHOT in this instance) from one job to another? This information is embedded in the pom.xml on the source code?

It does not appear there is a clean way to ask maven nicely for the project.version variable

If this data is available in the first job, have a look at workspaces. Workspaces are a way of declaring that a specified directory is to be preserved across a workflow. I would assume, then, that you could persist information in a text file, and then restore it in each job that you want to use it in.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.