在 Cloud Build 期间将存储库名称传递给 Slack 机器人
Pass Repository Name to Slack bot during Cloud Build
我正在关注 the documentation to get a Slack bot to report on Cloud Build progress for a Project in Google Cloud Platform, using the Slack image found in Google Cloud Builder Community。我已经能够成功地将开箱即用的消息发送到 post。
因为我有多个要构建的存储库,我想post正在构建的存储库的名称:
例如
Build bot: Repo Fizz-buzz built successfully...
Build bot: Repo Wizz-bang failed to build...
在 Notify()
函数中,cloudbuild.Build
结构有一些属性可以满足我的要求。 Source.RepoSource.RepoName
看起来很理想,但它是零。
另一种选择是让 trigger() 函数将存储库名称添加为参数:
Args: []string{
fmt.Sprintf("--build=%s", build),
fmt.Sprintf("--webhook=%s", webhook),
fmt.Sprintf("--repoName=%s", repoName),
"--mode=monitor",
},
我更愿意让 Notify() 函数处理这个,但我还没有找到合适的结构 属性。
我可以在 notify() 函数中使用 属性 来传递存储库名称吗?
我使用 github 应用触发构建并使用 build.substitutions.REPO_NAME
我正在关注 the documentation to get a Slack bot to report on Cloud Build progress for a Project in Google Cloud Platform, using the Slack image found in Google Cloud Builder Community。我已经能够成功地将开箱即用的消息发送到 post。
因为我有多个要构建的存储库,我想post正在构建的存储库的名称:
例如
Build bot: Repo Fizz-buzz built successfully...
Build bot: Repo Wizz-bang failed to build...
在 Notify()
函数中,cloudbuild.Build
结构有一些属性可以满足我的要求。 Source.RepoSource.RepoName
看起来很理想,但它是零。
另一种选择是让 trigger() 函数将存储库名称添加为参数:
Args: []string{
fmt.Sprintf("--build=%s", build),
fmt.Sprintf("--webhook=%s", webhook),
fmt.Sprintf("--repoName=%s", repoName),
"--mode=monitor",
},
我更愿意让 Notify() 函数处理这个,但我还没有找到合适的结构 属性。
我可以在 notify() 函数中使用 属性 来传递存储库名称吗?
我使用 github 应用触发构建并使用 build.substitutions.REPO_NAME