Cowboy in the desert.

How to deploy from Minecraft with Octopus Deploy

Shane Gill

Imagine a world where deployments were simple. You could push a button in your favorite video game and your latest release was deployed to production. Some may scoff: "My spreadsheets, RDP and manual config file edits could never be replaced by a virtual button!" Allow me to present OctoCraft Deploy:

On the Minecraft side all you need is Bukkit and a copy of Minecraft. Bukkit allows the creation of custom Minecraft plugins. OctoCraft Deploy is just a Minecraft plugin that interacts with the Octopus Deploy API.

Octopus Deploy is API first. Anything you can do through the UI can be accomplished through the API. Even with Java. OctoCraft Deploy calls the Octopus Deploy API to create a release, deploy that release to an environment and then monitor the state of the deployment. You can find full API doco here.

For example, to create a release:

Create a method to post to the API.

public HttpResponse Post(String path, String json) throws ClientProtocolException, IOException {
    HttpClient client = new DefaultHttpClient();
    HttpPost post = new HttpPost(url + path);
    post.setHeader(API_KEY_HEADER, apiKey);

    post.setEntity(new StringEntity(json, ContentType.TEXT_PLAIN));
    return client.execute(post);
}

POJO that will be serialized to the post request.

public class ReleasePost {
    private String projectId;
    private String version;

    public ReleasePost(String projectId, String version) {
        this.projectId = projectId;
        this.version = version;
    }

    @JsonProperty("ProjectId")
    public String getProjectId() {
        return projectId;
    }

    @JsonProperty("Version")
    public String getVersion() {
        return version;
    }
}

Do all the hard work of creating a release.

private Release createRelease(Project project) throws ClientProtocolException, IOException {                
    ReleasePost releasePost = new ReleasePost(project.getId(), "1.i");
    String content = new String(); 
    String json = objectMapper.writeValueAsString(releasePost);
    HttpResponse response = webClient.Post(RELEASES_PATH, json);

    content = EntityUtils.toString(response.getEntity());           
    return objectMapper.readValue(content, Release.class);  
}

The full source on GitHub.

Loading...