使用ZSH安装Groovy(在Jira&Confluence中具有自动化功能)

Full disclosure: I work for Atlassian. As a result, I spend a great deal of time creating, updating, and reading Confluence pages. While Confluence server and cloud both have APIs which can be used to programmatically update/create pages, Adaptavist created an app called ScriptRunner which makes this easier with built-in scripts and pre-written logic. My end-goal is to automate some common, reoccuring tasks either by checking a Jira issue for updates or another confluence page. Most Atlassian applications are written in Java and ScriptRunner uses a flavor of Java called Groovy.

Step 1: install Groovy on OS X

对于自制用户:

brew install groovy

对于MacPorts用户:

sudo port install groovy

Step 2: Set Groovy_home environment variable

欢迎您完全在zsh中执行此操作,但是我手动将其添加到了我的〜/ 。zshrc文件。 另一个注意事项是我已设置Sublime从命令行启动。 如果您喜欢vim,emacs或其他文本编辑器,则需要将引用替换为子级。

subl ~/.zshrc

中〜/ .zshrc,我添加了以下变量导出和注释:

# Add Groovy Home path
export GROOVY_HOME="$(/usr/local/opt/groovy/libexec)"

保存此文件,完成后即可将其关闭。

Step 3: Run a test to check your Groovy install

mkdir groovy-test && cd groovy-test
subl hello.groovy

现在,将测试脚本添加到刚创建的空文件中:

//hello.groovy
println "hello, world"
for (arg in this.args ) {
        
    println "Argument:" + arg;
}
// this is a comment
/* a block comment, commenting out an alternative to above:
this.args.each{ arg -> println "hello, ${arg}"}
*/

保存此文件,完成后即可将其关闭。

使用以下命令运行它:

groovy hello.groovy MyName yourName HisName

Step 4: Start using Groovy to automate tasks in Jira or Confluence

如前所述,Adaptavist提供了一些内置脚本,但是我发现我的需求更加复杂。 网上有一些很好的例子可以帮助您入门。

  • Create Confluence page
  • ScriptRunner examples for Confluence Cloud
  • ScriptRunner samples for Bitbucket, Bamboo, Confluence, and Jira
  • Best practices for ScriptRunner behaviors for Jira

from: https://dev.to//preciselyalyss/install-groovy-with-zsh-plus-automation-in-jira--confluence-nji

你可能感兴趣的:(jira,java,开发工具)