It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Stash tutorial not working

I've been trying to get this stash tutorial wokring: https://developer.atlassian.com/stash/docs/latest/tutorials-and-examples/controlling-when-pull-requests-can-be-merged.html

However, I am getting the following maven errors:

Description	Resource	Path	Location	Type
Project build error: 'dependencies.dependency.version' for com.atlassian.stash:stash-api:jar is missing.	pom.xml	/is-admin-merge-check	line 1	Maven Problem
Project build error: 'dependencies.dependency.version' for com.atlassian.stash:stash-page-objects:jar is missing.	pom.xml	/is-admin-merge-check	line 1	Maven Problem
Project build error: 'dependencies.dependency.version' for com.atlassian.stash:stash-spi:jar is missing.	pom.xml	/is-admin-merge-check	line 1	Maven Problem
Project build error: Non-resolvable import POM: Failure to find com.atlassian.stash:stash-parent:pom:2.2.0 in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced	pom.xml	/is-admin-merge-check	line 1	Maven Problem

The POM file looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycompany</groupId>
    <artifactId>is-admin-merge-check</artifactId>
    <version>1.0-SNAPSHOT</version>

    <organization>
        <name>Example Company</name>
        <url>http://www.example.com/</url>
    </organization>

    <name>is-admin-merge-check</name>
    <description>This is the com.mycompany:is-admin-merge-check plugin for Atlassian Stash.</description>
    <packaging>atlassian-plugin</packaging>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.atlassian.stash</groupId>
                <artifactId>stash-parent</artifactId>
                <version>${stash.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-api</artifactId>
            <scope>provided</scope>
        </dependency>
       <dependency>
	        <groupId>com.atlassian.stash</groupId>
	        <artifactId>stash-spi</artifactId>
	        <scope>provided</scope>
	    </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-page-objects</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
        </dependency>

        <!-- WIRED TEST RUNNER DEPENDENCIES -->
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
            <version>${plugin.testrunner.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <version>1.1.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.2-atlassian-1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-stash-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <products>
                        <product>
                            <id>stash</id>
                            <instanceId>stash</instanceId>
                            <version>${stash.version}</version>
                            <dataVersion>${stash.data.version}</dataVersion>
                        </product>  
                    </products>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    
    <properties>
        <stash.version>2.2.0</stash.version>
        <stash.data.version>2.2.0</stash.data.version>
        <amps.version>4.1.6</amps.version>
        <plugin.testrunner.version>1.1.1</plugin.testrunner.version>
    </properties>
    
</project>

This POM file was generated by the atlas-create-stash-plugin SDK command, as specified in the tutorial.

I thought i would try removing the dependencyManagement section and putting the <version>${stash.version}</version> on each dependency that needed it, but I get the following errors:

Description	Resource	Path	Location	Type
Missing artifact com.atlassian.stash:stash-api:jar:2.2.0:provided	pom.xml	/is-admin-merge-check	line 1	Maven Problem
Missing artifact com.atlassian.stash:stash-page-objects:jar:2.2.0:provided	pom.xml	/is-admin-merge-check	line 1	Maven Problem
Missing artifact com.atlassian.stash:stash-spi:jar:2.2.0:provided	pom.xml	/is-admin-merge-check	line 1	Maven Problem

Does anyone know what might be wrong here?

Edit

The original failure (before I removed the servlet-api dependency) was this:

[ERROR]   The project com.mycompany:is-admin-merge-check:1.0-SNAPSHOT (/Users/me/repos/stash-example-plugin/is-admin-merge-check/pom.xml) has 5 errors
[ERROR]     Non-resolvable import POM: Failure to find com.atlassian.stash:stash-parent:pom:2.2.0 in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced @ line 23, column 25 -&gt; [Help 2]
[ERROR]     'dependencies.dependency.version' for com.atlassian.stash:stash-api:jar is missing. @ line 34, column 21
[ERROR]     'dependencies.dependency.version' for com.atlassian.stash:stash-spi:jar is missing. @ line 39, column 21
[ERROR]     'dependencies.dependency.version' for com.atlassian.stash:stash-page-objects:jar is missing. @ line 44, column 21
[ERROR]     'dependencies.dependency.version' for javax.servlet:servlet-api:jar is missing. @ line 49, column 21

1 answer

1 accepted

1 vote
Answer accepted

Hi Annie,

It looks like you're just using the default maven repositories, which won't include the required Stash artifacts.

https://developer.atlassian.com/display/DOCS/Atlassian+Maven+Repositories

My understanding is that using the Atlassian SDK atlas commands should correctly resolve the dependencies from Atlassian's maven repositories. You should be able to use atlas-mvn and the like which will use the correct settings.xml.

I hope this helps.

Charles

Ooh, it looks like I've been using my own previously installed version of maven to do the builds, rather than the one included in the /usr/share/atlassian-plugin-sdk-4.1.6/apache-maven SDK folder.

Might be a good idea to add this requirement to this prerequisites page?

https://developer.atlassian.com/display/DOCS/Set+up+the+SDK+Prerequisites+for+Linux+or+Mac

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published Mar 14, 2019 in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

1,007 views 1 16
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you