Skip to content

Instantly share code, notes, and snippets.

View mrueegg's full-sized avatar

Michael Rüegg mrueegg

View GitHub Profile
@mrueegg
mrueegg / export-bamboo-project-specs.sh
Created June 23, 2021 08:37
Fetching all plan Java specs for a Bamboo project by REST and storing it in Java files
#!/usr/bin/env bash
# see https://jira.atlassian.com/browse/BAM-20237 for more details
BAMBOO_HOSTNAME=$1
BAMBOO_API_TOKEN=$2
PROJECT=$3
json=$(curl "https://${BAMBOO_HOSTNAME}/rest/api/latest/project/${PROJECT}/specs.json" \
--header "Authorization: Bearer ${BAMBOO_API_TOKEN}")
@mrueegg
mrueegg / SnakeYaml.java
Last active June 14, 2017 22:15
SnakeYaml example file
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
import org.yaml.snakeyaml.nodes.MappingNode;
import org.yaml.snakeyaml.nodes.NodeId;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@mrueegg
mrueegg / open-task-resolver.js
Created March 9, 2017 17:19
JavaScript AMD module to resolve open tasks in Bitbucket Server
define('plugin/openTaskResolver', [
'jquery',
'underscore',
'aui/flag',
'exports'], function ($, _, flag, exports) {
'use strict';
function resolve(tasks) {
var taskUrl = AJS.contextPath() + '/rest/api/1.0/tasks';
var resolveRequests = _.map(tasks, function (task) {
@mrueegg
mrueegg / task-resolver.js
Created March 9, 2017 17:18
JavaScript module for Bitbucket Server to resolve open tasks
define('plugin/stash', [
'jquery',
'stash/api/util/state',
'plugin/openTaskResolver',
'exports'
], function ($, state, openTaskResolver, exports) {
'use strict';
function bindTasksResolveButton() {
$('.resolve-open-tasks').mousedown(function (e) {
@mrueegg
mrueegg / HasOpenTasksCondition.scala
Created March 9, 2017 17:18
Bitbucket Server condition in Scala to only display a button if open tasks exist
import java.util.{Map => JMap}
import ch.mibex.crossproduct.api.OpenTasksCounter
import com.atlassian.bitbucket.pull.PullRequest
import com.atlassian.plugin.web.Condition
class HasOpenTasksCondition(openTasksCounter: OpenTasksCounter[PullRequest]) extends Condition {
override def init(context: JMap[String, String]): Unit = {}
override def shouldDisplay(context: JMap[String, AnyRef]): Boolean = context.get("pullRequest") match {
@mrueegg
mrueegg / BitbucketOpenTasksCounter.scala
Created March 9, 2017 17:18
Open task counter implementation in Scala for Bitbucket Server
import ch.mibex.crossproduct.api.OpenTasksCounter
import com.atlassian.bitbucket.pull.{PullRequest, PullRequestService, PullRequestTaskSearchRequest}
import com.atlassian.bitbucket.task.{Task, TaskState}
import com.atlassian.bitbucket.util.{PageProvider, PageRequest, PageUtils, PagedIterable}
import scala.collection.JavaConverters._
class BitbucketOpenTasksCounter(pullRequestService: PullRequestService) extends OpenTasksCounter[PullRequest] {
override def countOpenTasks(pullRequest: PullRequest): Long = {
val searchRequest = new PullRequestTaskSearchRequest.Builder(pullRequest).build()
@mrueegg
mrueegg / OpenTasksCounter.scala
Created March 9, 2017 17:17
Scala trait to count open tasks in a pull request
trait OpenTasksCounter[T] {
def countOpenTasks(pullRequest: T): Long
}
@mrueegg
mrueegg / atlassian-plugin.xml
Created March 9, 2017 17:17
Components used for resolving open tasks in a pull request
<!-- publish our implementations of the API interfaces for both products -->
<component key="bitbucket-open-tasks-counter" application="bitbucket"
class="ch.mibex.crossproduct.bitbucket.BitbucketOpenTasksCounter"
interface="ch.mibex.crossproduct.api.OpenTasksCounter"/>
<component key="stash-open-tasks-counter" application="stash"
class="ch.mibex.crossproduct.stash.StashOpenTasksCounter"
interface="ch.mibex.crossproduct.api.OpenTasksCounter"/>
<!-- application-specific imports from the product container -->
<component-import key="stash-pull-request-service" application="stash"
interface="com.atlassian.stash.pull.PullRequestService"/>
@mrueegg
mrueegg / atlassian-plugin.xml
Last active March 9, 2017 17:49
Bitbucket Server resource for resolving all open tasks in a pull request
<client-resource key="bitbucket-close-open-tasks-resources" application="bitbucket">
<resource type="download" name="task-resolver.js" location="/js/task-resolver.js"/>
<resource type="download" name="bitbucket.js" location="/js/bitbucket.js"/>
<dependency>com.atlassian.auiplugin:ajs</dependency>
<dependency>com.atlassian.bitbucket.server.bitbucket-web-api:amd</dependency>
<dependency>com.atlassian.bitbucket.server.bitbucket-web-api:aui</dependency>
<dependency>com.atlassian.bitbucket.server.bitbucket-web-api:jquery</dependency>
<dependency>com.atlassian.auiplugin:aui-flag</dependency>
<context>bitbucket.page.pullRequest.view</context>
</client-resource>
@mrueegg
mrueegg / atlassian-plugin.xml
Created March 9, 2017 17:15
Stash resource for loading JavaScript files to resolve all open tasks in a pull request
<stash-resource key="stash-close-open-tasks-resources" application="stash">
<resource type="download" name="close-open-tasks.js" location="/js/task-resolver.js"/>
<resource type="download" name="stash.js" location="/js/stash.js"/>
<dependency>com.atlassian.auiplugin:ajs</dependency>
<dependency>com.atlassian.stash.stash-web-plugin:global</dependency>
<dependency>com.atlassian.auiplugin:aui-flag</dependency>
<context>stash.page.pullRequest.view</context>
</stash-resource>