create_build_info_js

This script will create a file with the given name containing build information accessible by JavaScript code.

The value of build.id is depending on where this script is run:

locally

the current timestamp

AppVeyor

the value of the APPVEYOR_BUILD_ID environment variable

Bitbucket

the value of the BITBUCKET_BUILD_NUMBER environment variable

CircleCI

the value of the CIRCLE_WORKFLOW_ID environment variable

GitHub

the value of the GITHUB_RUN_ID environment variable

GitLab

the value of the CI_PIPELINE_ID environment variable

Jenkins

the value of the BUILD_ID environment variable

TeamCity

the value of the BUILD_NUMBER environment variable

Travis

the value of the TRAVIS_BUILD_ID environment variable

The value of build.time is either the value of the SOURCE_DATE_EPOCH environment variable or the current timestamp.

Usage

$ scripts/web/create_build_info_js.sh src/build-info.mjs

src/build-info.mjs
export const buildInfo = {
  build: {
    id: '1710116787',
    time: '2024-03-11T00:26:27Z',
  },
  git: {
    branch: 'main',
    commit: {
      id: '4768a3cf26cecc00a23be6acdf430809e4bb67a7',
      time: '2024-03-11T00:25:48Z',
    },
  },
};