1
我在我的Jenkins服務器上運行構建,我正在尋找使用當前構建中的提交編號動態填充git_commit字段。該文件中有多個函數,我想使用sed來匹配模塊的core-lambda-function1名稱,並使用當前版本的提交編號更新git_commit字段。任何幫助表示讚賞。謝謝。替換terraform文件中的代碼塊
module "core-lambda-function1" {
source = "./lambda"
name = "core-lambda-function"
runtime = "nodejs6.10"
role = "${aws_iam_role.iam_role_for_lambda.arn}"
filename = "../Archive.zip"
source_code_hash = "${base64sha256(file("../Archive.zip"))}"
source_dir = "../"
git_commit = ""
}
module "core-lambda-function2" {
source = "./lambda"
name = "core-lambda-function"
runtime = "nodejs6.10"
role = "${aws_iam_role.iam_role_for_lambda.arn}"
filename = "../Archive.zip"
source_code_hash = "${base64sha256(file("../Archive.zip"))}"
source_dir = "../"
git_commit = ""
}
這是我目前擁有的。
#!/bin/bash
set -e
while read p; do
NAME=$p
GIT_COMMIT=`git rev-parse HEAD`
echo $NAME | grep `xargs` main.tf -A 7 | sed -ri '7s/git_commit = ""/git_commit\ = \"'$GIT_COMMIT'"/g'
done < build_name
像這樣太: terraform計劃-var 「git_commit ='git的REV-解析HEAD'」 – dpn
看來這工作,我從來沒有這樣試過。 – BMW