From 6167aa8e3138079de445d562f92511ca2bacc3b6 Mon Sep 17 00:00:00 2001 From: "Christian A. Jacobsen" Date: Thu, 6 Jun 2019 08:48:54 +0200 Subject: [PATCH] Updates Semaphore CI Service for 2.0 (#132) * Updates Semaphore CI Service for 2.0 Semaphore launched their 2.0 on November 6th 2018. The current Semaphore Service is using environment variables no longer present with Semaphore 2.0. I've purposefully removed the `build` and `slug` tags from the generated config as there is no good equivalent with Semaphore 2.0 anymore. List of 'git env vars' can be found at https://docs.semaphoreci.com/article/12-environment-variables * Adds the build tag back As requested, the `build` tag has been added back to the config and will now be read from the `SEMAPHORE_WORKFLOW_ID` as it's unique per 'run through the CI pipeline'. --- lib/services/semaphore.js | 10 +++------- test/services/semaphore.test.js | 15 ++++++--------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/lib/services/semaphore.js b/lib/services/semaphore.js index 7ab48a05..9a91bfa3 100644 --- a/lib/services/semaphore.js +++ b/lib/services/semaphore.js @@ -7,13 +7,9 @@ module.exports = { console.log(' Semaphore CI Detected') return { service: 'semaphore', - build: - process.env.SEMAPHORE_BUILD_NUMBER + - '.' + - process.env.SEMAPHORE_CURRENT_THREAD, - commit: process.env.REVISION, - branch: process.env.BRANCH_NAME, - slug: process.env.SEMAPHORE_REPO_SLUG, + branch: process.env.SEMAPHORE_GIT_BRANCH, + build: process.env.SEMAPHORE_WORKFLOW_ID, + commit: process.env.SEMAPHORE_GIT_SHA, } }, } diff --git a/test/services/semaphore.test.js b/test/services/semaphore.test.js index ef322ba0..1f9db03c 100644 --- a/test/services/semaphore.test.js +++ b/test/services/semaphore.test.js @@ -7,17 +7,14 @@ describe('Semaphore CI Provider', function() { }) it('can get semaphore env info', function() { - process.env.SEMAPHORE_BUILD_NUMBER = '1234' - process.env.REVISION = '5678' - process.env.SEMAPHORE_CURRENT_THREAD = '1' - process.env.BRANCH_NAME = 'master' - process.env.SEMAPHORE_REPO_SLUG = 'owner/repo' + process.env.SEMAPHORE_GIT_BRANCH = 'development' + process.env.SEMAPHORE_GIT_SHA = '5c84719708b9b649b9ef3b56af214f38cee6acde' + process.env.SEMAPHORE_WORKFLOW_ID = '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf' expect(semaphore.configuration()).toEqual({ service: 'semaphore', - commit: '5678', - build: '1234.1', - branch: 'master', - slug: 'owner/repo', + branch: 'development', + build: '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf', + commit: '5c84719708b9b649b9ef3b56af214f38cee6acde', }) }) })