gpt4 book ai didi

bash - exec-maven-plugin 无法执行 .sh 脚本 : permission denied

转载 作者:行者123 更新时间:2023-12-04 16:09:01 25 4
gpt4 key购买 nike

我有一个 bash 脚本,我希望 maven 在编译阶段之后运行它,因为该脚本应该部署包。这是我试图在我的发布模块中使用的插件:

<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution>
<id>deploy-bundles</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${basedir}/deploy.sh</executable>
</configuration>
</execution>
</executions>
</plugin>

我在正确的路径中有 deploy.sh,因此已验证。现在,当我执行 mvn install 时,出现以下错误:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:exec (deploy-bundles) on project module.release: Command execution failed. Cannot run program "/bla/bla/module.release/deploy.sh" (in directory "/bla/bla/module.release"): error=13, Permission denied -> [Help 1]

首先,我认为这与我编写的 bash 脚本有关。所以我把它改成了一个简单的 bash 脚本,像这样:

#!/bin/bash          
STR="Hello World!"
echo $STR

但是,我遇到了同样的错误。所以这与代码无关。我应该赋予 Maven 特权吗?应该使用 sudo 命令吗?

最佳答案

获取存储在 VCS 中的文件权限可能很棘手,并不是每个 VCS 都擅长此操作。

相反,您可以使用脚本作为参数执行 /bin/bash(并从脚本中删除 #!... 行)。

您的配置可能如下所示:

<configuration>
<executable>/bin/bash</executable>
<arguments><argument>${basedir}/deploy.sh</argument></arguments>
</configuration>

(而且,一般情况下,/bin/sh 更便携,bash 可以在许多不同的地方。)

关于bash - exec-maven-plugin 无法执行 .sh 脚本 : permission denied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38393595/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com