CodeDeploy – 如何在CodeDeploy脚本中添加用户输入

huangapple go评论78阅读模式
英文:

CodeDeploy - How to add user input in CodeDeploy script

问题

我正在尝试在CodeDeploy脚本中添加用户输入。以下是我的代码:

#!/bin/bash
# 启动服务应用程序
read -p "请输入配置文件路径:" -r config_path
java -jar Testing-1.0-SNAPSHOT-jar-with-dependencies.jar ${config_path} > /dev/null 2> /dev/null < /dev/null &

我使用了> /dev/null 2> /dev/null < /dev/null &,因为这是一个长时间运行的进程,我希望在进程启动后CodeDeploy可以继续运行。但是现在它没有要求我输入配置文件路径,也没有显示任何错误。
非常感谢您的帮助。

英文:

I'm trying to add a an user input in CodeDeploy script. Here is my code

#!/bin/bash
# start service application
read -p &quot;Please Enter Path For Configuration File:&quot; -r config_path
java -jar Testing-1.0-SNAPSHOT-jar-with-dependencies.jar ${config_path} &gt; /dev/null 2&gt; /dev/null &lt; /dev/null &amp;

I'm using the > /dev/null 2> /dev/null < /dev/null & because it's a long-running process, and I want CodeDeploy to continue after the process starts. But right now, it doesn't ask me to enter the path for config file, nor show any error.
Any help is much appreciated.

答案1

得分: 1

很抱歉,这不是CodeDeploy挂钩脚本支持的功能。

脚本中传递的唯一参数是CodeDeploy已发布的环境变量,它们如下:

  • LIFECYCLE_EVENT:此变量包含与脚本关联的生命周期事件的名称。
  • DEPLOYMENT_ID:当前部署的部署ID包含在这些变量中。
  • APPLICATION_NAME:此变量包含正在部署的应用程序的名称。这是用户在控制台或AWS CLI中设置的名称。
  • DEPLOYMENT_GROUP_NAME:此变量包含部署组的名称。部署组是与应用程序关联的一组实例,您将其用于部署。
  • DEPLOYMENT_GROUP_ID:此变量包含与当前部署对应的AWS CodeDeploy中的部署组的ID。

您可以尝试使用其中一个来控制您要确定的逻辑。

英文:

Unfortunately this is not functionality that is supported within the CodeDeploy hook scripts.

The only arguments that are passed into the script are the environment variables that CodeDeploy has published, these are below:

  • LIFECYCLE_EVENT : This variable contains the name of the lifecycle event associated with the script.
  • DEPLOYMENT_ID : This variables contains the deployment ID of the current deployment.
  • APPLICATION_NAME : This variable contains the name of the application being deployed. This is the name the user sets in the console or AWS CLI.
  • DEPLOYMENT_GROUP_NAME : This variable contains the name of the deployment group. A deployment group is a set of instances associated with an application that you target for a deployment.
  • DEPLOYMENT_GROUP_ID : This variable contains the ID of the deployment group in AWS CodeDeploy that corresponds to the current deployment

You might be able to use one of these to control the logic you're trying to determine.

huangapple
  • 本文由 发表于 2020年8月11日 01:25:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/63345067.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定