Commits

James Dumay  committed 6a53da8

Add HelloWorld Plugin

  • Participants
  • Parent commits ed48459

Comments (0)

Files changed (12)

+syntax: glob
+activemq-data
+target
+.idea
+*.iml
+*.ipr
+*.iws

File part2/helloworld/LICENSE.TXT

+To avoid future confusion, we recommend that you include a license with your plugin.
+This file is simply a reminder.
+
+For a template license you can have a look at: http://www.opensource.org/licenses/
+
+Atlassian releases most of its modules under a BSD license: http://www.opensource.org/licenses/bsd-license.php

File part2/helloworld/README.TXT

+You have successfully created a plugin using the Bamboo plugin archetype!
+
+Here are the SDK commands you'll use immediately:
+
+* atlas-run   -- installs this plugin into Bamboo and starts it on http://localhost:6990/bamboo
+* atlas-debug -- same as atlas-run, but allows a debugger to attach at port 5005
+* atlas-cli   -- after atlas-run or atlas-debug, opens a Maven command line window:
+                 - 'pi' reinstalls the plugin into the running Bamboo instance
+* atlas-help  -- prints description for all commands in the SDK
+
+Full documentation is always available at:
+
+http://confluence.atlassian.com/display/DEVNET/Developing+your+Plugin+using+the+Atlassian+Plugin+SDK

File part2/helloworld/pom.xml

+<?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>helloworld</groupId>
+    <artifactId>helloworld</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <organization>
+        <name>Example Company</name>
+        <url>http://www.example.com/</url>
+    </organization>
+
+    <name>helloworld</name>
+    <description>This is the helloworld:helloworld plugin for Atlassian Bamboo.</description>
+    <packaging>atlassian-plugin</packaging>
+
+    <properties>
+        <bamboo.version>3.1</bamboo.version>
+        <bamboo.data.version>2.6.1</bamboo.data.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.atlassian.bamboo</groupId>
+            <artifactId>atlassian-bamboo-web</artifactId>
+            <version>${bamboo.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.6</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>com.atlassian.maven.plugins</groupId>
+                <artifactId>maven-bamboo-plugin</artifactId>
+                <version>3.3.2</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <productVersion>${bamboo.version}</productVersion>
+                    <productDataVersion>${bamboo.data.version}</productDataVersion>
+                </configuration>
+            </plugin>
+	          <!--
+              If you have dependencies that ship with your plugin you should use the shade plugin to include them in the final jar
+              Uncomment the section below and add any jars you want to include by adding <include>groupId:artifactId</include> between the artifactSet elements.
+              See http://atlss.in/mhgZm6 for more information
+            -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+		            <version>1.4</version>
+                <executions>
+                   <execution>
+                     <phase>package</phase>
+                     <goals>
+                       <goal>shade</goal>
+                     </goals>
+                     <!--
+                     <configuration>
+                       <artifactSet>
+                          <includes>
+                            <include>com.mygroupid:my-artifact-id</include>
+                          </includes>
+                        </artifactSet>
+                      </configuration>
+                      -->
+                   </execution>
+                </executions>
+            </plugin>
+          
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

File part2/helloworld/src/main/java/helloworld/ExampleTask.java

+package helloworld;
+
+import com.atlassian.bamboo.build.logger.BuildLogger;
+import com.atlassian.bamboo.task.TaskContext;
+import com.atlassian.bamboo.task.TaskException;
+import com.atlassian.bamboo.task.TaskResult;
+import com.atlassian.bamboo.task.TaskResultBuilder;
+import com.atlassian.bamboo.task.TaskType;
+import org.jetbrains.annotations.NotNull;
+
+public class ExampleTask implements TaskType
+{
+    @NotNull
+    @java.lang.Override
+    public TaskResult execute(@NotNull final TaskContext taskContext) throws TaskException
+    {
+        final BuildLogger buildLogger = taskContext.getBuildLogger();
+
+        buildLogger.addBuildLogEntry("Hello, world!");
+
+        return TaskResultBuilder.create(taskContext).success().build();
+    }
+}

File part2/helloworld/src/main/java/helloworld/ExampleTaskConfigurator.java

+package helloworld;
+
+import com.atlassian.bamboo.collections.ActionParametersMap;
+import com.atlassian.bamboo.task.AbstractTaskConfigurator;
+import com.atlassian.bamboo.task.TaskDefinition;
+import com.atlassian.bamboo.utils.error.ErrorCollection;
+import com.opensymphony.xwork.TextProvider;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Map;
+
+public class ExampleTaskConfigurator extends AbstractTaskConfigurator
+{
+    private TextProvider textProvider;
+
+    @NotNull
+    @Override
+    public Map<String, String> generateTaskConfigMap(@NotNull final ActionParametersMap params, @Nullable final TaskDefinition previousTaskDefinition)
+    {
+        final Map<String, String> config = super.generateTaskConfigMap(params, previousTaskDefinition);
+
+        return config;
+    }
+
+    @Override
+    public void populateContextForCreate(@NotNull final Map<String, Object> context)
+    {
+        super.populateContextForCreate(context);
+
+        context.put("say", "Hello, World!");
+    }
+
+    @Override
+    public void populateContextForEdit(@NotNull final Map<String, Object> context, @NotNull final TaskDefinition taskDefinition)
+    {
+        super.populateContextForEdit(context, taskDefinition);
+
+        context.put("say", taskDefinition.getConfiguration().get("say"));
+    }
+
+    @Override
+    public void populateContextForView(@NotNull final Map<String, Object> context, @NotNull final TaskDefinition taskDefinition)
+    {
+        super.populateContextForView(context, taskDefinition);
+        context.put("say", taskDefinition.getConfiguration().get("say"));
+    }
+
+    @Override
+    public void validate(@NotNull final ActionParametersMap params, @NotNull final ErrorCollection errorCollection)
+    {
+        super.validate(params, errorCollection);
+
+        final String sayValue = params.getString("say");
+        if (StringUtils.isEmpty(sayValue))
+        {
+            errorCollection.addError("say", textProvider.getText("helloworld.say.error"));
+        }
+    }
+
+    public void setTextProvider(final TextProvider textProvider)
+    {
+        this.textProvider = textProvider;
+    }
+}

File part2/helloworld/src/main/resources/atlassian-plugin.xml

+<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="1">
+    <!--
+    note that this plugin has to be a plugins-version '1' plugin as build module types (repositories, tasks, pre/post processors)
+    are plugins v1 only. Module types such as REST, Gadgets, Servlets and Filters are plugins v2 and cannot be mixed in the same
+    plugin as plugins v1 module types for the time being
+    -->
+    <plugin-info>
+        <description>${project.description}</description>
+        <version>${project.version}</version>
+        <vendor name="${project.organization.name}" url="${project.organization.url}" />
+    </plugin-info>
+
+    <!-- internationalize your plugin -->
+    <resource type="i18n" name="helloworld language" location="english"/>
+
+    <!-- defines an example task -->
+    <taskType name="helloworld" class="helloworld.ExampleTask" key="test">
+      <description>A simple Hello World Task</description>
+      <!-- Categories available in 3.1: "builder", "test" and "deployment"
+      <category name=""/>
+      -->
+      <configuration class="helloworld.ExampleTaskConfigurator"/>
+      <resource type="freemarker" name="edit" location="editExampleTask.ftl"/>
+      <resource type="freemarker" name="view" location="viewExampleTask.ftl"/>
+    </taskType>
+</atlassian-plugin>

File part2/helloworld/src/main/resources/editExampleTask.ftl

+[@ww.textfield labelKey="helloworld.say" name="say" required='true'/]

File part2/helloworld/src/main/resources/english.properties

+helloworld.say = Say
+helloworld.say.description = What should Bamboo print to the log?
+helloworld.say.error = You did not configure Bamboo with anything to say.

File part2/helloworld/src/main/resources/viewExampleTask.ftl

+[@ww.label labelKey="helloworld.say" name="say"/]

File part2/helloworld/src/test/java/it/IntegrationTestMyPlugin.java

+package it;
+
+import junit.framework.TestCase;
+
+public class IntegrationTestMyPlugin extends TestCase
+{
+	public void testSomething()
+	{
+	}
+}

File part2/helloworld/src/test/resources/TEST_RESOURCES_README.TXT

+Create any of the test resources you might need in this directory.
+
+Please remove this file before releasing your plugin.