[英]Unable to Set Execution Policy for Gitlab CI/CD Pipeline
I have created an Amazon Alexa Skill and I have also added ask-cli support to it.我已经创建了一个 Amazon Alexa Skill,并且还向它添加了 ask-cli 支持。 When I was trying to deploy it using ask-cli an error came ie当我尝试使用 ask-cli 部署它时出现错误,即
/bin/sh: 1: hooks/pre_deploy_hook.sh: Permission denied [Error]: Hook Scripts failed
Then, I opened Powershell as administrator and run the following command:然后,我以管理员身份打开Powershell并运行以下命令:
Set-ExecutionPolicy Unrestricted
After that I successfully deployed the skill from my system.之后,我成功地从我的系统部署了该技能。 Then I uploaded my project at gitlab and want to deploy it from gitlab CI/CD whenever a commit occurs in master branch.然后我在 gitlab 上传了我的项目,并希望在 master 分支中发生提交时从 gitlab CI/CD 部署它。 But it's showing the same hook script error.但它显示了相同的钩子脚本错误。 Then, I changed my .gitlab-ci.yml file for just changing the policy and not deploying the skill.然后,我更改了我的.gitlab-ci.yml文件以仅更改策略而不是部署技能。 Then again an error occurred.然后再次发生错误。
Now, I want to deploy my skill throught gitlab ci/cd whenever a commit occurs in master branch and for that I need to set Exection Policy to Unrestricted.现在,我想在 master 分支中发生提交时通过 gitlab ci/cd 部署我的技能,为此我需要将 Exection Policy 设置为 Unrestricted。 Please tell me how can do that.请告诉我怎么做。
Note that the error message is complaining about a *.sh
file, implying a Unix shell script (typically, a POSIX-like shell such as sh
or bash
), whereas Set-ExecutionPolicy
applies exclusively to PowerShell scripts ( *.ps1
) - and isn't supported on Unix-like platforms at all.请注意,错误消息是抱怨*.sh
文件,这意味着Unix shell 脚本(通常,类似于 POSIX 的 shell,例如sh
或bash
),而Set-ExecutionPolicy
仅适用于PowerShell脚本 ( *.ps1
) - 和在类 Unix 平台上根本不支持。 [1] [1]
Specifically, the Permission denied
error suggest that script file hooks/pre_deploy_hook.sh
isn't executable (doesn't have executable permissions ).具体来说, Permission denied
错误表明脚本文件hooks/pre_deploy_hook.sh
不可执行(没有可执行权限)。
To make it executable (by anyone), run something like:要使其可执行(任何人),请运行以下命令:
chmod a+x .git/hooks/pre_deploy_hook.sh
from your project folder.从您的项目文件夹。
[1] On Unix-like platforms, PowerShell's execution policies don't apply: in Windows terms, it's as if the Bypass
policy were in effect (even though Get-ExecutionPolicy
reports Unrestricted
). [1] 在类 Unix 平台上,PowerShell 的执行策略不适用:在 Windows 术语中,就好像Bypass
策略有效(即使Get-ExecutionPolicy
报告Unrestricted
)。 An attempt to set the policy makes Set-ExecutionPolicy
fail with Operation is not supported on this platform
, as shown in your screenshot.如屏幕截图所示,尝试设置策略会使Set-ExecutionPolicy
失败并显示Operation is not supported on this platform
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.