Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Updates Semaphore CI Service for 2.0 (#132)
Browse files Browse the repository at this point in the history
* 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'.
  • Loading branch information
ChristianJacobsen authored and eddiemoore committed Jun 6, 2019
1 parent e98d176 commit 6167aa8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
10 changes: 3 additions & 7 deletions lib/services/semaphore.js
Expand Up @@ -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,
}
},
}
15 changes: 6 additions & 9 deletions test/services/semaphore.test.js
Expand Up @@ -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',
})
})
})

0 comments on commit 6167aa8

Please sign in to comment.