我们可以从仓库运行bash脚本吗?

我是初学者。我不确定这是否可行。我在bitbucket存储库上有一个bash脚本,它可以进行某种设置。要运行该bash脚本,我必须在本地下载该bash脚本并运行.sh文件。有什么方法可以通过Bitbucket存储库运行脚本而无需下载?

评论
  • nrerum
    nrerum 回复

    您总是需要下载该文件(即:从服务器中检索文件),但是您可以生成一条管线来一次检索并执行。最简单的是:

    curl ${url} | bash
    

    You'll need to locate the URL that presents the raw file (rather than the HTML web page). For BitBucket this will look something like below. You can substitue ${commit_id} for a branch or tag name instead.

    https://bitbucket.org/${user}/${repo}/raw/${commit_id}/${file}
    

    Beware however that this often causes raised eyebrows from a security point of view, especially if retrieving the file via HTTP (rather than HTTPS), as you're basically running unknown code on your computer. Using sudo in this pipeline is even more concerning.

    用户需要做好准备以信任存储在存储库中的任何内容,因此请确保仅允许受信任的用户推送(或合并),并确保您仔细查看对相关文件的更改。