From b35338adc1489441eaaa00911dfa8eb4f7fb8e33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Thu, 10 Jun 2021 12:56:45 +0100 Subject: [PATCH 1/5] WIP: Add script that updates testdata with missing env vars --- create-meta/ciDict.json | 2 +- create-meta/testdata/AzurePipelines.txt | 2 +- create-meta/testdata/Bamboo.txt | 4 ++ create-meta/testdata/Buddy.txt | 5 +++ create-meta/testdata/CircleCI.txt | 5 +++ create-meta/testdata/CodeFresh.txt | 4 ++ create-meta/testdata/GitHubActions.txt | 4 +- create-meta/testdata/GitLab.txt | 5 +++ create-meta/testdata/Semaphore.txt | 6 +++ create-meta/testdata/TeamCity.txt | 4 ++ create-meta/testdata/TravisCI.txt | 5 +++ create-meta/testdata/Wercker.txt | 6 +++ create-meta/update-testdata.rb | 43 +++++++++++++++++++++ messages/go/messages.go | 7 ++-- messages/javascript/src/messages.ts | 2 + messages/jsonschema/Meta.json | 4 ++ messages/messages.md | 1 + messages/ruby/lib/cucumber/messages.dtos.rb | 7 ++++ 18 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 create-meta/testdata/Bamboo.txt create mode 100644 create-meta/testdata/Buddy.txt create mode 100644 create-meta/testdata/CircleCI.txt create mode 100644 create-meta/testdata/CodeFresh.txt create mode 100644 create-meta/testdata/GitLab.txt create mode 100644 create-meta/testdata/Semaphore.txt create mode 100644 create-meta/testdata/TeamCity.txt create mode 100644 create-meta/testdata/TravisCI.txt create mode 100644 create-meta/testdata/Wercker.txt create mode 100644 create-meta/update-testdata.rb diff --git a/create-meta/ciDict.json b/create-meta/ciDict.json index 5ec7ce1695..c9425de5db 100644 --- a/create-meta/ciDict.json +++ b/create-meta/ciDict.json @@ -1,6 +1,6 @@ { "Azure Pipelines": { - "url": "${BUILD_URI}", + "url": "${BUILD_BUILDURI}", "git": { "remote": "${BUILD_REPOSITORY_URI}", "revision": "${BUILD_SOURCEVERSION}", diff --git a/create-meta/testdata/AzurePipelines.txt b/create-meta/testdata/AzurePipelines.txt index 2d28e6cb7e..d9089a78b9 100644 --- a/create-meta/testdata/AzurePipelines.txt +++ b/create-meta/testdata/AzurePipelines.txt @@ -1,4 +1,4 @@ -BUILD_URI=https://cihost.com/path/to/the/build +BUILD_BUILDURI=https://cihost.com/path/to/the/build BUILD_REPOSITORY_URI=https://scmhost.com/path/to/the/project BUILD_SOURCEBRANCH=refs/heads/main BUILD_SOURCEVERSION=decafbad diff --git a/create-meta/testdata/Bamboo.txt b/create-meta/testdata/Bamboo.txt new file mode 100644 index 0000000000..aac412ea6e --- /dev/null +++ b/create-meta/testdata/Bamboo.txt @@ -0,0 +1,4 @@ +bamboo.buildResultsUrl=??? +bamboo.planRepository.1.branch=??? +bamboo.planRepository.1.repositoryUrl=??? +bamboo.planRepository.1.revision=??? diff --git a/create-meta/testdata/Buddy.txt b/create-meta/testdata/Buddy.txt new file mode 100644 index 0000000000..379ed04265 --- /dev/null +++ b/create-meta/testdata/Buddy.txt @@ -0,0 +1,5 @@ +BUDDY_EXECUTION_BRANCH=??? +BUDDY_EXECUTION_REVISION=??? +BUDDY_EXECUTION_TAG=??? +BUDDY_EXECUTION_URL=??? +BUDDY_SCM_URL=??? diff --git a/create-meta/testdata/CircleCI.txt b/create-meta/testdata/CircleCI.txt new file mode 100644 index 0000000000..d9648ea93f --- /dev/null +++ b/create-meta/testdata/CircleCI.txt @@ -0,0 +1,5 @@ +CIRCLE_BRANCH=??? +CIRCLE_BUILD_URL=??? +CIRCLE_REPOSITORY_URL=??? +CIRCLE_SHA1=??? +CIRCLE_TAG=??? diff --git a/create-meta/testdata/CodeFresh.txt b/create-meta/testdata/CodeFresh.txt new file mode 100644 index 0000000000..6133e5792e --- /dev/null +++ b/create-meta/testdata/CodeFresh.txt @@ -0,0 +1,4 @@ +CF_BRANCH=??? +CF_BUILD_URL=??? +CF_COMMIT_URL=??? +CF_REVISION=??? diff --git a/create-meta/testdata/GitHubActions.txt b/create-meta/testdata/GitHubActions.txt index 62abf3892b..a8e57dfb90 100644 --- a/create-meta/testdata/GitHubActions.txt +++ b/create-meta/testdata/GitHubActions.txt @@ -20,7 +20,7 @@ DOTNET_SKIP_FIRST_TIME_EXPERIENCE="1" CI=true DOTNET_NOLOGO="1" USER=runner -GITHUB_HEAD_REF= +GITHUB_HEAD_REF GITHUB_ACTOR=aslakhellesoy GITHUB_ACTION=run2 GRADLE_HOME=/usr/share/gradle @@ -49,7 +49,7 @@ CHROMEWEBDRIVER=/usr/local/share/chrome_driver HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew" GITHUB_GRAPHQL_URL=https://api.github.com/graphql RUNNER_OS=Linux -GITHUB_BASE_REF= +GITHUB_BASE_REF VCPKG_INSTALLATION_ROOT=/usr/local/share/vcpkg GITHUB_JOB=test PERFLOG_LOCATION_SETTING=RUNNER_PERFLOG diff --git a/create-meta/testdata/GitLab.txt b/create-meta/testdata/GitLab.txt new file mode 100644 index 0000000000..6be5ff5e15 --- /dev/null +++ b/create-meta/testdata/GitLab.txt @@ -0,0 +1,5 @@ +CI_COMMIT_BRANCH=??? +CI_COMMIT_SHA=??? +CI_COMMIT_TAG=??? +CI_JOB_URL=??? +CI_REPOSITORY_URL=??? diff --git a/create-meta/testdata/Semaphore.txt b/create-meta/testdata/Semaphore.txt new file mode 100644 index 0000000000..fc8ba65192 --- /dev/null +++ b/create-meta/testdata/Semaphore.txt @@ -0,0 +1,6 @@ +SEMAPHORE_GIT_BRANCH=??? +SEMAPHORE_GIT_SHA=??? +SEMAPHORE_GIT_TAG_NAME=??? +SEMAPHORE_GIT_URL=??? +SEMAPHORE_JOB_ID=??? +SEMAPHORE_ORGANIZATION_URL=??? diff --git a/create-meta/testdata/TeamCity.txt b/create-meta/testdata/TeamCity.txt new file mode 100644 index 0000000000..5073dd9a0d --- /dev/null +++ b/create-meta/testdata/TeamCity.txt @@ -0,0 +1,4 @@ +build.vcs.number=??? +teamcity.build.branch=??? +teamcity.build.id=??? +teamcity.serverUrl=??? diff --git a/create-meta/testdata/TravisCI.txt b/create-meta/testdata/TravisCI.txt new file mode 100644 index 0000000000..488397fe68 --- /dev/null +++ b/create-meta/testdata/TravisCI.txt @@ -0,0 +1,5 @@ +TRAVIS_BRANCH=??? +TRAVIS_BUILD_WEB_URL=??? +TRAVIS_COMMIT=??? +TRAVIS_REPO_SLUG=??? +TRAVIS_TAG=??? diff --git a/create-meta/testdata/Wercker.txt b/create-meta/testdata/Wercker.txt new file mode 100644 index 0000000000..40ab15aa0f --- /dev/null +++ b/create-meta/testdata/Wercker.txt @@ -0,0 +1,6 @@ +WERCKER_GIT_BRANCH=??? +WERCKER_GIT_COMMIT=??? +WERCKER_GIT_DOMAIN=??? +WERCKER_GIT_OWNER=??? +WERCKER_GIT_REPOSITORY=??? +WERCKER_RUN_URL=??? diff --git a/create-meta/update-testdata.rb b/create-meta/update-testdata.rb new file mode 100644 index 0000000000..45266140d9 --- /dev/null +++ b/create-meta/update-testdata.rb @@ -0,0 +1,43 @@ +require 'json' +require 'set' + +ciDict = JSON.parse(File.read(File.dirname(__FILE__) + '/ciDict.json')) + +def collect_vars(ob, env_vars) + ob.each do |key, val| + if val.is_a?(String) + # RegExp copied from ruby/lib/cucumber/create_meta/variable_expression + # Collect all variables + val.scan(/\${(.*?)(?:(? Git) git?: Git } diff --git a/messages/jsonschema/Meta.json b/messages/jsonschema/Meta.json index f43d3c626b..4fce192c08 100644 --- a/messages/jsonschema/Meta.json +++ b/messages/jsonschema/Meta.json @@ -18,6 +18,10 @@ "description": "Link to the build", "type": "string" }, + "buildNumber": { + "description": "The build number. Some CI servers use non-numeric build numbers, which is why this is a string", + "type": "string" + }, "git": { "$ref": "#/definitions/Git" } diff --git a/messages/messages.md b/messages/messages.md index 2e0865d665..6a7cd918f2 100644 --- a/messages/messages.md +++ b/messages/messages.md @@ -218,6 +218,7 @@ will only have one of its fields set, which indicates the payload of the message | ----- | ---- | ----------- | ----------- | | `name` | string | yes | | | `url` | string | no | | +| `buildNumber` | string | no | | | `git` | [Git](#git) | no | | ## Git diff --git a/messages/ruby/lib/cucumber/messages.dtos.rb b/messages/ruby/lib/cucumber/messages.dtos.rb index 0fe9a7840a..32b27ae24b 100644 --- a/messages/ruby/lib/cucumber/messages.dtos.rb +++ b/messages/ruby/lib/cucumber/messages.dtos.rb @@ -946,15 +946,22 @@ class Ci attr_reader :url + ## + # The build number. Some CI servers use non-numeric build numbers, which is why this is a string + + attr_reader :build_number + attr_reader :git def initialize( name: '', url: nil, + build_number: nil, git: nil ) @name = name @url = url + @build_number = build_number @git = git end end From 9d6ab8e6028f25cbf64d836a014f5e601357d964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Thu, 24 Jun 2021 15:58:08 +0100 Subject: [PATCH 2/5] Improve tests for create-meta. Remove TeamCity. --- create-meta/CHANGELOG.md | 2 ++ create-meta/README.md | 2 -- create-meta/ciDict.json | 11 +---------- .../resources/io/cucumber/createmeta/ciDict.json | 13 ++----------- create-meta/javascript/src/ciDict.json | 13 ++----------- create-meta/javascript/test/createMetaTest.ts | 4 ++-- create-meta/ruby/lib/cucumber/ciDict.json | 13 ++----------- create-meta/testdata/Bamboo.txt | 8 ++++---- create-meta/testdata/Bamboo.txt.json | 9 +++++++++ create-meta/testdata/Bitrise.txt | 1 + create-meta/testdata/Bitrise.txt.json | 1 + create-meta/testdata/Buddy.txt | 10 +++++----- create-meta/testdata/Buddy.txt.json | 10 ++++++++++ create-meta/testdata/CircleCI.txt | 10 +++++----- create-meta/testdata/CircleCI.txt.json | 10 ++++++++++ create-meta/testdata/CodeFresh.txt | 8 ++++---- create-meta/testdata/CodeFresh.txt.json | 9 +++++++++ create-meta/testdata/GitLab.txt | 9 ++++----- .../testdata/{GitlabCI.txt.json => Gitlab.txt.json} | 0 create-meta/testdata/GitlabCI.txt | 4 ---- create-meta/testdata/Semaphore.txt | 12 ++++++------ create-meta/testdata/Semaphore.txt.json | 10 ++++++++++ create-meta/testdata/TeamCity.txt | 4 ---- create-meta/testdata/TravisCI.txt | 10 +++++----- create-meta/testdata/TravisCI.txt.json | 10 ++++++++++ create-meta/testdata/Wercker.txt | 12 ++++++------ create-meta/testdata/Wercker.txt.json | 9 +++++++++ create-meta/update-testdata.rb | 3 +++ 28 files changed, 122 insertions(+), 95 deletions(-) create mode 100644 create-meta/testdata/Bamboo.txt.json create mode 100644 create-meta/testdata/Buddy.txt.json create mode 100644 create-meta/testdata/CircleCI.txt.json create mode 100644 create-meta/testdata/CodeFresh.txt.json rename create-meta/testdata/{GitlabCI.txt.json => Gitlab.txt.json} (100%) delete mode 100644 create-meta/testdata/GitlabCI.txt create mode 100644 create-meta/testdata/Semaphore.txt.json delete mode 100644 create-meta/testdata/TeamCity.txt create mode 100644 create-meta/testdata/TravisCI.txt.json create mode 100644 create-meta/testdata/Wercker.txt.json diff --git a/create-meta/CHANGELOG.md b/create-meta/CHANGELOG.md index 6aa5f3ad9b..abfa48b8d3 100644 --- a/create-meta/CHANGELOG.md +++ b/create-meta/CHANGELOG.md @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Removed +* Removed support for TeamCity since it doesn't seem to expose enough environment variables. + ### Fixed ## [5.0.0] - 2021-05-17 diff --git a/create-meta/README.md b/create-meta/README.md index 6cc4ffc702..9b5fe6f1d5 100644 --- a/create-meta/README.md +++ b/create-meta/README.md @@ -19,8 +19,6 @@ defined by the following supported CI and build servers: * [GoCD](https://docs.gocd.org/current/faq/dev_use_current_revision_in_build.html) * [Jenkins](https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables) and [Jenkins Git plugin](https://plugins.jenkins.io/git/#environment-variables) * [Semaphore](https://docs.semaphoreci.com/ci-cd-environment/environment-variables/) -* [TeamCity](https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html) - * Also see [REST API](https://www.jetbrains.com/help/teamcity/rest-api.html#) * [Travis CI](https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables) * [Wercker](https://devcenter.wercker.com/administration/environment-variables/available-env-vars/) diff --git a/create-meta/ciDict.json b/create-meta/ciDict.json index c9425de5db..003702e865 100644 --- a/create-meta/ciDict.json +++ b/create-meta/ciDict.json @@ -47,7 +47,7 @@ "CodeFresh": { "url": "${CF_BUILD_URL}", "git": { - "remote": "${CF_COMMIT_URL}", + "remote": "${CF_COMMIT_URL/(.*)\\/commit.+$/\\1}.git", "revision": "${CF_REVISION}", "branch": "${CF_BRANCH}", "tag": null @@ -107,15 +107,6 @@ "tag": "${SEMAPHORE_GIT_TAG_NAME}" } }, - "TeamCity": { - "url": "${teamcity.serverUrl}/app/rest/builds/id:${teamcity.build.id}", - "git": { - "remote": null, - "revision": "${build.vcs.number}", - "branch": "${teamcity.build.branch}", - "tag": null - } - }, "Travis CI": { "url": "${TRAVIS_BUILD_WEB_URL}", "git": { diff --git a/create-meta/java/src/main/resources/io/cucumber/createmeta/ciDict.json b/create-meta/java/src/main/resources/io/cucumber/createmeta/ciDict.json index 5ec7ce1695..003702e865 100644 --- a/create-meta/java/src/main/resources/io/cucumber/createmeta/ciDict.json +++ b/create-meta/java/src/main/resources/io/cucumber/createmeta/ciDict.json @@ -1,6 +1,6 @@ { "Azure Pipelines": { - "url": "${BUILD_URI}", + "url": "${BUILD_BUILDURI}", "git": { "remote": "${BUILD_REPOSITORY_URI}", "revision": "${BUILD_SOURCEVERSION}", @@ -47,7 +47,7 @@ "CodeFresh": { "url": "${CF_BUILD_URL}", "git": { - "remote": "${CF_COMMIT_URL}", + "remote": "${CF_COMMIT_URL/(.*)\\/commit.+$/\\1}.git", "revision": "${CF_REVISION}", "branch": "${CF_BRANCH}", "tag": null @@ -107,15 +107,6 @@ "tag": "${SEMAPHORE_GIT_TAG_NAME}" } }, - "TeamCity": { - "url": "${teamcity.serverUrl}/app/rest/builds/id:${teamcity.build.id}", - "git": { - "remote": null, - "revision": "${build.vcs.number}", - "branch": "${teamcity.build.branch}", - "tag": null - } - }, "Travis CI": { "url": "${TRAVIS_BUILD_WEB_URL}", "git": { diff --git a/create-meta/javascript/src/ciDict.json b/create-meta/javascript/src/ciDict.json index 5ec7ce1695..003702e865 100644 --- a/create-meta/javascript/src/ciDict.json +++ b/create-meta/javascript/src/ciDict.json @@ -1,6 +1,6 @@ { "Azure Pipelines": { - "url": "${BUILD_URI}", + "url": "${BUILD_BUILDURI}", "git": { "remote": "${BUILD_REPOSITORY_URI}", "revision": "${BUILD_SOURCEVERSION}", @@ -47,7 +47,7 @@ "CodeFresh": { "url": "${CF_BUILD_URL}", "git": { - "remote": "${CF_COMMIT_URL}", + "remote": "${CF_COMMIT_URL/(.*)\\/commit.+$/\\1}.git", "revision": "${CF_REVISION}", "branch": "${CF_BRANCH}", "tag": null @@ -107,15 +107,6 @@ "tag": "${SEMAPHORE_GIT_TAG_NAME}" } }, - "TeamCity": { - "url": "${teamcity.serverUrl}/app/rest/builds/id:${teamcity.build.id}", - "git": { - "remote": null, - "revision": "${build.vcs.number}", - "branch": "${teamcity.build.branch}", - "tag": null - } - }, "Travis CI": { "url": "${TRAVIS_BUILD_WEB_URL}", "git": { diff --git a/create-meta/javascript/test/createMetaTest.ts b/create-meta/javascript/test/createMetaTest.ts index b81ea52b4a..0984d36a58 100644 --- a/create-meta/javascript/test/createMetaTest.ts +++ b/create-meta/javascript/test/createMetaTest.ts @@ -82,7 +82,7 @@ describe('createMeta', () => { it('post-processes git refs to branch', () => { const envDict = { - BUILD_URI: 'the-url', + BUILD_BUILDURI: 'the-url', BUILD_REPOSITORY_URI: 'the-remote', BUILD_SOURCEBRANCH: 'refs/heads/main', BUILD_SOURCEVERSION: 'the-revision', @@ -104,7 +104,7 @@ describe('createMeta', () => { it('post-processes git refs to tag', () => { const envDict = { - BUILD_URI: 'the-url', + BUILD_BUILDURI: 'the-url', BUILD_REPOSITORY_URI: 'the-remote', BUILD_SOURCEBRANCH: 'refs/tags/v1.2.3', BUILD_SOURCEVERSION: 'the-revision', diff --git a/create-meta/ruby/lib/cucumber/ciDict.json b/create-meta/ruby/lib/cucumber/ciDict.json index 5ec7ce1695..003702e865 100644 --- a/create-meta/ruby/lib/cucumber/ciDict.json +++ b/create-meta/ruby/lib/cucumber/ciDict.json @@ -1,6 +1,6 @@ { "Azure Pipelines": { - "url": "${BUILD_URI}", + "url": "${BUILD_BUILDURI}", "git": { "remote": "${BUILD_REPOSITORY_URI}", "revision": "${BUILD_SOURCEVERSION}", @@ -47,7 +47,7 @@ "CodeFresh": { "url": "${CF_BUILD_URL}", "git": { - "remote": "${CF_COMMIT_URL}", + "remote": "${CF_COMMIT_URL/(.*)\\/commit.+$/\\1}.git", "revision": "${CF_REVISION}", "branch": "${CF_BRANCH}", "tag": null @@ -107,15 +107,6 @@ "tag": "${SEMAPHORE_GIT_TAG_NAME}" } }, - "TeamCity": { - "url": "${teamcity.serverUrl}/app/rest/builds/id:${teamcity.build.id}", - "git": { - "remote": null, - "revision": "${build.vcs.number}", - "branch": "${teamcity.build.branch}", - "tag": null - } - }, "Travis CI": { "url": "${TRAVIS_BUILD_WEB_URL}", "git": { diff --git a/create-meta/testdata/Bamboo.txt b/create-meta/testdata/Bamboo.txt index aac412ea6e..6ff8e94de3 100644 --- a/create-meta/testdata/Bamboo.txt +++ b/create-meta/testdata/Bamboo.txt @@ -1,4 +1,4 @@ -bamboo.buildResultsUrl=??? -bamboo.planRepository.1.branch=??? -bamboo.planRepository.1.repositoryUrl=??? -bamboo.planRepository.1.revision=??? +bamboo.buildResultsUrl=https://cihost.com/path/to/the/build +bamboo.planRepository.1.branch=main +bamboo.planRepository.1.repositoryUrl=https://github.com/cucumber-ltd/shouty.rb +bamboo.planRepository.1.revision=057f8fe233b17629af084064c2a7b8d1dbb795ad diff --git a/create-meta/testdata/Bamboo.txt.json b/create-meta/testdata/Bamboo.txt.json new file mode 100644 index 0000000000..b597d58e2a --- /dev/null +++ b/create-meta/testdata/Bamboo.txt.json @@ -0,0 +1,9 @@ +{ + "git": { + "branch": "main", + "remote": "https://github.com/cucumber-ltd/shouty.rb", + "revision": "057f8fe233b17629af084064c2a7b8d1dbb795ad" + }, + "name": "Bamboo", + "url": "https://cihost.com/path/to/the/build" +} diff --git a/create-meta/testdata/Bitrise.txt b/create-meta/testdata/Bitrise.txt index d92eee8d3c..6402236df4 100644 --- a/create-meta/testdata/Bitrise.txt +++ b/create-meta/testdata/Bitrise.txt @@ -2,3 +2,4 @@ BITRISE_BUILD_URL=https://cihost.com/path/to/the/build GIT_REPOSITORY_URL=https://scmhost.com/path/to/the/project BITRISE_GIT_BRANCH=main BITRISE_GIT_COMMIT=decafbad +BITRISE_GIT_TAG=v1.2.3 diff --git a/create-meta/testdata/Bitrise.txt.json b/create-meta/testdata/Bitrise.txt.json index 952792594b..ef9aa9a520 100644 --- a/create-meta/testdata/Bitrise.txt.json +++ b/create-meta/testdata/Bitrise.txt.json @@ -1,6 +1,7 @@ { "git": { "branch": "main", + "tag": "v1.2.3", "remote": "https://scmhost.com/path/to/the/project", "revision": "decafbad" }, diff --git a/create-meta/testdata/Buddy.txt b/create-meta/testdata/Buddy.txt index 379ed04265..d99b54b785 100644 --- a/create-meta/testdata/Buddy.txt +++ b/create-meta/testdata/Buddy.txt @@ -1,5 +1,5 @@ -BUDDY_EXECUTION_BRANCH=??? -BUDDY_EXECUTION_REVISION=??? -BUDDY_EXECUTION_TAG=??? -BUDDY_EXECUTION_URL=??? -BUDDY_SCM_URL=??? +BUDDY_EXECUTION_BRANCH=main +BUDDY_EXECUTION_REVISION=057f8fe233b17629af084064c2a7b8d1dbb795ad +BUDDY_EXECUTION_TAG=v1.2.3 +BUDDY_EXECUTION_URL=https://cihost.com/path/to/the/build +BUDDY_SCM_URL=https://github.com/cucumber-ltd/shouty.rb diff --git a/create-meta/testdata/Buddy.txt.json b/create-meta/testdata/Buddy.txt.json new file mode 100644 index 0000000000..5d50694115 --- /dev/null +++ b/create-meta/testdata/Buddy.txt.json @@ -0,0 +1,10 @@ +{ + "git": { + "branch": "main", + "tag": "v1.2.3", + "remote": "https://github.com/cucumber-ltd/shouty.rb", + "revision": "057f8fe233b17629af084064c2a7b8d1dbb795ad" + }, + "name": "Buddy", + "url": "https://cihost.com/path/to/the/build" +} diff --git a/create-meta/testdata/CircleCI.txt b/create-meta/testdata/CircleCI.txt index d9648ea93f..dfee904155 100644 --- a/create-meta/testdata/CircleCI.txt +++ b/create-meta/testdata/CircleCI.txt @@ -1,5 +1,5 @@ -CIRCLE_BRANCH=??? -CIRCLE_BUILD_URL=??? -CIRCLE_REPOSITORY_URL=??? -CIRCLE_SHA1=??? -CIRCLE_TAG=??? +CIRCLE_BRANCH=main +CIRCLE_BUILD_URL=https://cihost.com/path/to/the/build +CIRCLE_REPOSITORY_URL=https://github.com/cucumber-ltd/shouty.rb +CIRCLE_SHA1=057f8fe233b17629af084064c2a7b8d1dbb795ad +CIRCLE_TAG=v1.2.3 diff --git a/create-meta/testdata/CircleCI.txt.json b/create-meta/testdata/CircleCI.txt.json new file mode 100644 index 0000000000..4afb10b9e7 --- /dev/null +++ b/create-meta/testdata/CircleCI.txt.json @@ -0,0 +1,10 @@ +{ + "git": { + "branch": "main", + "tag": "v1.2.3", + "remote": "https://github.com/cucumber-ltd/shouty.rb", + "revision": "057f8fe233b17629af084064c2a7b8d1dbb795ad" + }, + "name": "CircleCI", + "url": "https://cihost.com/path/to/the/build" +} diff --git a/create-meta/testdata/CodeFresh.txt b/create-meta/testdata/CodeFresh.txt index 6133e5792e..33a7f5d0cc 100644 --- a/create-meta/testdata/CodeFresh.txt +++ b/create-meta/testdata/CodeFresh.txt @@ -1,4 +1,4 @@ -CF_BRANCH=??? -CF_BUILD_URL=??? -CF_COMMIT_URL=??? -CF_REVISION=??? +CF_BRANCH=main +CF_BUILD_URL=https://cihost.com/path/to/the/build +CF_COMMIT_URL=https://github.com/cucumber-ltd/shouty.rb/commit/057f8fe233b17629af084064c2a7b8d1dbb795ad +CF_REVISION=057f8fe233b17629af084064c2a7b8d1dbb795ad diff --git a/create-meta/testdata/CodeFresh.txt.json b/create-meta/testdata/CodeFresh.txt.json new file mode 100644 index 0000000000..06f0b2b3d0 --- /dev/null +++ b/create-meta/testdata/CodeFresh.txt.json @@ -0,0 +1,9 @@ +{ + "git": { + "branch": "main", + "remote": "https://github.com/cucumber-ltd/shouty.rb.git", + "revision": "057f8fe233b17629af084064c2a7b8d1dbb795ad" + }, + "name": "CodeFresh", + "url": "https://cihost.com/path/to/the/build" +} diff --git a/create-meta/testdata/GitLab.txt b/create-meta/testdata/GitLab.txt index 6be5ff5e15..086a1f12a1 100644 --- a/create-meta/testdata/GitLab.txt +++ b/create-meta/testdata/GitLab.txt @@ -1,5 +1,4 @@ -CI_COMMIT_BRANCH=??? -CI_COMMIT_SHA=??? -CI_COMMIT_TAG=??? -CI_JOB_URL=??? -CI_REPOSITORY_URL=??? +CI_JOB_URL=https://gitlab.com/cucumber/cucumber/jobs/713869896 +CI_REPOSITORY_URL=https://cukebot:thisIsAVerySensitiveInformation@gitlab.com/cucumber/cucumber.git +CI_COMMIT_SHA=123456789 +CI_COMMIT_BRANCH=main diff --git a/create-meta/testdata/GitlabCI.txt.json b/create-meta/testdata/Gitlab.txt.json similarity index 100% rename from create-meta/testdata/GitlabCI.txt.json rename to create-meta/testdata/Gitlab.txt.json diff --git a/create-meta/testdata/GitlabCI.txt b/create-meta/testdata/GitlabCI.txt deleted file mode 100644 index 086a1f12a1..0000000000 --- a/create-meta/testdata/GitlabCI.txt +++ /dev/null @@ -1,4 +0,0 @@ -CI_JOB_URL=https://gitlab.com/cucumber/cucumber/jobs/713869896 -CI_REPOSITORY_URL=https://cukebot:thisIsAVerySensitiveInformation@gitlab.com/cucumber/cucumber.git -CI_COMMIT_SHA=123456789 -CI_COMMIT_BRANCH=main diff --git a/create-meta/testdata/Semaphore.txt b/create-meta/testdata/Semaphore.txt index fc8ba65192..96c2f65362 100644 --- a/create-meta/testdata/Semaphore.txt +++ b/create-meta/testdata/Semaphore.txt @@ -1,6 +1,6 @@ -SEMAPHORE_GIT_BRANCH=??? -SEMAPHORE_GIT_SHA=??? -SEMAPHORE_GIT_TAG_NAME=??? -SEMAPHORE_GIT_URL=??? -SEMAPHORE_JOB_ID=??? -SEMAPHORE_ORGANIZATION_URL=??? +SEMAPHORE_GIT_BRANCH=main +SEMAPHORE_GIT_SHA=decafbad +SEMAPHORE_GIT_TAG_NAME=v1.0 +SEMAPHORE_GIT_URL=https://scmhost.com/path/to/the/project +SEMAPHORE_JOB_ID=job-123 +SEMAPHORE_ORGANIZATION_URL=https://my.semaphore.com diff --git a/create-meta/testdata/Semaphore.txt.json b/create-meta/testdata/Semaphore.txt.json new file mode 100644 index 0000000000..45331a4500 --- /dev/null +++ b/create-meta/testdata/Semaphore.txt.json @@ -0,0 +1,10 @@ +{ + "git": { + "branch": "main", + "remote": "https://scmhost.com/path/to/the/project", + "revision": "decafbad", + "tag": "v1.0" + }, + "name": "Semaphore", + "url": "https://my.semaphore.com/jobs/job-123" +} diff --git a/create-meta/testdata/TeamCity.txt b/create-meta/testdata/TeamCity.txt deleted file mode 100644 index 5073dd9a0d..0000000000 --- a/create-meta/testdata/TeamCity.txt +++ /dev/null @@ -1,4 +0,0 @@ -build.vcs.number=??? -teamcity.build.branch=??? -teamcity.build.id=??? -teamcity.serverUrl=??? diff --git a/create-meta/testdata/TravisCI.txt b/create-meta/testdata/TravisCI.txt index 488397fe68..ae87554ec9 100644 --- a/create-meta/testdata/TravisCI.txt +++ b/create-meta/testdata/TravisCI.txt @@ -1,5 +1,5 @@ -TRAVIS_BRANCH=??? -TRAVIS_BUILD_WEB_URL=??? -TRAVIS_COMMIT=??? -TRAVIS_REPO_SLUG=??? -TRAVIS_TAG=??? +TRAVIS_BRANCH=main +TRAVIS_BUILD_WEB_URL=https://cihost.com/path/to/the/build +TRAVIS_COMMIT=057f8fe233b17629af084064c2a7b8d1dbb795ad +TRAVIS_REPO_SLUG=cucumber-ltd/shouty.rb +TRAVIS_TAG=v1.2.3 diff --git a/create-meta/testdata/TravisCI.txt.json b/create-meta/testdata/TravisCI.txt.json new file mode 100644 index 0000000000..8f0f03796e --- /dev/null +++ b/create-meta/testdata/TravisCI.txt.json @@ -0,0 +1,10 @@ +{ + "git": { + "branch": "main", + "tag": "v1.2.3", + "remote": "https://github.com/cucumber-ltd/shouty.rb.git", + "revision": "057f8fe233b17629af084064c2a7b8d1dbb795ad" + }, + "name": "Travis CI", + "url": "https://cihost.com/path/to/the/build" +} diff --git a/create-meta/testdata/Wercker.txt b/create-meta/testdata/Wercker.txt index 40ab15aa0f..e89ec82409 100644 --- a/create-meta/testdata/Wercker.txt +++ b/create-meta/testdata/Wercker.txt @@ -1,6 +1,6 @@ -WERCKER_GIT_BRANCH=??? -WERCKER_GIT_COMMIT=??? -WERCKER_GIT_DOMAIN=??? -WERCKER_GIT_OWNER=??? -WERCKER_GIT_REPOSITORY=??? -WERCKER_RUN_URL=??? +WERCKER_GIT_BRANCH=main +WERCKER_GIT_COMMIT=057f8fe233b17629af084064c2a7b8d1dbb795ad +WERCKER_GIT_DOMAIN=github.com +WERCKER_GIT_OWNER=cucumber-ltd +WERCKER_GIT_REPOSITORY=shouty.rb +WERCKER_RUN_URL=https://cihost.com/path/to/the/build diff --git a/create-meta/testdata/Wercker.txt.json b/create-meta/testdata/Wercker.txt.json new file mode 100644 index 0000000000..1b3c90bf03 --- /dev/null +++ b/create-meta/testdata/Wercker.txt.json @@ -0,0 +1,9 @@ +{ + "git": { + "branch": "main", + "remote": "https://github.com/cucumber-ltd/shouty.rb.git", + "revision": "057f8fe233b17629af084064c2a7b8d1dbb795ad" + }, + "name": "Wercker", + "url": "https://cihost.com/path/to/the/build" +} diff --git a/create-meta/update-testdata.rb b/create-meta/update-testdata.rb index 45266140d9..b63b4165b5 100644 --- a/create-meta/update-testdata.rb +++ b/create-meta/update-testdata.rb @@ -1,6 +1,9 @@ require 'json' require 'set' +# This script can be used to update the test data when the ciDict.json file is modified. +# After running this script, the testdata should be inspected and updated manually + ciDict = JSON.parse(File.read(File.dirname(__FILE__) + '/ciDict.json')) def collect_vars(ob, env_vars) From d225c704b4c9e326ae0f91124f59b066f93cdbf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Thu, 24 Jun 2021 21:44:58 +0100 Subject: [PATCH 3/5] Add buildNumber --- create-meta/README.md | 3 ++ create-meta/ciDict.json | 22 ++++++++++--- create-meta/java/pom.xml | 2 +- .../io/cucumber/createmeta/CreateMeta.java | 5 +++ .../io/cucumber/createmeta/ciDict.json | 22 ++++++++++--- .../cucumber/createmeta/CreateMetaTest.java | 3 +- create-meta/javascript/src/ciDict.json | 22 ++++++++++--- create-meta/javascript/src/createMeta.ts | 4 ++- create-meta/javascript/src/types.ts | 1 + create-meta/javascript/test/createMetaTest.ts | 33 +++++++++++++++++++ create-meta/ruby/lib/cucumber/ciDict.json | 22 ++++++++++--- create-meta/ruby/lib/cucumber/create_meta.rb | 1 + create-meta/testdata/AzurePipelines.txt | 1 + create-meta/testdata/AzurePipelines.txt.json | 3 +- create-meta/testdata/Bamboo.txt | 9 ++--- create-meta/testdata/Bamboo.txt.json | 3 +- create-meta/testdata/Bitrise.txt | 1 + create-meta/testdata/Bitrise.txt.json | 3 +- create-meta/testdata/Buddy.txt | 1 + create-meta/testdata/Buddy.txt.json | 3 +- create-meta/testdata/CircleCI.txt | 1 + create-meta/testdata/CircleCI.txt.json | 3 +- create-meta/testdata/CodeFresh.txt | 1 + create-meta/testdata/CodeFresh.txt.json | 3 +- create-meta/testdata/CodeShip.txt | 1 + create-meta/testdata/CodeShip.txt.json | 3 +- create-meta/testdata/GitHubActions.txt.json | 3 +- create-meta/testdata/GitLab.txt | 1 + create-meta/testdata/Gitlab.txt.json | 3 +- create-meta/testdata/GoCD.txt.json | 3 +- create-meta/testdata/Jenkins.txt | 1 + create-meta/testdata/Jenkins.txt.json | 3 +- create-meta/testdata/Semaphore.txt | 2 +- create-meta/testdata/Semaphore.txt.json | 3 +- create-meta/testdata/TravisCI.txt | 1 + create-meta/testdata/TravisCI.txt.json | 3 +- create-meta/testdata/Wercker.txt | 2 +- create-meta/testdata/Wercker.txt.json | 3 +- 38 files changed, 165 insertions(+), 39 deletions(-) diff --git a/create-meta/README.md b/create-meta/README.md index 9b5fe6f1d5..830051aa69 100644 --- a/create-meta/README.md +++ b/create-meta/README.md @@ -42,6 +42,9 @@ Then build and run the tests: If all tests pass, commit your code and send us a pull request. Bonus points if you also update `CHANGELOG.md` and `README.md`. +You might want to look at the source code for [danger](https://github.com/danger/danger/tree/master/lib/danger/ci_source) +to understand how various CI server environment variables should be interpreted. + ## CI definitions The `ciDict.json` file contains definitions of various CI servers. Each property of a CI diff --git a/create-meta/ciDict.json b/create-meta/ciDict.json index 003702e865..4cf94ba4b5 100644 --- a/create-meta/ciDict.json +++ b/create-meta/ciDict.json @@ -1,6 +1,7 @@ { "Azure Pipelines": { "url": "${BUILD_BUILDURI}", + "buildNumber": "${BUILD_BUILDNUMBER}", "git": { "remote": "${BUILD_REPOSITORY_URI}", "revision": "${BUILD_SOURCEVERSION}", @@ -9,16 +10,18 @@ } }, "Bamboo": { - "url": "${bamboo.buildResultsUrl}", + "url": "${bamboo_buildResultsUrl}", + "buildNumber": "${bamboo_buildNumber}", "git": { - "remote": "${bamboo.planRepository.1.repositoryUrl}", - "revision": "${bamboo.planRepository.1.revision}", - "branch": "${bamboo.planRepository.1.branch}", + "remote": "${bamboo_planRepository_repositoryUrl}", + "revision": "${bamboo_planRepository_revision}", + "branch": "${bamboo_planRepository_branch}", "tag": null } }, "Buddy": { "url": "${BUDDY_EXECUTION_URL}", + "buildNumber": "${BUDDY_EXECUTION_ID}", "git": { "remote": "${BUDDY_SCM_URL}", "revision": "${BUDDY_EXECUTION_REVISION}", @@ -28,6 +31,7 @@ }, "Bitrise": { "url": "${BITRISE_BUILD_URL}", + "buildNumber": "${BITRISE_BUILD_NUMBER}", "git": { "remote": "${GIT_REPOSITORY_URL}", "revision": "${BITRISE_GIT_COMMIT}", @@ -37,6 +41,7 @@ }, "CircleCI": { "url": "${CIRCLE_BUILD_URL}", + "buildNumber": "${CIRCLE_BUILD_NUM}", "git": { "remote": "${CIRCLE_REPOSITORY_URL}", "revision": "${CIRCLE_SHA1}", @@ -46,6 +51,7 @@ }, "CodeFresh": { "url": "${CF_BUILD_URL}", + "buildNumber": "${CF_BUILD_ID}", "git": { "remote": "${CF_COMMIT_URL/(.*)\\/commit.+$/\\1}.git", "revision": "${CF_REVISION}", @@ -55,6 +61,7 @@ }, "CodeShip": { "url": "${CI_BUILD_URL}", + "buildNumber": "${CI_BUILD_NUMBER}", "git": { "remote": "${CI_PULL_REQUEST/(.*)\\/pull\\/\\d+/\\1.git}", "revision": "${CI_COMMIT_ID}", @@ -64,6 +71,7 @@ }, "GitHub Actions": { "url": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}", + "buildNumber": "${GITHUB_RUN_ID}", "git": { "remote": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git", "revision": "${GITHUB_SHA}", @@ -73,6 +81,7 @@ }, "GitLab": { "url": "${CI_JOB_URL}", + "buildNumber": "${CI_JOB_ID}", "git": { "remote": "${CI_REPOSITORY_URL}", "revision": "${CI_COMMIT_SHA}", @@ -82,6 +91,7 @@ }, "GoCD": { "url": "${GO_SERVER_URL}/pipelines/${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}", + "buildNumber": "${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}", "git": { "remote": "${GO_SCM_*_PR_URL/(.*)\\/pull\\/\\d+/\\1.git}", "revision": "${GO_REVISION}", @@ -91,6 +101,7 @@ }, "Jenkins": { "url": "${BUILD_URL}", + "buildNumber": "${BUILD_NUMBER}", "git": { "remote": "${GIT_URL}", "revision": "${GIT_COMMIT}", @@ -100,6 +111,7 @@ }, "Semaphore": { "url": "${SEMAPHORE_ORGANIZATION_URL}/jobs/${SEMAPHORE_JOB_ID}", + "buildNumber": "${SEMAPHORE_JOB_ID}", "git": { "remote": "${SEMAPHORE_GIT_URL}", "revision": "${SEMAPHORE_GIT_SHA}", @@ -109,6 +121,7 @@ }, "Travis CI": { "url": "${TRAVIS_BUILD_WEB_URL}", + "buildNumber": "${TRAVIS_JOB_NUMBER}", "git": { "remote": "https://github.com/${TRAVIS_REPO_SLUG}.git", "revision": "${TRAVIS_COMMIT}", @@ -118,6 +131,7 @@ }, "Wercker": { "url": "${WERCKER_RUN_URL}", + "buildNumber": "${WERCKER_RUN_URL/.*\\/([^\\/]+)$/\\1}", "git": { "remote": "https://${WERCKER_GIT_DOMAIN}/${WERCKER_GIT_OWNER}/${WERCKER_GIT_REPOSITORY}.git", "revision": "${WERCKER_GIT_COMMIT}", diff --git a/create-meta/java/pom.xml b/create-meta/java/pom.xml index 5d880faa29..22b12ae91d 100644 --- a/create-meta/java/pom.xml +++ b/create-meta/java/pom.xml @@ -29,7 +29,7 @@ io.cucumber messages - [16.0.0,17.0.0) + 16.0.2-SNAPSHOT diff --git a/create-meta/java/src/main/java/io/cucumber/createmeta/CreateMeta.java b/create-meta/java/src/main/java/io/cucumber/createmeta/CreateMeta.java index bf88b16d05..9328e0a05a 100644 --- a/create-meta/java/src/main/java/io/cucumber/createmeta/CreateMeta.java +++ b/create-meta/java/src/main/java/io/cucumber/createmeta/CreateMeta.java @@ -71,6 +71,7 @@ static Ci detectCI(Map env) { private static Ci createCi(String name, JsonObject ci, Map env) { String url = evaluate(getString(ci, "url"), env); + String buildNumber = evaluate(getString(ci, "buildNumber"), env); if (url == null) return null; JsonObject git = ci.get("git").asObject(); String remote = removeUserInfoFromUrl(evaluate(getString(git, "remote"), env)); @@ -81,12 +82,16 @@ private static Ci createCi(String name, JsonObject ci, Map env) return new Ci( name, url, + buildNumber, new Git(remote, revision, branch, tag) ); } private static String getString(JsonObject json, String name) { JsonValue val = json.get(name); + if(val == null) { + throw new RuntimeException(String.format("Missing %s property in %s", name, json.toString())); + } return val.isNull() ? null : val.asString(); } } diff --git a/create-meta/java/src/main/resources/io/cucumber/createmeta/ciDict.json b/create-meta/java/src/main/resources/io/cucumber/createmeta/ciDict.json index 003702e865..4cf94ba4b5 100644 --- a/create-meta/java/src/main/resources/io/cucumber/createmeta/ciDict.json +++ b/create-meta/java/src/main/resources/io/cucumber/createmeta/ciDict.json @@ -1,6 +1,7 @@ { "Azure Pipelines": { "url": "${BUILD_BUILDURI}", + "buildNumber": "${BUILD_BUILDNUMBER}", "git": { "remote": "${BUILD_REPOSITORY_URI}", "revision": "${BUILD_SOURCEVERSION}", @@ -9,16 +10,18 @@ } }, "Bamboo": { - "url": "${bamboo.buildResultsUrl}", + "url": "${bamboo_buildResultsUrl}", + "buildNumber": "${bamboo_buildNumber}", "git": { - "remote": "${bamboo.planRepository.1.repositoryUrl}", - "revision": "${bamboo.planRepository.1.revision}", - "branch": "${bamboo.planRepository.1.branch}", + "remote": "${bamboo_planRepository_repositoryUrl}", + "revision": "${bamboo_planRepository_revision}", + "branch": "${bamboo_planRepository_branch}", "tag": null } }, "Buddy": { "url": "${BUDDY_EXECUTION_URL}", + "buildNumber": "${BUDDY_EXECUTION_ID}", "git": { "remote": "${BUDDY_SCM_URL}", "revision": "${BUDDY_EXECUTION_REVISION}", @@ -28,6 +31,7 @@ }, "Bitrise": { "url": "${BITRISE_BUILD_URL}", + "buildNumber": "${BITRISE_BUILD_NUMBER}", "git": { "remote": "${GIT_REPOSITORY_URL}", "revision": "${BITRISE_GIT_COMMIT}", @@ -37,6 +41,7 @@ }, "CircleCI": { "url": "${CIRCLE_BUILD_URL}", + "buildNumber": "${CIRCLE_BUILD_NUM}", "git": { "remote": "${CIRCLE_REPOSITORY_URL}", "revision": "${CIRCLE_SHA1}", @@ -46,6 +51,7 @@ }, "CodeFresh": { "url": "${CF_BUILD_URL}", + "buildNumber": "${CF_BUILD_ID}", "git": { "remote": "${CF_COMMIT_URL/(.*)\\/commit.+$/\\1}.git", "revision": "${CF_REVISION}", @@ -55,6 +61,7 @@ }, "CodeShip": { "url": "${CI_BUILD_URL}", + "buildNumber": "${CI_BUILD_NUMBER}", "git": { "remote": "${CI_PULL_REQUEST/(.*)\\/pull\\/\\d+/\\1.git}", "revision": "${CI_COMMIT_ID}", @@ -64,6 +71,7 @@ }, "GitHub Actions": { "url": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}", + "buildNumber": "${GITHUB_RUN_ID}", "git": { "remote": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git", "revision": "${GITHUB_SHA}", @@ -73,6 +81,7 @@ }, "GitLab": { "url": "${CI_JOB_URL}", + "buildNumber": "${CI_JOB_ID}", "git": { "remote": "${CI_REPOSITORY_URL}", "revision": "${CI_COMMIT_SHA}", @@ -82,6 +91,7 @@ }, "GoCD": { "url": "${GO_SERVER_URL}/pipelines/${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}", + "buildNumber": "${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}", "git": { "remote": "${GO_SCM_*_PR_URL/(.*)\\/pull\\/\\d+/\\1.git}", "revision": "${GO_REVISION}", @@ -91,6 +101,7 @@ }, "Jenkins": { "url": "${BUILD_URL}", + "buildNumber": "${BUILD_NUMBER}", "git": { "remote": "${GIT_URL}", "revision": "${GIT_COMMIT}", @@ -100,6 +111,7 @@ }, "Semaphore": { "url": "${SEMAPHORE_ORGANIZATION_URL}/jobs/${SEMAPHORE_JOB_ID}", + "buildNumber": "${SEMAPHORE_JOB_ID}", "git": { "remote": "${SEMAPHORE_GIT_URL}", "revision": "${SEMAPHORE_GIT_SHA}", @@ -109,6 +121,7 @@ }, "Travis CI": { "url": "${TRAVIS_BUILD_WEB_URL}", + "buildNumber": "${TRAVIS_JOB_NUMBER}", "git": { "remote": "https://github.com/${TRAVIS_REPO_SLUG}.git", "revision": "${TRAVIS_COMMIT}", @@ -118,6 +131,7 @@ }, "Wercker": { "url": "${WERCKER_RUN_URL}", + "buildNumber": "${WERCKER_RUN_URL/.*\\/([^\\/]+)$/\\1}", "git": { "remote": "https://${WERCKER_GIT_DOMAIN}/${WERCKER_GIT_OWNER}/${WERCKER_GIT_REPOSITORY}.git", "revision": "${WERCKER_GIT_COMMIT}", diff --git a/create-meta/java/src/test/java/io/cucumber/createmeta/CreateMetaTest.java b/create-meta/java/src/test/java/io/cucumber/createmeta/CreateMetaTest.java index 95c56d85d8..afe39d3980 100644 --- a/create-meta/java/src/test/java/io/cucumber/createmeta/CreateMetaTest.java +++ b/create-meta/java/src/test/java/io/cucumber/createmeta/CreateMetaTest.java @@ -49,11 +49,11 @@ void it_detects_github_actions() throws IOException { put("GITHUB_REF", "refs/tags/the-tag"); }}; Meta meta = createMeta("cucumber-jvm", "3.2.1", env); - System.out.println("JSON.toJSON(meta.getCi()) = " + JSON.toJSON(meta.getCi())); assertEquals(new Ci( "GitHub Actions", "https://github.company.com/cucumber/cucumber-ruby/actions/runs/140170388", + "140170388", new Git( "https://github.company.com/cucumber/cucumber-ruby.git", "the-revision", @@ -83,6 +83,7 @@ void it_detects_go_cd() throws IOException { assertEquals(new Ci( "GoCD", "https://mygocd.com/pipelines/my-pipeline/1234/my-stage/456", + "my-pipeline/1234/my-stage/456", new Git( "https://github.com/owner/repo.git", "the-revision", diff --git a/create-meta/javascript/src/ciDict.json b/create-meta/javascript/src/ciDict.json index 003702e865..4cf94ba4b5 100644 --- a/create-meta/javascript/src/ciDict.json +++ b/create-meta/javascript/src/ciDict.json @@ -1,6 +1,7 @@ { "Azure Pipelines": { "url": "${BUILD_BUILDURI}", + "buildNumber": "${BUILD_BUILDNUMBER}", "git": { "remote": "${BUILD_REPOSITORY_URI}", "revision": "${BUILD_SOURCEVERSION}", @@ -9,16 +10,18 @@ } }, "Bamboo": { - "url": "${bamboo.buildResultsUrl}", + "url": "${bamboo_buildResultsUrl}", + "buildNumber": "${bamboo_buildNumber}", "git": { - "remote": "${bamboo.planRepository.1.repositoryUrl}", - "revision": "${bamboo.planRepository.1.revision}", - "branch": "${bamboo.planRepository.1.branch}", + "remote": "${bamboo_planRepository_repositoryUrl}", + "revision": "${bamboo_planRepository_revision}", + "branch": "${bamboo_planRepository_branch}", "tag": null } }, "Buddy": { "url": "${BUDDY_EXECUTION_URL}", + "buildNumber": "${BUDDY_EXECUTION_ID}", "git": { "remote": "${BUDDY_SCM_URL}", "revision": "${BUDDY_EXECUTION_REVISION}", @@ -28,6 +31,7 @@ }, "Bitrise": { "url": "${BITRISE_BUILD_URL}", + "buildNumber": "${BITRISE_BUILD_NUMBER}", "git": { "remote": "${GIT_REPOSITORY_URL}", "revision": "${BITRISE_GIT_COMMIT}", @@ -37,6 +41,7 @@ }, "CircleCI": { "url": "${CIRCLE_BUILD_URL}", + "buildNumber": "${CIRCLE_BUILD_NUM}", "git": { "remote": "${CIRCLE_REPOSITORY_URL}", "revision": "${CIRCLE_SHA1}", @@ -46,6 +51,7 @@ }, "CodeFresh": { "url": "${CF_BUILD_URL}", + "buildNumber": "${CF_BUILD_ID}", "git": { "remote": "${CF_COMMIT_URL/(.*)\\/commit.+$/\\1}.git", "revision": "${CF_REVISION}", @@ -55,6 +61,7 @@ }, "CodeShip": { "url": "${CI_BUILD_URL}", + "buildNumber": "${CI_BUILD_NUMBER}", "git": { "remote": "${CI_PULL_REQUEST/(.*)\\/pull\\/\\d+/\\1.git}", "revision": "${CI_COMMIT_ID}", @@ -64,6 +71,7 @@ }, "GitHub Actions": { "url": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}", + "buildNumber": "${GITHUB_RUN_ID}", "git": { "remote": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git", "revision": "${GITHUB_SHA}", @@ -73,6 +81,7 @@ }, "GitLab": { "url": "${CI_JOB_URL}", + "buildNumber": "${CI_JOB_ID}", "git": { "remote": "${CI_REPOSITORY_URL}", "revision": "${CI_COMMIT_SHA}", @@ -82,6 +91,7 @@ }, "GoCD": { "url": "${GO_SERVER_URL}/pipelines/${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}", + "buildNumber": "${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}", "git": { "remote": "${GO_SCM_*_PR_URL/(.*)\\/pull\\/\\d+/\\1.git}", "revision": "${GO_REVISION}", @@ -91,6 +101,7 @@ }, "Jenkins": { "url": "${BUILD_URL}", + "buildNumber": "${BUILD_NUMBER}", "git": { "remote": "${GIT_URL}", "revision": "${GIT_COMMIT}", @@ -100,6 +111,7 @@ }, "Semaphore": { "url": "${SEMAPHORE_ORGANIZATION_URL}/jobs/${SEMAPHORE_JOB_ID}", + "buildNumber": "${SEMAPHORE_JOB_ID}", "git": { "remote": "${SEMAPHORE_GIT_URL}", "revision": "${SEMAPHORE_GIT_SHA}", @@ -109,6 +121,7 @@ }, "Travis CI": { "url": "${TRAVIS_BUILD_WEB_URL}", + "buildNumber": "${TRAVIS_JOB_NUMBER}", "git": { "remote": "https://github.com/${TRAVIS_REPO_SLUG}.git", "revision": "${TRAVIS_COMMIT}", @@ -118,6 +131,7 @@ }, "Wercker": { "url": "${WERCKER_RUN_URL}", + "buildNumber": "${WERCKER_RUN_URL/.*\\/([^\\/]+)$/\\1}", "git": { "remote": "https://${WERCKER_GIT_DOMAIN}/${WERCKER_GIT_OWNER}/${WERCKER_GIT_REPOSITORY}.git", "revision": "${WERCKER_GIT_COMMIT}", diff --git a/create-meta/javascript/src/createMeta.ts b/create-meta/javascript/src/createMeta.ts index bf34c75bd0..957cf4ffec 100644 --- a/create-meta/javascript/src/createMeta.ts +++ b/create-meta/javascript/src/createMeta.ts @@ -69,6 +69,7 @@ export function removeUserInfoFromUrl(value: string): string { function createCi(ciName: string, ciSystem: CiSystem, envDict: Env): messages.Ci | undefined { const url = evaluateVariableExpression(ciSystem.url, envDict) + const buildNumber = evaluateVariableExpression(ciSystem.buildNumber, envDict) if (url === undefined) { // The url is what consumers will use as the primary key for a build // If this cannot be determined, we return nothing. @@ -77,8 +78,9 @@ function createCi(ciName: string, ciSystem: CiSystem, envDict: Env): messages.Ci const branch = evaluateVariableExpression(ciSystem.git.branch, envDict) return { - url, name: ciName, + url, + buildNumber, git: { remote: removeUserInfoFromUrl(evaluateVariableExpression(ciSystem.git.remote, envDict)), revision: evaluateVariableExpression(ciSystem.git.revision, envDict), diff --git a/create-meta/javascript/src/types.ts b/create-meta/javascript/src/types.ts index cff285e0f2..0cfd52c9ba 100644 --- a/create-meta/javascript/src/types.ts +++ b/create-meta/javascript/src/types.ts @@ -1,5 +1,6 @@ export interface CiSystem { url: string + buildNumber: string git: { remote: string | undefined branch: string | undefined diff --git a/create-meta/javascript/test/createMetaTest.ts b/create-meta/javascript/test/createMetaTest.ts index 0984d36a58..94db39367e 100644 --- a/create-meta/javascript/test/createMetaTest.ts +++ b/create-meta/javascript/test/createMetaTest.ts @@ -18,12 +18,14 @@ describe('createMeta', () => { CIRCLE_BRANCH: 'the-branch', CIRCLE_SHA1: 'the-revision', CIRCLE_TAG: 'the-tag', + CIRCLE_BUILD_NUM: '234', } const meta = createMeta('someTool', '1.2.3', envDict, ciDict) const ci: messages.Ci = { name: 'CircleCI', url: 'the-url', + buildNumber: '234', git: { remote: 'the-remote', branch: 'the-branch', @@ -47,6 +49,7 @@ describe('createMeta', () => { const ci: messages.Ci = { name: 'GitHub Actions', url: 'https://github.com/cucumber/cucumber-ruby/actions/runs/140170388', + buildNumber: '140170388', git: { remote: 'https://github.com/cucumber/cucumber-ruby.git', branch: undefined, @@ -70,6 +73,7 @@ describe('createMeta', () => { const ci: messages.Ci = { name: 'GitHub Actions', url: 'https://github.company.com/cucumber/cucumber-ruby/actions/runs/140170388', + buildNumber: '140170388', git: { remote: 'https://github.company.com/cucumber/cucumber-ruby.git', branch: 'the-branch', @@ -86,12 +90,14 @@ describe('createMeta', () => { BUILD_REPOSITORY_URI: 'the-remote', BUILD_SOURCEBRANCH: 'refs/heads/main', BUILD_SOURCEVERSION: 'the-revision', + BUILD_BUILDNUMBER: '456', } const meta = createMeta('someTool', '1.2.3', envDict, ciDict) const ci: messages.Ci = { name: 'Azure Pipelines', url: 'the-url', + buildNumber: '456', git: { remote: 'the-remote', branch: 'main', @@ -108,12 +114,14 @@ describe('createMeta', () => { BUILD_REPOSITORY_URI: 'the-remote', BUILD_SOURCEBRANCH: 'refs/tags/v1.2.3', BUILD_SOURCEVERSION: 'the-revision', + BUILD_BUILDNUMBER: '456', } const meta = createMeta('someTool', '1.2.3', envDict, ciDict) const ci: messages.Ci = { name: 'Azure Pipelines', url: 'the-url', + buildNumber: '456', git: { remote: 'the-remote', branch: undefined, @@ -123,4 +131,29 @@ describe('createMeta', () => { } assert.deepStrictEqual(meta.ci, ci) }) + + it('extracts build number from url', () => { + const envDict = { + WERCKER_GIT_BRANCH: 'main', + WERCKER_GIT_COMMIT: '057f8fe233b17629af084064c2a7b8d1dbb795ad', + WERCKER_GIT_DOMAIN: 'github.com', + WERCKER_GIT_OWNER: 'cucumber-ltd', + WERCKER_GIT_REPOSITORY: 'shouty.rb', + WERCKER_RUN_URL: 'https://cihost.com/path/to/build/629af084064c2', + } + + const meta = createMeta('someTool', '1.2.3', envDict, ciDict) + const ci: messages.Ci = { + git: { + branch: 'main', + tag: undefined, + remote: 'https://github.com/cucumber-ltd/shouty.rb.git', + revision: '057f8fe233b17629af084064c2a7b8d1dbb795ad', + }, + name: 'Wercker', + url: 'https://cihost.com/path/to/build/629af084064c2', + buildNumber: '629af084064c2', + } + assert.deepStrictEqual(meta.ci, ci) + }) }) diff --git a/create-meta/ruby/lib/cucumber/ciDict.json b/create-meta/ruby/lib/cucumber/ciDict.json index 003702e865..4cf94ba4b5 100644 --- a/create-meta/ruby/lib/cucumber/ciDict.json +++ b/create-meta/ruby/lib/cucumber/ciDict.json @@ -1,6 +1,7 @@ { "Azure Pipelines": { "url": "${BUILD_BUILDURI}", + "buildNumber": "${BUILD_BUILDNUMBER}", "git": { "remote": "${BUILD_REPOSITORY_URI}", "revision": "${BUILD_SOURCEVERSION}", @@ -9,16 +10,18 @@ } }, "Bamboo": { - "url": "${bamboo.buildResultsUrl}", + "url": "${bamboo_buildResultsUrl}", + "buildNumber": "${bamboo_buildNumber}", "git": { - "remote": "${bamboo.planRepository.1.repositoryUrl}", - "revision": "${bamboo.planRepository.1.revision}", - "branch": "${bamboo.planRepository.1.branch}", + "remote": "${bamboo_planRepository_repositoryUrl}", + "revision": "${bamboo_planRepository_revision}", + "branch": "${bamboo_planRepository_branch}", "tag": null } }, "Buddy": { "url": "${BUDDY_EXECUTION_URL}", + "buildNumber": "${BUDDY_EXECUTION_ID}", "git": { "remote": "${BUDDY_SCM_URL}", "revision": "${BUDDY_EXECUTION_REVISION}", @@ -28,6 +31,7 @@ }, "Bitrise": { "url": "${BITRISE_BUILD_URL}", + "buildNumber": "${BITRISE_BUILD_NUMBER}", "git": { "remote": "${GIT_REPOSITORY_URL}", "revision": "${BITRISE_GIT_COMMIT}", @@ -37,6 +41,7 @@ }, "CircleCI": { "url": "${CIRCLE_BUILD_URL}", + "buildNumber": "${CIRCLE_BUILD_NUM}", "git": { "remote": "${CIRCLE_REPOSITORY_URL}", "revision": "${CIRCLE_SHA1}", @@ -46,6 +51,7 @@ }, "CodeFresh": { "url": "${CF_BUILD_URL}", + "buildNumber": "${CF_BUILD_ID}", "git": { "remote": "${CF_COMMIT_URL/(.*)\\/commit.+$/\\1}.git", "revision": "${CF_REVISION}", @@ -55,6 +61,7 @@ }, "CodeShip": { "url": "${CI_BUILD_URL}", + "buildNumber": "${CI_BUILD_NUMBER}", "git": { "remote": "${CI_PULL_REQUEST/(.*)\\/pull\\/\\d+/\\1.git}", "revision": "${CI_COMMIT_ID}", @@ -64,6 +71,7 @@ }, "GitHub Actions": { "url": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}", + "buildNumber": "${GITHUB_RUN_ID}", "git": { "remote": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git", "revision": "${GITHUB_SHA}", @@ -73,6 +81,7 @@ }, "GitLab": { "url": "${CI_JOB_URL}", + "buildNumber": "${CI_JOB_ID}", "git": { "remote": "${CI_REPOSITORY_URL}", "revision": "${CI_COMMIT_SHA}", @@ -82,6 +91,7 @@ }, "GoCD": { "url": "${GO_SERVER_URL}/pipelines/${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}", + "buildNumber": "${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}", "git": { "remote": "${GO_SCM_*_PR_URL/(.*)\\/pull\\/\\d+/\\1.git}", "revision": "${GO_REVISION}", @@ -91,6 +101,7 @@ }, "Jenkins": { "url": "${BUILD_URL}", + "buildNumber": "${BUILD_NUMBER}", "git": { "remote": "${GIT_URL}", "revision": "${GIT_COMMIT}", @@ -100,6 +111,7 @@ }, "Semaphore": { "url": "${SEMAPHORE_ORGANIZATION_URL}/jobs/${SEMAPHORE_JOB_ID}", + "buildNumber": "${SEMAPHORE_JOB_ID}", "git": { "remote": "${SEMAPHORE_GIT_URL}", "revision": "${SEMAPHORE_GIT_SHA}", @@ -109,6 +121,7 @@ }, "Travis CI": { "url": "${TRAVIS_BUILD_WEB_URL}", + "buildNumber": "${TRAVIS_JOB_NUMBER}", "git": { "remote": "https://github.com/${TRAVIS_REPO_SLUG}.git", "revision": "${TRAVIS_COMMIT}", @@ -118,6 +131,7 @@ }, "Wercker": { "url": "${WERCKER_RUN_URL}", + "buildNumber": "${WERCKER_RUN_URL/.*\\/([^\\/]+)$/\\1}", "git": { "remote": "https://${WERCKER_GIT_DOMAIN}/${WERCKER_GIT_OWNER}/${WERCKER_GIT_REPOSITORY}.git", "revision": "${WERCKER_GIT_COMMIT}", diff --git a/create-meta/ruby/lib/cucumber/create_meta.rb b/create-meta/ruby/lib/cucumber/create_meta.rb index 72f0d67091..c79236324a 100644 --- a/create-meta/ruby/lib/cucumber/create_meta.rb +++ b/create-meta/ruby/lib/cucumber/create_meta.rb @@ -46,6 +46,7 @@ def create_ci(ci_name, ci_system, env) { url: url, name: ci_name, + buildNumber: evaluate(ci_system['buildNumber'], env), git: { remote: remove_userinfo_from_url(evaluate(ci_system['git']['remote'], env)), revision: evaluate(ci_system['git']['revision'], env), diff --git a/create-meta/testdata/AzurePipelines.txt b/create-meta/testdata/AzurePipelines.txt index d9089a78b9..49af322f82 100644 --- a/create-meta/testdata/AzurePipelines.txt +++ b/create-meta/testdata/AzurePipelines.txt @@ -1,4 +1,5 @@ BUILD_BUILDURI=https://cihost.com/path/to/the/build +BUILD_BUILDNUMBER=1234 BUILD_REPOSITORY_URI=https://scmhost.com/path/to/the/project BUILD_SOURCEBRANCH=refs/heads/main BUILD_SOURCEVERSION=decafbad diff --git a/create-meta/testdata/AzurePipelines.txt.json b/create-meta/testdata/AzurePipelines.txt.json index 6e4a8c658a..40351045cc 100644 --- a/create-meta/testdata/AzurePipelines.txt.json +++ b/create-meta/testdata/AzurePipelines.txt.json @@ -5,5 +5,6 @@ "revision": "decafbad" }, "name": "Azure Pipelines", - "url": "https://cihost.com/path/to/the/build" + "url": "https://cihost.com/path/to/the/build", + "buildNumber": "1234" } diff --git a/create-meta/testdata/Bamboo.txt b/create-meta/testdata/Bamboo.txt index 6ff8e94de3..d4e1cb79af 100644 --- a/create-meta/testdata/Bamboo.txt +++ b/create-meta/testdata/Bamboo.txt @@ -1,4 +1,5 @@ -bamboo.buildResultsUrl=https://cihost.com/path/to/the/build -bamboo.planRepository.1.branch=main -bamboo.planRepository.1.repositoryUrl=https://github.com/cucumber-ltd/shouty.rb -bamboo.planRepository.1.revision=057f8fe233b17629af084064c2a7b8d1dbb795ad +bamboo_buildResultsUrl=https://cihost.com/path/to/the/build +bamboo_buildNumber=1234 +bamboo_planRepository_branch=main +bamboo_planRepository_repositoryUrl=https://github.com/cucumber-ltd/shouty.rb +bamboo_planRepository_revision=057f8fe233b17629af084064c2a7b8d1dbb795ad diff --git a/create-meta/testdata/Bamboo.txt.json b/create-meta/testdata/Bamboo.txt.json index b597d58e2a..384e829436 100644 --- a/create-meta/testdata/Bamboo.txt.json +++ b/create-meta/testdata/Bamboo.txt.json @@ -5,5 +5,6 @@ "revision": "057f8fe233b17629af084064c2a7b8d1dbb795ad" }, "name": "Bamboo", - "url": "https://cihost.com/path/to/the/build" + "url": "https://cihost.com/path/to/the/build", + "buildNumber": "1234" } diff --git a/create-meta/testdata/Bitrise.txt b/create-meta/testdata/Bitrise.txt index 6402236df4..afd7d3c314 100644 --- a/create-meta/testdata/Bitrise.txt +++ b/create-meta/testdata/Bitrise.txt @@ -1,4 +1,5 @@ BITRISE_BUILD_URL=https://cihost.com/path/to/the/build +BITRISE_BUILD_NUMBER=1234 GIT_REPOSITORY_URL=https://scmhost.com/path/to/the/project BITRISE_GIT_BRANCH=main BITRISE_GIT_COMMIT=decafbad diff --git a/create-meta/testdata/Bitrise.txt.json b/create-meta/testdata/Bitrise.txt.json index ef9aa9a520..00615e3b67 100644 --- a/create-meta/testdata/Bitrise.txt.json +++ b/create-meta/testdata/Bitrise.txt.json @@ -6,5 +6,6 @@ "revision": "decafbad" }, "name": "Bitrise", - "url": "https://cihost.com/path/to/the/build" + "url": "https://cihost.com/path/to/the/build", + "buildNumber": "1234" } diff --git a/create-meta/testdata/Buddy.txt b/create-meta/testdata/Buddy.txt index d99b54b785..6bd313ddc1 100644 --- a/create-meta/testdata/Buddy.txt +++ b/create-meta/testdata/Buddy.txt @@ -2,4 +2,5 @@ BUDDY_EXECUTION_BRANCH=main BUDDY_EXECUTION_REVISION=057f8fe233b17629af084064c2a7b8d1dbb795ad BUDDY_EXECUTION_TAG=v1.2.3 BUDDY_EXECUTION_URL=https://cihost.com/path/to/the/build +BUDDY_EXECUTION_ID=1234 BUDDY_SCM_URL=https://github.com/cucumber-ltd/shouty.rb diff --git a/create-meta/testdata/Buddy.txt.json b/create-meta/testdata/Buddy.txt.json index 5d50694115..414b48e6e7 100644 --- a/create-meta/testdata/Buddy.txt.json +++ b/create-meta/testdata/Buddy.txt.json @@ -6,5 +6,6 @@ "revision": "057f8fe233b17629af084064c2a7b8d1dbb795ad" }, "name": "Buddy", - "url": "https://cihost.com/path/to/the/build" + "url": "https://cihost.com/path/to/the/build", + "buildNumber": "1234" } diff --git a/create-meta/testdata/CircleCI.txt b/create-meta/testdata/CircleCI.txt index dfee904155..7370cab443 100644 --- a/create-meta/testdata/CircleCI.txt +++ b/create-meta/testdata/CircleCI.txt @@ -3,3 +3,4 @@ CIRCLE_BUILD_URL=https://cihost.com/path/to/the/build CIRCLE_REPOSITORY_URL=https://github.com/cucumber-ltd/shouty.rb CIRCLE_SHA1=057f8fe233b17629af084064c2a7b8d1dbb795ad CIRCLE_TAG=v1.2.3 +CIRCLE_BUILD_NUM=1234 diff --git a/create-meta/testdata/CircleCI.txt.json b/create-meta/testdata/CircleCI.txt.json index 4afb10b9e7..a1c98b408f 100644 --- a/create-meta/testdata/CircleCI.txt.json +++ b/create-meta/testdata/CircleCI.txt.json @@ -6,5 +6,6 @@ "revision": "057f8fe233b17629af084064c2a7b8d1dbb795ad" }, "name": "CircleCI", - "url": "https://cihost.com/path/to/the/build" + "url": "https://cihost.com/path/to/the/build", + "buildNumber": "1234" } diff --git a/create-meta/testdata/CodeFresh.txt b/create-meta/testdata/CodeFresh.txt index 33a7f5d0cc..4ec675b70e 100644 --- a/create-meta/testdata/CodeFresh.txt +++ b/create-meta/testdata/CodeFresh.txt @@ -2,3 +2,4 @@ CF_BRANCH=main CF_BUILD_URL=https://cihost.com/path/to/the/build CF_COMMIT_URL=https://github.com/cucumber-ltd/shouty.rb/commit/057f8fe233b17629af084064c2a7b8d1dbb795ad CF_REVISION=057f8fe233b17629af084064c2a7b8d1dbb795ad +CF_BUILD_ID=1234 diff --git a/create-meta/testdata/CodeFresh.txt.json b/create-meta/testdata/CodeFresh.txt.json index 06f0b2b3d0..c264db2a87 100644 --- a/create-meta/testdata/CodeFresh.txt.json +++ b/create-meta/testdata/CodeFresh.txt.json @@ -5,5 +5,6 @@ "revision": "057f8fe233b17629af084064c2a7b8d1dbb795ad" }, "name": "CodeFresh", - "url": "https://cihost.com/path/to/the/build" + "url": "https://cihost.com/path/to/the/build", + "buildNumber": "1234" } diff --git a/create-meta/testdata/CodeShip.txt b/create-meta/testdata/CodeShip.txt index 891f2d265e..d7fa9a30a2 100644 --- a/create-meta/testdata/CodeShip.txt +++ b/create-meta/testdata/CodeShip.txt @@ -2,3 +2,4 @@ CI_BUILD_URL=https://cihost.com/path/to/the/build CI_PULL_REQUEST=https://github.com/owner/repo/pull/42 CI_BRANCH=main CI_COMMIT_ID=decafbad +CI_BUILD_NUMBER=1234 diff --git a/create-meta/testdata/CodeShip.txt.json b/create-meta/testdata/CodeShip.txt.json index 03be3da793..006fb88f51 100644 --- a/create-meta/testdata/CodeShip.txt.json +++ b/create-meta/testdata/CodeShip.txt.json @@ -5,5 +5,6 @@ "revision": "decafbad" }, "name": "CodeShip", - "url": "https://cihost.com/path/to/the/build" + "url": "https://cihost.com/path/to/the/build", + "buildNumber": "1234" } diff --git a/create-meta/testdata/GitHubActions.txt.json b/create-meta/testdata/GitHubActions.txt.json index e530f91825..68b0126335 100644 --- a/create-meta/testdata/GitHubActions.txt.json +++ b/create-meta/testdata/GitHubActions.txt.json @@ -5,5 +5,6 @@ "branch": "master" }, "name": "GitHub Actions", - "url": "https://github.com/cucumber-ltd/shouty.rb/actions/runs/154666429" + "url": "https://github.com/cucumber-ltd/shouty.rb/actions/runs/154666429", + "buildNumber": "154666429" } diff --git a/create-meta/testdata/GitLab.txt b/create-meta/testdata/GitLab.txt index 086a1f12a1..9190466270 100644 --- a/create-meta/testdata/GitLab.txt +++ b/create-meta/testdata/GitLab.txt @@ -2,3 +2,4 @@ CI_JOB_URL=https://gitlab.com/cucumber/cucumber/jobs/713869896 CI_REPOSITORY_URL=https://cukebot:thisIsAVerySensitiveInformation@gitlab.com/cucumber/cucumber.git CI_COMMIT_SHA=123456789 CI_COMMIT_BRANCH=main +CI_JOB_ID=713869896 diff --git a/create-meta/testdata/Gitlab.txt.json b/create-meta/testdata/Gitlab.txt.json index 81549e4258..535634997e 100644 --- a/create-meta/testdata/Gitlab.txt.json +++ b/create-meta/testdata/Gitlab.txt.json @@ -5,5 +5,6 @@ "branch": "main" }, "name": "GitLab", - "url": "https://gitlab.com/cucumber/cucumber/jobs/713869896" + "url": "https://gitlab.com/cucumber/cucumber/jobs/713869896", + "buildNumber": "713869896" } diff --git a/create-meta/testdata/GoCD.txt.json b/create-meta/testdata/GoCD.txt.json index ef77e6f84a..e3dfb83a14 100644 --- a/create-meta/testdata/GoCD.txt.json +++ b/create-meta/testdata/GoCD.txt.json @@ -5,5 +5,6 @@ "revision": "decafbad" }, "name": "GoCD", - "url": "https://cihost.com/pipelines/my-pipeline-name/1234/my-stage-name/456" + "url": "https://cihost.com/pipelines/my-pipeline-name/1234/my-stage-name/456", + "buildNumber": "my-pipeline-name/1234/my-stage-name/456" } diff --git a/create-meta/testdata/Jenkins.txt b/create-meta/testdata/Jenkins.txt index ef0eae9483..90ea9bd45b 100644 --- a/create-meta/testdata/Jenkins.txt +++ b/create-meta/testdata/Jenkins.txt @@ -2,3 +2,4 @@ BUILD_URL=https://cihost.com/path/to/the/build GIT_URL=https://scmhost.com/path/to/the/project GIT_LOCAL_BRANCH=main GIT_COMMIT=decafbad +BUILD_NUMBER=1234 diff --git a/create-meta/testdata/Jenkins.txt.json b/create-meta/testdata/Jenkins.txt.json index fdc713f7ba..39faae6478 100644 --- a/create-meta/testdata/Jenkins.txt.json +++ b/create-meta/testdata/Jenkins.txt.json @@ -5,5 +5,6 @@ "revision": "decafbad" }, "name": "Jenkins", - "url": "https://cihost.com/path/to/the/build" + "url": "https://cihost.com/path/to/the/build", + "buildNumber": "1234" } diff --git a/create-meta/testdata/Semaphore.txt b/create-meta/testdata/Semaphore.txt index 96c2f65362..99f595a544 100644 --- a/create-meta/testdata/Semaphore.txt +++ b/create-meta/testdata/Semaphore.txt @@ -2,5 +2,5 @@ SEMAPHORE_GIT_BRANCH=main SEMAPHORE_GIT_SHA=decafbad SEMAPHORE_GIT_TAG_NAME=v1.0 SEMAPHORE_GIT_URL=https://scmhost.com/path/to/the/project -SEMAPHORE_JOB_ID=job-123 +SEMAPHORE_JOB_ID=a26d42cf-89ac-4c3f-9e2d-51bb231897bf SEMAPHORE_ORGANIZATION_URL=https://my.semaphore.com diff --git a/create-meta/testdata/Semaphore.txt.json b/create-meta/testdata/Semaphore.txt.json index 45331a4500..edad366a5b 100644 --- a/create-meta/testdata/Semaphore.txt.json +++ b/create-meta/testdata/Semaphore.txt.json @@ -6,5 +6,6 @@ "tag": "v1.0" }, "name": "Semaphore", - "url": "https://my.semaphore.com/jobs/job-123" + "url": "https://my.semaphore.com/jobs/a26d42cf-89ac-4c3f-9e2d-51bb231897bf", + "buildNumber": "a26d42cf-89ac-4c3f-9e2d-51bb231897bf" } diff --git a/create-meta/testdata/TravisCI.txt b/create-meta/testdata/TravisCI.txt index ae87554ec9..b1fe7ddefa 100644 --- a/create-meta/testdata/TravisCI.txt +++ b/create-meta/testdata/TravisCI.txt @@ -3,3 +3,4 @@ TRAVIS_BUILD_WEB_URL=https://cihost.com/path/to/the/build TRAVIS_COMMIT=057f8fe233b17629af084064c2a7b8d1dbb795ad TRAVIS_REPO_SLUG=cucumber-ltd/shouty.rb TRAVIS_TAG=v1.2.3 +TRAVIS_JOB_NUMBER=4.1 diff --git a/create-meta/testdata/TravisCI.txt.json b/create-meta/testdata/TravisCI.txt.json index 8f0f03796e..9daf09dc62 100644 --- a/create-meta/testdata/TravisCI.txt.json +++ b/create-meta/testdata/TravisCI.txt.json @@ -6,5 +6,6 @@ "revision": "057f8fe233b17629af084064c2a7b8d1dbb795ad" }, "name": "Travis CI", - "url": "https://cihost.com/path/to/the/build" + "url": "https://cihost.com/path/to/the/build", + "buildNumber": "4.1" } diff --git a/create-meta/testdata/Wercker.txt b/create-meta/testdata/Wercker.txt index e89ec82409..df9097fd27 100644 --- a/create-meta/testdata/Wercker.txt +++ b/create-meta/testdata/Wercker.txt @@ -3,4 +3,4 @@ WERCKER_GIT_COMMIT=057f8fe233b17629af084064c2a7b8d1dbb795ad WERCKER_GIT_DOMAIN=github.com WERCKER_GIT_OWNER=cucumber-ltd WERCKER_GIT_REPOSITORY=shouty.rb -WERCKER_RUN_URL=https://cihost.com/path/to/the/build +WERCKER_RUN_URL=https://cihost.com/path/to/build/629af084064c2 diff --git a/create-meta/testdata/Wercker.txt.json b/create-meta/testdata/Wercker.txt.json index 1b3c90bf03..00b5017714 100644 --- a/create-meta/testdata/Wercker.txt.json +++ b/create-meta/testdata/Wercker.txt.json @@ -5,5 +5,6 @@ "revision": "057f8fe233b17629af084064c2a7b8d1dbb795ad" }, "name": "Wercker", - "url": "https://cihost.com/path/to/the/build" + "url": "https://cihost.com/path/to/build/629af084064c2", + "buildNumber": "629af084064c2" } From 16770b61d46f229d30215f132695cc12b13bc34d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Thu, 24 Jun 2021 22:07:44 +0100 Subject: [PATCH 4/5] Fix bad casing in file --- .../java/src/main/java/io/cucumber/createmeta/CreateMeta.java | 2 +- create-meta/testdata/{Gitlab.txt.json => GitLab.txt.json} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename create-meta/testdata/{Gitlab.txt.json => GitLab.txt.json} (100%) diff --git a/create-meta/java/src/main/java/io/cucumber/createmeta/CreateMeta.java b/create-meta/java/src/main/java/io/cucumber/createmeta/CreateMeta.java index 9328e0a05a..bbcb6836fe 100644 --- a/create-meta/java/src/main/java/io/cucumber/createmeta/CreateMeta.java +++ b/create-meta/java/src/main/java/io/cucumber/createmeta/CreateMeta.java @@ -71,9 +71,9 @@ static Ci detectCI(Map env) { private static Ci createCi(String name, JsonObject ci, Map env) { String url = evaluate(getString(ci, "url"), env); - String buildNumber = evaluate(getString(ci, "buildNumber"), env); if (url == null) return null; JsonObject git = ci.get("git").asObject(); + String buildNumber = evaluate(getString(ci, "buildNumber"), env); String remote = removeUserInfoFromUrl(evaluate(getString(git, "remote"), env)); String revision = evaluate(getString(git, "revision"), env); String branch = evaluate(getString(git, "branch"), env); diff --git a/create-meta/testdata/Gitlab.txt.json b/create-meta/testdata/GitLab.txt.json similarity index 100% rename from create-meta/testdata/Gitlab.txt.json rename to create-meta/testdata/GitLab.txt.json From bfaf15828f02b1fd23d4554e7cf92734d7aa13ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Fri, 25 Jun 2021 09:32:53 +0100 Subject: [PATCH 5/5] Update changelogs --- create-meta/CHANGELOG.md | 9 +++++++++ messages/CHANGELOG.md | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/create-meta/CHANGELOG.md b/create-meta/CHANGELOG.md index abfa48b8d3..ee42a3a5c3 100644 --- a/create-meta/CHANGELOG.md +++ b/create-meta/CHANGELOG.md @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added +* Detect and populate `Ci#buildNumber` for all supported CI servers. + ([#1632](https://github.com/cucumber/common/pull/1632) + [#1606](https://github.com/cucumber/common/issues/1606) + [aslakhellesoy]) + ### Changed ### Deprecated @@ -19,6 +24,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +* Improve detection of Bamboo environment variables +* Improve detection of Azure environment variables +* Fix `Git#remote` for CodeFresh + ## [5.0.0] - 2021-05-17 ### Added diff --git a/messages/CHANGELOG.md b/messages/CHANGELOG.md index ee074934c1..67edbf58c8 100644 --- a/messages/CHANGELOG.md +++ b/messages/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added +* Added `Ci#buildNumber` field + ([#1632](https://github.com/cucumber/common/pull/1632) + [#1606](https://github.com/cucumber/common/issues/1606) + [aslakhellesoy]) * [Ruby] Generate DTOs from the json schemas to avoid usage of plain ruby hashes ([#1574](https://github.com/cucumber/common/issues/1574))