GithubHelp home page GithubHelp logo

jira-scripts's Introduction

Atlassian JIRA MyGroovy templates / examples

Template of quick writing groovy scripts for the plugin [Groovy Amigo] (https://marketplace.atlassian.com/1218755). The template uses the usual java-api in easy-to-use wrappers. You can just to copy the code and apply it in the right order.

[Groovy language docs is here] (http://groovy-lang.org/documentation.html)

[MyGroovy source code] (https://github.com/atlascommunity/jira-plugins-groovy)

[MyGroovy documentation] (https://github.com/atlascommunity/jira-plugins-groovy/wiki)

Additions and wishes are welcome.

Example 1

Receiving issue

	ComponentAccessor.issueManager.getIssueObject(key)

The template is represented by a method that is copied with the import.

	def getIssue(String key){
		ComponentAccessor.issueManager.getIssueObject(key)
	}

Example 2

Calling a transition at issue. The transition.groovy file contains the doTransition (issue, actionId, user) method. It passes the issue with which you want to call the transition, the transition id, user - the user on whose behalf the transition is made

	def doTransition(issue, int actionId, user){
	    def issueService = ComponentAccessor.getIssueService()
	    def issueInputParameters = issueService.newIssueInputParameters();
	    def transitionValidationResult = issueService.validateTransition(user, issue.id, actionId, issueInputParameters);
	    if (transitionValidationResult.isValid()){
	       issueService.transition(user, transitionValidationResult);
	        return true
	    } else {
	        return false
	    }
	}

Example 3

To execute a query in the database, call the select ("select * from ...") method from the sql.groovy file

	select("select ...")

	def select(String query){
	    OfBizDelegator delegator = ComponentAccessor.getOfBizDelegator();
	    DelegatorInterface delegatorInterface = delegator.getDelegatorInterface();
	    String helperName = delegatorInterface.getGroupHelperName("default");
	    Connection connection = ConnectionFactory.getConnection(helperName);
	    Sql sql = new Sql(connection);

	    List<GroovyRowResult> resultRows = []
	    try{
	        resultRows.addAll(sql.rows(query));
	    } finally {
	        connection.close()
	    }
	    return resultRows
	}

jira-scripts's People

Contributors

chuikoaleksandr avatar nteplov avatar slobodchuk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.