Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Multi step pipeline not caching built jars

locus2k
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 8, 2018

I have a project that requires a jar to be built prior to the main application being built. I created a multi-step pipeline with the first step is to clone and install the first jar (its a private jar thats not available on the maven central repository). Everything worked fine until i tagged the required jar as a RELEASE. Now when i run the build it says it cant find the jar because its trying to reach out to the maven central repository for the file even though it was already built. The only way I was able to solve the problem was to combined the two steps into 1.

 

Here is the pipeline file I am using

 

pipelines: 
default:
-
step:
name: Commons build
image: maven:3.3.9
caches:
-
maven
-
node
script:
-
git clone git@bitbucket.org:locus2k/commons.git --branch 1.1.0-RELEASE
-
mvn -B install -f commons/pom.xml
artifacts:
-
target/*.jar
-
step:
name: Portal build
image: maven:3.3.9
size: 2x
caches:
-
maven
-
node
script:
- mvn -s pipeline-settings.xml -B install # -B batch mode makes Maven less verbose
services: - mysql
definitions:
services:
mysql:
image: mysql:8.0.11
environment:
MYSQL_DATABASE: 'portal'
MYSQL_ROOT_PASSWORD: 'let_me_in'

 Is there anyway to specify the order in which the pipeline tries to find the jars? first locally then try to download it. I want to try to keep the two steps as they are and not combine them.

1 answer

0 votes
StannousBaratheon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 13, 2018

Hi @locus2k

Edit: My apologies I just saw that you're already using artifacts. I'll investigate this further and provide another recommendation.

Each step in Pipelines is a new environment. You can copy state from one step to another using artifacts. Please see the following page of our documentation for further information: https://confluence.atlassian.com/bitbucket/using-artifacts-in-steps-935389074.html

Regards

Sam

StannousBaratheon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 13, 2018

When using release artifacts maven first looks in the local .m2 directory and if not present it then checks the remote repository.

You're currently sharing the artifact from the target directory which the maven process in the second step will not use. You must copy the jar from target to the appropriate location under ~/.m2 in order for it to be found by the second step.

The reason this works when the steps are combined is because maven also installs dependencies in the local .m2 directory.

I hope this helps. For more information about maven's local repository please see the following references:

https://maven.apache.org/guides/getting-started/index.html#How_do_I_create_a_JAR_and_install_it_in_my_local_repository

https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events