GCP Slack 构建通知的自定义消息

Custom Message for GCP Slack Build Notification

我按照 this 教程成功设置了 GCP Slack 构建通知。现在,我收到以下 Slack 消息:

// createSlackMessage creates a message from a build object.
const createSlackMessage = (build) => {
  const message = {
    text: `Build \`${build.id}\``,
    mrkdwn: true,
    attachments: [
      {
        title: 'Build logs',
        title_link: build.logUrl,
        fields: [{
          title: 'Status',
          value: build.status
        }]
      }
    ]
  };
  return message;
}

除了这里的内容之外,我还想要项目 ID、部署它的用户以及我在部署期间使用的其他环境变量等信息(例如,我使用 _ENV 来区分开发服务器和生产服务器服务器)。提取此类信息的方法是什么?我在哪里可以找到对对象列表的引用 build 对象?如果默认情况下 build 没有我想要的对象,我可以以某种方式添加它吗?

看看 here,那里有您可以使用的所有可用选项。

希望这对您有所帮助。

更新:

不确定您是否可以添加自定义变量,但我认为替换可能就是您要找的。

Use substitutions in your build config file to substitute specific variables at runtime. Substitutions are helpful for variables whose value isn't known until build time, or to re-use an existing build request with different variable values.

Cloud Build provides built-in substitutions or you can define your own substitutions. Use the substitutions field in your build's steps and images fields to resolve their values at build time.

Here 你有更多关于他们的信息。

告诉我。