简体   繁体   English

根据 git 分支更改 serverless.yml 阶段

[英]Change serverless.yml stage depending on git branch

I have a nodejs project set up with bitbucket ci/cd - is there any way to programmatically change the Stage from dev to what ever git branch I am on?我有一个使用 bitbucket ci/cd 设置的 nodejs 项目——有什么方法可以以编程方式将 Stage 从 dev 更改为我所在的 git 分支吗?

Serverless.yml:无服务器.yml:

stage: ${opt:stage, "dev"}阶段:${opt:stage, "dev"}

I have tried to use this package ( https://www.npmjs.com/package/serverless-plugin-git-variables ) but it doesn't seem to be working.我试过使用这个 package ( https://www.npmjs.com/package/serverless-plugin-git-variables ) 但它似乎没有用。

Introduction介绍

Hi, a git repo is defined by the hidden .git directory present inside the repo itself, if you are on linux based system you can find the folder using the following command in your terminal inside your project嗨, git repo是由回购本身内部存在的隐藏.git目录定义的,如果您在基于 linux 的系统上,您可以在项目中的终端中使用以下命令找到该文件夹

ls -al 

Inside the.git you can find a file called HEAD that contains the current head branch for the project ie: ref: refs/heads/3-implement-some feature在 .git 中,您可以找到一个名为HEAD的文件,其中包含项目的当前 head 分支,即: ref: refs/heads/3-implement-some feature

Conlcusion结论

Basically what i mean is that you can access to this file inside your project and define your desired custom logic.基本上我的意思是您可以在项目中访问此文件并定义所需的自定义逻辑。 I hope this can help you in some way.我希望这能以某种方式帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM