Skip to end of banner
Go to start of banner

API

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Merge Check Hook

Objects

ObjectsData Returned

changeSet

List of changesets

[{
 "fromHash":"ahash",
 "toHash":"bash",
 "refId","refId",
 "type":"add",
 "branch":"master"
},{
 "fromHash":"ahash",
 "toHash":"bash",
 "refId","refId",
 "type":"add",
 "branch":"master"
}]

repository

Basic Metadata about the repository

{
 "id":1232,
 "name":"Repository name",
 "slug":"rep_1"
}

project

Basic metadata about the project

{
 "key":"PROJECT_1",
 "name":"Project name"
}

currentUser

Returns the current user

{
 "userName":"bsmith",
 "fullName": "Bob Smith",
 "email": "bob@example.com"
}

On This Page

 

Functions

FunctionSample callData returned

stash.log(str)

Puts a log entry in the atlassian-stash.log

stash.log('Debug');{code}
None

stash.sendEmail( to, subject, body)

Sends an email to the toEmail from the fromUser

 
stash.sendEmail('bob@example.com','Hello World!','My body goes here');

 

Only available if the Stash administrator has enabled it.

None

stash.getUser(String username)

Looks up a stash user

stash.getUser('jbob')
{
 "userName":"bsmith",
 "fullName": "Bob Smith",
 "email": "bob@example.com"
}

 

 

stash.getUsersInGroup(String groupname)

Looks up a list of users by group

stash.getUsersInGroup('stash-users');
[{
 "userName":"bsmith",
 "fullName": "Bob Smith",
 "email": "bob@example.com"
},{
 "userName":"bsmith",
 "fullName": "Bob Smith",
 "email": "bob@example.com"
}]

 

 

 

 

 

stash.sendHttp( method, url)

Makes an http request to desired url

stash.sendHttp('GET','http://example.com');

 

Only available if the Stash administrator has enabled it.

{
 "successful":true,
 "headers":
 [
 "Response-header": "value"
 ],
 "responseBody":"{}",
 "statusCode":200,
 "statusText": "OK",
 "exceptionMessage":""
}

stash.sendHttp( method, url, body)

Makes an http request to desired url with a body

stash.sendHttp('PUT','http://example.com','{}');

 

Only available if the Stash administrator has enabled it.

{
 "successful":true,
 "headers":
 [
 "Response-header": "value"
 ],
 "responseBody":"{}",
 "statusCode":200,
 "statusText": "OK",
 "exceptionMessage":""
}

stash.sendFeedback( subject, body, block)

Provides feedback to the end user. If block(boolean) is true then the action will be rejected

  1. stash.sendFeedback( 'Warning - force attempted', 'We are not accepting '+
  2.  'git push -f on this repository', true)

 

Not available for post hooks


None

stash.executeCommand(command)

Executes the command

stash.executeCommand('echo "Hello World!"');
{
 "output":"Hello World!",
 "exitCode":0
 "wasSuccessful":true
 }

stash.fetchCommit(projectKey, repoSlug, refId)

Retrieves a single commit

stash.fetchCommits('PROJECT_1', 'rep_1', '0a943a29376f2336b78312d99e65da17048951db')
{
 "filesAdded": [ { "path": "binary/D.zip", "exeutable": false } ],
 "filesDeleted": [],
 "filesModified": [],
 "filesMoved": [],
 "filesCopied": [],
 "filesUnknown": [],
 "branch": "0a943a2",
 "date": "Feb 2, 2011 9:01:07 PM",
 "message": "Copy C.zip as D.zip",
 "hash": "0a943a29376f2336b78312d99e65da17048951db"
}

stash.fetchCommits(projectKey, repoSlug, startRef, endRef)

Retrieves multiple commits

stash.fetchCommits('PROJECT_1', 'rep_1', '0a943a29376f2336b78312d99e65da17048951db','0a943a29376f2336b78312d99e65da17048951db')
{
 "filesAdded": [ { "path": "binary/D.zip", "exeutable": false } ],
 "filesDeleted": [],
 "filesModified": [],
 "filesMoved": [],
 "filesCopied": [],
 "filesUnknown": [],
 "branch": "0a943a2",
 "date": "Feb 2, 2011 9:01:07 PM",
 "message": "Copy C.zip as D.zip",
 "hash": "0a943a29376f2336b78312d99e65da17048951db"
}

 

  • No labels