简体   繁体   English

无法为 Gitlab CI/CD 管道设置执行策略

[英]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,例如shbash ),而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.

相关问题 即使代码在 gitlab CI/CD 管道中没有正确类型提示,`mypy` 也会返回退出状态为 0 - `mypy` returning with exit status of 0 even though code is not properly type hinted in gitlab CI/CD pipeline Gitlab CI/CD 验证 powershell 脚本 - Gitlab CI/CD validate powershell script 使用 Powershell 脚本在 Azure 上配置 CI/CD 管道 - configuration CI/CD pipeline on Azure with Powershell Script 用于测试 java gitlab CI/CD 的所有单元测试的命令 - command to test all unit tests for java gitlab CI/CD 如何使用 powershell 在 GitLab CI/CD 脚本中运行可执行文件 - How to run an executable file in GitLab CI/CD script using powershell 从流程设置执行策略 - Set-Execution Policy from process Ansible,如何设置Execution-Policy为RemoteSigned? - In Ansible, how to set Execution-Policy to RemoteSigned? Powershell甚至无法执行设置执行策略 - Powershell cannot execute even set the execution policy 如何在 Azure DevOps 中为 QnAMaker ChatBot 虚拟助手模板创建 CI/CD 管道 - How to create CI/CD pipeline for QnAMaker ChatBot Virtual Assistant Template in Azure DevOps Gitlab CI/CD 在“清理项目目录和基于文件的变量”时失败并显示“错误:作业失败:退出代码 1” - Gitlab CI/CD fails while "Cleaning up project directory and file based variables" with "ERROR: Job failed: exit code 1"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM