Skip to content

Commit 47d9f5a

Browse files
committed
INIT repository
0 parents  commit 47d9f5a

File tree

11 files changed

+273
-0
lines changed

11 files changed

+273
-0
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[*.java]
2+
indent_style = tab
3+
indent_size = 4

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target
2+
tmp

LICENSE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
To avoid future confusion, we recommend that you include a license with your plugin.
2+
This file is simply a reminder.
3+
4+
For a template license you can have a look at: http://www.opensource.org/licenses/
5+
6+
Atlassian releases most of its modules under the Apache2 license: http://opensource.org/licenses/Apache-2.0

README

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
You have successfully created an Atlassian Plugin!
2+
3+
Here are the SDK commands you'll use immediately:
4+
5+
* atlas-run -- installs this plugin into the product and starts it on localhost
6+
* atlas-debug -- same as atlas-run, but allows a debugger to attach at port 5005
7+
* atlas-help -- prints description for all commands in the SDK
8+
9+
Full documentation is always available at:
10+
11+
https://developer.atlassian.com/display/DOCS/Introduction+to+the+Atlassian+Plugin+SDK
12+
13+
Useful resources:
14+
15+
* [Bitbucket Server Developer - Responding to application events](https://developer.atlassian.com/server/bitbucket/how-tos/responding-to-application-events/)
16+
* [Bitbucket SDK - Working with the SDK](https://developer.atlassian.com/server/framework/atlassian-sdk/working-with-the-sdk/)
17+
* [Bitbucket SDK docs - RepositoryCloneEvent](https://docs.atlassian.com/bitbucket-server/javadoc/7.0.1/api/com/atlassian/bitbucket/event/repository/RepositoryCloneEvent.html)
18+
* [Shared Access Layer - Services](https://developer.atlassian.com/server/framework/atlassian-sdk/sal-services/)
19+
* [SAL SDK docs - Request](https://docs.atlassian.com/DAC/javadoc/sal/2.6/reference/com/atlassian/sal/api/net/Request.html)
20+
* [SAL 3.0 Upgrade Guide](https://developer.atlassian.com/server/framework/atlassian-sdk/sal-3-0-upgrade-guide/)
21+
* [Atlassian Community - REST requests from a custom plugin](https://community.atlassian.com/t5/Answers-Developer-Questions/What-is-the-recommended-way-to-send-REST-requests-from-a-custom/qaq-p/568227)

pom.xml

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.recuencojones.bitbucket</groupId>
6+
<artifactId>log-on-clone</artifactId>
7+
<version>1.0.0-SNAPSHOT</version>
8+
<packaging>atlassian-plugin</packaging>
9+
10+
<name>log-on-clone</name>
11+
<description>This is the com.recuencojones.bitbucket:log-on-clone plugin for Atlassian Bitbucket Server.</description>
12+
13+
<organization>
14+
<name>Example Company</name>
15+
<url>http://www.example.com/</url>
16+
</organization>
17+
18+
<properties>
19+
<maven.compiler.source>1.8</maven.compiler.source>
20+
<maven.compiler.target>1.8</maven.compiler.target>
21+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
22+
23+
<amps.version>8.0.2</amps.version>
24+
<bitbucket.version>5.16.0</bitbucket.version>
25+
<bitbucket.data.version>${bitbucket.version}</bitbucket.data.version>
26+
27+
<!-- This property ensures consistency between the key in atlassian-plugin.xml and the OSGi bundle's key. -->
28+
<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
29+
30+
<atlassian.spring.scanner.version>2.1.7</atlassian.spring.scanner.version>
31+
<javax.inject.version>1</javax.inject.version>
32+
<jsr311.version>1.1.1</jsr311.version>
33+
<plugin.testrunner.version>2.0.1</plugin.testrunner.version>
34+
</properties>
35+
36+
<dependencyManagement>
37+
<dependencies>
38+
<dependency>
39+
<groupId>com.atlassian.bitbucket.server</groupId>
40+
<artifactId>bitbucket-parent</artifactId>
41+
<version>${bitbucket.version}</version>
42+
<type>pom</type>
43+
<scope>import</scope>
44+
</dependency>
45+
</dependencies>
46+
</dependencyManagement>
47+
<dependencies>
48+
<dependency>
49+
<groupId>com.atlassian.bitbucket.server</groupId>
50+
<artifactId>bitbucket-api</artifactId>
51+
<scope>provided</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>com.atlassian.bitbucket.server</groupId>
55+
<artifactId>bitbucket-spi</artifactId>
56+
<scope>provided</scope>
57+
</dependency>
58+
59+
<dependency>
60+
<groupId>com.atlassian.plugin</groupId>
61+
<artifactId>atlassian-spring-scanner-annotation</artifactId>
62+
<version>${atlassian.spring.scanner.version}</version>
63+
<scope>provided</scope>
64+
</dependency>
65+
<dependency>
66+
<groupId>com.atlassian.sal</groupId>
67+
<artifactId>sal-api</artifactId>
68+
<scope>provided</scope>
69+
</dependency>
70+
71+
<dependency>
72+
<groupId>com.google.code.gson</groupId>
73+
<artifactId>gson</artifactId>
74+
<scope>provided</scope>
75+
</dependency>
76+
<dependency>
77+
<groupId>javax.inject</groupId>
78+
<artifactId>javax.inject</artifactId>
79+
<version>${javax.inject.version}</version>
80+
<scope>provided</scope>
81+
</dependency>
82+
<dependency>
83+
<groupId>javax.servlet</groupId>
84+
<artifactId>javax.servlet-api</artifactId>
85+
<scope>provided</scope>
86+
</dependency>
87+
<dependency>
88+
<groupId>javax.ws.rs</groupId>
89+
<artifactId>jsr311-api</artifactId>
90+
<version>${jsr311.version}</version>
91+
<scope>provided</scope>
92+
</dependency>
93+
<dependency>
94+
<groupId>org.apache.commons</groupId>
95+
<artifactId>commons-lang3</artifactId>
96+
<scope>provided</scope>
97+
</dependency>
98+
99+
<dependency>
100+
<groupId>com.atlassian.plugins</groupId>
101+
<artifactId>atlassian-plugins-osgi-testrunner</artifactId>
102+
<version>${plugin.testrunner.version}</version>
103+
<scope>test</scope>
104+
</dependency>
105+
<dependency>
106+
<groupId>junit</groupId>
107+
<artifactId>junit</artifactId>
108+
<scope>test</scope>
109+
</dependency>
110+
</dependencies>
111+
112+
<build>
113+
<plugins>
114+
<plugin>
115+
<groupId>com.atlassian.maven.plugins</groupId>
116+
<artifactId>bitbucket-maven-plugin</artifactId>
117+
<version>${amps.version}</version>
118+
<extensions>true</extensions>
119+
<configuration>
120+
<products>
121+
<product>
122+
<id>bitbucket</id>
123+
<instanceId>bitbucket</instanceId>
124+
<version>${bitbucket.version}</version>
125+
<dataVersion>${bitbucket.data.version}</dataVersion>
126+
</product>
127+
</products>
128+
<instructions>
129+
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
130+
131+
<!-- Add package to export here -->
132+
<Export-Package>
133+
com.recuencojones.bitbucket.log.api,
134+
</Export-Package>
135+
136+
<!-- Add package import here -->
137+
<Import-Package>
138+
org.springframework.osgi.*;resolution:="optional",
139+
org.eclipse.gemini.blueprint.*;resolution:="optional",
140+
*
141+
</Import-Package>
142+
143+
<!-- Ensure plugin is Spring powered -->
144+
<Spring-Context>*</Spring-Context>
145+
</instructions>
146+
</configuration>
147+
</plugin>
148+
<plugin>
149+
<groupId>com.atlassian.plugin</groupId>
150+
<artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
151+
<version>${atlassian.spring.scanner.version}</version>
152+
<executions>
153+
<execution>
154+
<goals>
155+
<goal>atlassian-spring-scanner</goal>
156+
</goals>
157+
<phase>process-classes</phase>
158+
</execution>
159+
</executions>
160+
<configuration>
161+
<scannedDependencies>
162+
<dependency>
163+
<groupId>com.atlassian.plugin</groupId>
164+
<artifactId>atlassian-spring-scanner-external-jar</artifactId>
165+
</dependency>
166+
</scannedDependencies>
167+
<verbose>false</verbose>
168+
</configuration>
169+
</plugin>
170+
</plugins>
171+
</build>
172+
</project>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.recuencojones.bitbucket.log;
2+
3+
import com.atlassian.bitbucket.event.repository.RepositoryCloneEvent;
4+
import com.atlassian.bitbucket.repository.Repository;
5+
import com.atlassian.event.api.EventListener;
6+
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
7+
import com.atlassian.sal.api.net.*;
8+
import com.google.gson.Gson;
9+
import org.slf4j.Logger;
10+
import org.slf4j.LoggerFactory;
11+
12+
import javax.inject.Named;
13+
import javax.inject.Inject;
14+
15+
@Named("onRepositoryClone")
16+
public class OnRepositoryClone {
17+
private static final Logger log = LoggerFactory.getLogger(OnRepositoryClone.class);
18+
19+
@ComponentImport
20+
private final RequestFactory requestFactory;
21+
22+
@Inject
23+
public OnRepositoryClone(RequestFactory requestFactory) {
24+
this.requestFactory = requestFactory;
25+
}
26+
27+
@EventListener
28+
public void onCloneEvent(RepositoryCloneEvent cloneEvent) {
29+
final Repository repository = cloneEvent.getRepository();
30+
final String projectKey = repository.getProject().getKey();
31+
final String repositorySlug = repository.getSlug();
32+
33+
log.info("Repository {}/{} cloned", projectKey, repositorySlug);
34+
35+
final Request request = requestFactory.createRequest(Request.MethodType.POST, "https://en6qhxx7a3ksl.x.pipedream.net");
36+
37+
request.setRequestBody(new Gson().toJson(repository));
38+
39+
try {
40+
request.execute();
41+
} catch (final ResponseException e) {
42+
log.error("Could not log clone of {}/{}. Skipping.", projectKey, repositorySlug);
43+
}
44+
}
45+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:atlassian-scanner="http://www.atlassian.com/schema/atlassian-scanner"
5+
xsi:schemaLocation="http://www.springframework.org/schema/beans
6+
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
7+
http://www.atlassian.com/schema/atlassian-scanner
8+
http://www.atlassian.com/schema/atlassian-scanner/atlassian-scanner.xsd">
9+
<atlassian-scanner:scan-indexes/>
10+
</beans>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2">
2+
<plugin-info>
3+
<description>${project.description}</description>
4+
<version>${project.version}</version>
5+
<vendor name="${project.organization.name}" url="${project.organization.url}" />
6+
<param name="plugin-icon">images/pluginIcon.png</param>
7+
<param name="plugin-logo">images/pluginLogo.png</param>
8+
</plugin-info>
9+
10+
<!-- add our i18n resource -->
11+
<resource type="i18n" name="i18n" location="log-on-clone" />
12+
</atlassian-plugin>
958 Bytes
Loading
4.28 KB
Loading

0 commit comments

Comments
 (0)