Skip to content

Commit

Permalink
Merge pull request #2 from zvercodebender/master
Browse files Browse the repository at this point in the history
Add Tag Release task to create a tag on a branch
  • Loading branch information
Rick Broker authored Oct 25, 2017
2 parents 5179575 + 6d67f17 commit af83f43
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ bin
.project
.pydevproject
.DS_*
supervisord*
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ deploy:
provider: releases
api-key:
secure: YeEJO7TElGtHfVxI/uhujcrGRhhI9w6GvBh67jPHGoIP0+G5TnUs2rhKMnhqxNkMGLDuCcm+U5QTQDAFOVoERlQPSqlTHF7bohxaJujTDZ+es9QHjUqsy2/CT/ov//m6gmFUPplLW++gOmABZR1WoOWp2eT1H/1NDDsT5jAI7wrQchjTlLEQndaCP8tAHI9hD4VdXiF38+1OYP55d/Tmujs3KpKDx2Df3f+12twhjGIwg+7kTaoAdN7j+TD0uUoSZ7wby98KUnAn5qj+dq0cfYoc2kvZ+eMEzxQpMXzxuWlFXOUwb2j9AFzR2SMC38BJxgHU92e3XnfbZP4mFOLpQLJnW1HUdPQQdAAebvpomDjvTsg3H8ttmoNj43eBhRwVVgA3ER2btEdsJGsrYZbkRftGoNi6irL14ymNxLY9VtnayyUCSXbEgZZgY/XUpNnlULEGvwpfg5ZYMtMMlJZDxImrIipEoiNOXjVO8GYOVk5mKA8YQ+Bv+5tQlopDasFMI+NFFVneVU205+ZGcCV2DlAnkBRO+6E5oy6vyDpnj2SD4wEQ1PKWtjEfA5OF6eKz/vvTP9FsdmjwQONmM2E09Jv4Y6N/ktIcX+XbI2OlpK3926bSBh+MtIPLa4Do0UOM3+KcR8fScRL0b3uHEKebFg997NGoQxbEGh0QllLq0n4=
file: build/libs/xlr-bitbucket-plugin-1.0.2.jar
file_glob: true
file: build/libs/*
skip_cleanup: true
on:
tags: true
Expand Down
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
# xlr-bitbucket-plugin

This plugin offers an interface from XL Release to Atlassian Stash(Now Bitbucket Server) and Bitbucket Cloud API

#### IMPORTANT ####

* Use **Stash Connection and Stash Tasks** if you're using an **on-prem hosted Bitbucket Server**. Stash is now called Bitbucket Server.
* Use **Bitbucket Connection and Bitbucket Tasks** if you're using **Bitbucket Cloud**.
* All Stash/Bitbucket Server tasks are based on api **/rest/api/1.0/** prefix
* All Bitbucket Cloud tasks are based on api **/2.0/** prefix

# CI status #
# XLR Bitbucket plugin

[![Build Status][xlr-bitbucket-plugin-travis-image]][xlr-bitbucket-plugin-travis-url]
[![Codacy Badge][xlr-bitbucket-plugin-codacy-image] ][xlr-bitbucket-plugin-codacy-url]
Expand All @@ -27,6 +16,16 @@ This plugin offers an interface from XL Release to Atlassian Stash(Now Bitbucket
[xlr-bitbucket-plugin-license-url]: https://opensource.org/licenses/MIT
[xlr-bitbucket-plugin-downloads-image]: https://img.shields.io/github/downloads/xebialabs-community/xlr-bitbucket-plugin/total.svg

This plugin offers an interface from XL Release to Atlassian Stash(Now Bitbucket Server) and Bitbucket Cloud API

#### IMPORTANT ####

* Use **Stash Connection and Stash Tasks** if you're using an **on-prem hosted Bitbucket Server**. Stash is now called Bitbucket Server.
* Use **Bitbucket Connection and Bitbucket Tasks** if you're using **Bitbucket Cloud**.
* All Stash/Bitbucket Server tasks are based on api **/rest/api/1.0/** prefix
* All Bitbucket Cloud tasks are based on api **/2.0/** prefix


# Development #

* Start XLR: `./gradlew runDockerCompose`
Expand Down Expand Up @@ -59,11 +58,14 @@ This plugin offers an interface from XL Release to Atlassian Stash(Now Bitbucket
+ `stash.WaitForMerge` : This task waits and polls stash to check the status of a Pull request Merge Status
+ `stash.DownloadCode` : This task allows to export a code zip file that can be downloaded to a specified folder on XL Release server locally for a provided branch in repository. Requires [Bitbucket Server Archive plugin](https://marketplace.atlassian.com/plugins/com.atlassian.stash.plugin.stash-archive/server/overview)
+ `stash.searchFileContent` : This task allows to search a file's content in a repository/branch using a provided pattern and return group0 and group1 as results. eg.
```
version[ ]*=[ ]*(\d+)

```
```
version[ ]*=[ ]*(\d+)

```

+ `stash.DeleteBranch` : This task allows to delete a branch
+ `stash.TagRelease` : This task adds a tag to a branch



Expand Down Expand Up @@ -122,6 +124,9 @@ version[ ]*=[ ]*(\d+)
* Get Pull Request
![](images/stash/getpullrequest.png)

* Tag Release
![](images/stash/tagrelease.png)

# References #

[Stash/Bitbucket Server REST API](https://developer.atlassian.com/stash/docs/latest/reference/rest-api.html)
Expand Down
25 changes: 21 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
import org.apache.tools.ant.filters.ReplaceTokens

plugins {
id "com.github.hierynomus.license" version "0.13.0"
id "com.xebialabs.xl.docker" version "1.0.0"
id "nebula.release" version "6.0.0"
}

version='1.0.2'

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'maven'

xlDocker {
compileImage = 'xebialabs/xlr_dev_compile'
compileVersion = 'v6.1.0.1'
compileVersion = 'v7.2.0.1'
runImage = 'xebialabs/xlr_dev_run'
runVersion = 'v6.1.0.1'
runVersion = 'v7.2.0.1'
runPortMapping = '15516:5516'
}


if (!project.hasProperty('release.scope')) {
project.ext['release.scope'] = 'patch'
}

if (!project.hasProperty('release.useLastTag')) {
project.ext['release.useLastTag'] = true
}

processResources.configure {
filter ReplaceTokens, tokens: [
'project.version': version.toString(),
'project.name' : rootProject.name
]
}

license {
header rootProject.file('License.md')
strictCheck false
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Dec 02 11:13:28 PST 2015
#Tue Oct 24 19:33:51 EDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
Binary file added images/stash/tagrelease.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/main/resources/stash/Stash.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ def stash_waitformerge(self, variables):
time.sleep(variables['pollInterval'])
return {'output' : data}

def stash_tagrelease(self, variables):
endpoint = "/rest/git/1.0/projects/%s/repos/%s/tags" % (variables['project'], variables['repository'])
logger.warn("Tag project (%s/%s" % (variables['project'], variables['repository']))
content = '''{"force":"true", "message":"%s", "name":"%s", "startPoint":"refs/heads/%s", "type":"ANNOTATED"}''' % (variables['message'], variables['tagname'], variables['branch'])
response = self.api_call('POST',endpoint,body=content, contentType="application/json")
data = response.getResponse()
return {'output': data}


# TODO - apache cleint doesnt support body with DELETE method. add ability to xlrelease.HTTPRequest
def stash_deletebranch_old(self, variables):
endpoint = "/rest/branch-utils/1.0/projects/%s/repos/%s/branches" % (variables['project'], variables['repository'])
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/synthetic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@
<property name="pollInterval" category="input" kind="integer" description="Polling Interval in seconds" label="Poll Interval"/>
</type>

<type type="stash.TagRelease" extends="stash.Task" >
<property name="tagname" category="input" description="Release Tag" label="Release Tag Name"/>
<property name="message" category="input" description="Release Tag message" label="Release Tag Message"/>
<property name="branch" category="input" description="Branch to Tag" />
</type>

<type type="stash.Server" extends="configuration.HttpConnection">
<property name="checkConfigurationPath" hidden="true" default="/rest/api/1.0/users"/>
<property name="checkConfigurationContentType" hidden="true" default="application/json"/>
Expand Down
49 changes: 49 additions & 0 deletions src/test/bitbucket/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: '3'

services:
bitbucket:
image: blacklabelops/bitbucket
depends_on:
- postgres_bitbucket
networks:
- bitbucketnet
volumes:
- bitbucketdata:/var/atlassian/bitbucket
ports:
- '7990:7990'
environment:
- 'BITBUCKET_PROXY_NAME='
- 'BITBUCKET_PROXY_PORT='
- 'BITBUCKET_PROXY_SCHEME='
- 'BITBUCKET_DELAYED_START='
- 'DOCKER_WAIT_HOST=postgres_bitbucket'
- 'DOCKER_WAIT_PORT=5432'
labels:
com.blacklabelops.description: "Atlassian Bitbucket"
com.blacklabelops.service: "bitbucket"

postgres_bitbucket:
image: blacklabelops/postgres
networks:
- bitbucketnet
volumes:
- postgresqldata:/var/lib/postgresql/data
environment:
- 'POSTGRES_USER=bitbucketdb'
# CHANGE THE PASSWORD!
- 'POSTGRES_PASSWORD=jellyfish'
- 'POSTGRES_DB=bitbucketdb'
- 'POSTGRES_ENCODING=UTF8'
labels:
com.blacklabelops.description: "PostgreSQL Database Server"
com.blacklabelops.service: "postgresql"

volumes:
bitbucketdata:
external: false
postgresqldata:
external: false

networks:
bitbucketnet:
driver: bridge
26 changes: 26 additions & 0 deletions supervisord.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
2017-10-24 23:33:34,313 CRIT Supervisor running as root (no user in config file)
2017-10-24 23:33:34,317 INFO supervisord started with pid 1
2017-10-24 23:33:35,320 INFO spawned: 'xlr' with pid 8
2017-10-24 23:33:36,337 INFO success: xlr entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2017-10-24 23:36:00,167 WARN received SIGINT indicating exit request
2017-10-24 23:36:00,172 INFO waiting for xlr to die
2017-10-24 23:36:00,386 INFO stopped: xlr (terminated by SIGTERM)
2017-10-24 23:36:00,387 INFO reaped unknown pid 14
2017-10-24 23:36:00,389 WARN received SIGTERM indicating exit request
2017-10-24 23:36:58,642 CRIT Supervisor running as root (no user in config file)
2017-10-24 23:36:58,646 INFO supervisord started with pid 1
2017-10-24 23:36:59,650 INFO spawned: 'xlr' with pid 8
2017-10-24 23:37:00,668 INFO success: xlr entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2017-10-24 23:37:48,931 INFO exited: xlr (exit status 0; expected)
2017-10-24 23:50:23,074 WARN received SIGINT indicating exit request
2017-10-24 23:50:48,852 CRIT Supervisor running as root (no user in config file)
2017-10-24 23:50:48,857 INFO supervisord started with pid 1
2017-10-24 23:50:49,861 INFO spawned: 'xlr' with pid 8
2017-10-24 23:50:50,884 INFO success: xlr entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2017-10-24 23:51:38,903 INFO exited: xlr (exit status 0; expected)
2017-10-24 23:55:11,864 WARN received SIGINT indicating exit request
2017-10-24 23:57:34,176 CRIT Supervisor running as root (no user in config file)
2017-10-24 23:57:34,180 INFO supervisord started with pid 1
2017-10-24 23:57:35,187 INFO spawned: 'xlr' with pid 8
2017-10-24 23:57:36,205 INFO success: xlr entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2017-10-24 23:58:24,427 INFO exited: xlr (exit status 0; expected)
1 change: 1 addition & 0 deletions supervisord.pid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1

0 comments on commit af83f43

Please sign in to comment.