开发一款Jira应用:发布你的Atlassian Forge应用

Distributing Your Atlassian Forge App

In a prior installment of this blog [1], mg官方游戏中心讨论了让你的Forge应用程序启动并运行在“你好, World!" way on a test Atlassian instance. Now, 也许你的公司有一个员工每天使用的Atlassian实例, 并且你想通过在该实例上安装Forge应用程序来在现实世界中测试它. 另一种情况是,你现在已经为你的应用准备好了客户, so you need to distribute it to them. Let's see how that can be done!

First, a word about Forge environments…

每个Forge应用都可以部署到三种环境中:

  • 开发:这种环境最适合应用程序的开发和测试周期. In that environment, the app can run in the cloud, 或者它可以通过隧道在开发人员的机器上运行. See [1] for more details.

  • Staging:将此环境用于应用程序的稳定预生产版本. 这最适合于验证、确认或可用性测试.

  • 生产:当然,这是客户使用应用程序的环境.

As you might expect, each environment is firewalled from the others; they don’t share in-app data, for example. However, multiple environments of the same app, 可能是应用程序代码的不同版本, can be installed on the same Atlassian instance, 这样你就可以针对同一组Atlassian Cloud数据测试应用程序, such as Jira tickets:

 

正如应用名称右侧的标签所暗示的那样,第二个是开发,第三个是分期. 生产,第一个,没有这样的标签.

注:所有应用在生产中的使用将受到Forge平台配额和限制。[2]. Also, if the app is a paid app, 该应用程序的生产使用将向您的公司收费-即使这样的使用 by your company! mg官方游戏中心建议应用程序的大部分测试都在开发和登台阶段进行, 因为这些环境不受这样的限制和收费.

Also, a word about required user permissions…

Currently, 只有一个Atlassian Cloud用户可以执行部署和安装一个给定的Forge应用程序-即, the user who created the app. 当您考虑可能希望在一个Atlassian Cloud站点上执行开发时,这一点非常重要, 然后让其他用户在不同的网站上测试你的应用. 当然,这也让多个开发者开发同一款应用变得更加困难. On top of that, if someone leaves a company, 以及他们在公司工作期间是否开发过Forge应用, 那么他们的Atlassian Cloud用户可能仍然需要拥有足够的特权来保持应用程序的可部署性.

Atlassian在他们的路线图上有一些东西,可以让多个用户“拥有”同一款应用,用于开发目的。[3]. 然而,与此同时,还需要变通方法,mg官方游戏中心将在稍后讨论.

And Now, Hands on Your Keyboard!

Let’s say you’ve created a Forge app, called getting-started. 您已经在开发环境中开发并测试了它, 现在您希望将其部署到Staging环境中,以便其他人进一步测试. Let’s do that.

Deploying Your Forge App

In Forge terminology, deployment 指的是在Forge环境中构建和部署特定版本的Forge应用程序. 这是分发应用程序的第一步, 无论是全新的还是代码更新的版本.

要部署,请确保您的应用程序已完全构建,然后运行 forge deploy command [4] from your app’s root directory. If you don’t specify any command-line arguments, it will deploy to the Development environment; however, we wish to deploy to Staging instead, so the command needs to specify the -e staging argument:

Installing Your Forge App

Installation 指在Atlassian站点上安装特定的Forge环境-应用程序组合, 假设应用程序已经部署到指定的环境中. Whenever a given app is updated via a deployment, 在所有Atlassian Cloud站点上,该应用程序在部署到环境中的所有安装都将收到更新通知.

注意:下面描述的所有安装方法都要求执行安装的用户具有对Atlassian Cloud产品(Jira)的管理员访问权限, for example) to which the Forge app is attached.

Install to Staging

You’re the sole developer of the app, 并且您希望将应用程序的Staging版本安装到Atlassian Cloud测试实例中,而不需要设置CI/CD管道(mg官方游戏中心稍后会这样做)。. Let’s run the forge install command [5] from your app’s root directory. Like forge deploy, forge install targets the Development environment by default, so we’ll need to specify Staging instead; the command accepts the -e staging argument just like forge deploy:

Install to Staging on Another Instance

您已经在自己的Atlassian Cloud站点上测试了应用程序. For the purposes of real-world testing, 现在,您希望将其部署到公司用于所有基于atlassian的日常活动的另一个站点. What do you do?

回想一下我之前关于所需用户权限的讨论. 您需要请求Atlassian Cloud站点的管理员为您的公司将您的Atlassian Cloud用户(创建应用程序的同一用户)设置为临时管理员. 完成后,您将执行与前面安装到暂存一节中相同的步骤.

Install a Limited-Release App to Production

您已经在登台环境中进行了广泛的测试,现在可以安装到生产环境了. 您已经按照上面部署Forge应用程序中描述的步骤进行了操作, but with Production as the target environment. 你考虑过通过Atlassian Marketplace推广应用, 哪个相当于谷歌的Play Store或苹果的App Store, but for apps that run in the Atlassian ecosystem. However, you don’t 希望你的应用程序在市场上可用,但你 do wish to distribute it to a set of beta customers. Let’s see how.

Forge应用程序可以通过开发者控制台生成的安装链接共享. 这使得应用程序可以在不使用Atlassian Marketplace的情况下发布到其他网站. 要为应用程序生成安装链接,必须满足以下要求:

  • The app must not be a paid app.

  • The app must not have a license in its manifest.yml file.

  • 该应用程序必须没有提交在市场上市.[MB1] 

To generate an installation link for your app, 让mg官方游戏中心来看看Atlassian开发者控制台的应用列表[6]:

In our case, the app is called getting-started. 它目前没有被共享,所以mg官方游戏中心需要启用共享,然后mg官方游戏中心可以得到一个安装链接:

Wait a minute. 在你分享应用之前,Atlassian会要求你提供一些信息:

You’re required to specify the following:

  • the company/department that produced the app

  • 链接到应用程序的客户支持联系信息

  • 链接到应用程序的隐私政策-查看[7]了解更多信息

  • whether the app stores personal data

Once you fill those out with valid information, then click Save Changes, 它会询问你的应用程序所针对的Atlassian Cloud产品, then you can generate an installation link:

然后您可以将安装链接发送给您的客户. 如果客户希望将应用程序安装到他们的Atlassian Cloud站点, 他们的Atlassian Cloud产品或网站管理员可以访问该链接.

Atlassian Marketplace

Forge应用程序可以在Atlassian Marketplace上列出,用户可以从那里安装它. 该市场为你提供了一种向所有Atlassian Cloud客户宣传应用(无论是免费还是付费)的方式. It’s also the only way to distribute a paid and/or licensed Forge app; the Marketplace handles customer subscriptions, billing, payments and related functions for your app. However, once you list your app in the Marketplace, 你不能再通过安装链接分享你的应用. 了解如何将您的应用程序提交到Marketplace上市审批流程, visit Listing Forge Apps [8].[C(L1] 

Continuous Integration and Continuous Deployment for Your App

Now that we’ve explained manual 部署时,您可能想知道,“我如何通过CI/CD自动完成所有这些工作??“如何为Atlassian Forge应用程序配置CI/CD[9]在这方面有很多信息, 使用Bitbucket作为存储库和CI/CD平台.[MB2] [C(L3] [C(L4] [C(L5] [AH6]  It’s actually fairly straightforward; let’s work on an example. 顺便说一下,本节假设您已经具备Bitbucket管道的一般知识.

First, enable your pipelines. 在存储库的设置中,在左侧栏中,单击管道部分的设置:

Then, click Enable Pipelines:

接下来要做的是为Forge凭证定义存储库变量. Forge CLI命令将成为您的CI/CD步骤的一部分,它将自动使用这些凭证来访问和上传Forge环境, so that your pipelines don’t need to issue a forge login command. 在存储库的左侧栏中,单击repository Settings:

然后,在左侧栏的管道部分,单击Repository Variables:

在弹出的页面中添加以下变量:

  • FORGE_EMAIL:用于CI/CD目的的对Bitbucket和Forge有足够访问权限的Forge用户的电子邮件地址.

  • FORGE_API_TOKEN: The API token defined for the above Forge user. Make it a secured/encrypted variable.

Now, let’s create a bitbucket-pipelines.yml 在存储库的根目录中,让mg官方游戏中心在其中定义一些东西.

Getting Started with Forge[10]表明您必须使用Node 14、16或18的LTS版本. 在文件的顶部,mg官方游戏中心将指定mg官方游戏中心希望使用Node 18:


Now, let’s define a step for smoke testing. 每当将更改推送到存储库中的任何代码分支时,都会运行此步骤. It will install npm packages, build the front end, turn off usage analytics [11], 安装Forge CLI(使Forge CLI命令可用), then run the Forge linter:

Next, let’s define a branches subsection for our pipelines section. mg官方游戏中心将添加构建代码并将其自动部署到开发环境的步骤 main code branch. We’re limiting these actions to the main branch for simplicity’s sake, 同时也防止它们在任何更改被推送到任何分支时被执行, 例如,尚未批准合并的特定功能的分支 main.

That’s it! 下次将分支推送到Forge应用程序存储库时,将运行冒烟测试管道. The next time you merge to main,构建和部署到开发环境的管道将自动运行. Pretty cool!

Thank You!

mg官方游戏中心讨论了很多关于Forge应用发行的细节. 我希望你发现这篇文章在你的旅程中有价值,把你的Forge应用程序的想法带给世界!

References

Chris Low & Alex Howard

Chris Low是Moser Consulting的高级顾问. For over twenty years, 他为不同的行业设计和开发了不同复杂性的软件.

Alex Howard在Moser工作了8年半, 并担任全生命周期解决方案的应用服务技术主管. In Alex's time at Moser, he has delivered modern, 面向小型和大型商业客户(超过500万美元)的全栈TypeScript应用程序. 他可以,而且倾向于,扮演大多数开发人员或与开发人员相邻的角色(架构师、开发人员等).). In his time at Moser, Alex has demonstrated not only a knack for, but also an incessant drive to, 快速学习新事物,然后将这些知识传播给他的同龄人. 对新技术和爱好感兴趣,并能感染他人, Alex truly loves his role here at Moser.

Previous
Previous

开发Jira应用:Atlassian Forge应用开发的三个技巧

Next
Next

开发一个Jira应用程序:开始与Atlassian Forge