Skip to content

Commit

Permalink
feat(jetbrainsSpace): add jetbrains space support (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
123FLO321 authored Jul 8, 2022
1 parent a24a275 commit 5bad207
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ if (isCI) {
| [Vela](https://go-vela.github.io/docs/reference/environment/variables/) | `vela` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| [Vercel](https://vercel.com/docs/environment-variables) | `vercel` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: | :x: |
| [Wercker](http://devcenter.wercker.com/docs/environment-variables/available-env-vars#hs_cos_wrapper_name) | `wercker` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: |
| [JetBrains Space](https://www.jetbrains.com/space/) | `jetbrainsSpace` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: | :x: |

:warning: See [Caveats](#caveats)

Expand Down
20 changes: 20 additions & 0 deletions services/jetbrains-space.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// https://jetbrains.com/help/space/automation-environment-variables.html#automation
const {parseBranch} = require('../lib/utils.js');

module.exports = {
detect({env}) {
return Boolean(env.JB_SPACE_EXECUTION_NUMBER);
},
configuration({env}) {
const projectKey = env.JB_SPACE_PROJECT_KEY?.toLowerCase();
const repositoryName = env.JB_SPACE_GIT_REPOSITORY_NAME;
return {
name: 'JetBrains Space',
service: 'jetbrainsSpace',
commit: env.JB_SPACE_GIT_REVISION,
build: env.JB_SPACE_EXECUTION_NUMBER,
branch: parseBranch(env.JB_SPACE_GIT_BRANCH),
slug: projectKey && repositoryName ? `${projectKey}/${repositoryName}` : undefined,
};
},
};
22 changes: 22 additions & 0 deletions test/services/jetbrains-space.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const test = require('ava');
const jetbrainsSpace = require('../../services/jetbrains-space.js');

const env = {
JB_SPACE_PROJECT_ID: '1',
JB_SPACE_PROJECT_KEY: 'TEST-PROJECT',
JB_SPACE_EXECUTION_NUMBER: '123',
JB_SPACE_GIT_REVISION: '12345',
JB_SPACE_GIT_BRANCH: 'refs/heads/some_branch',
JB_SPACE_GIT_REPOSITORY_NAME: 'test-repository',
};

test('Push', (t) => {
t.deepEqual(jetbrainsSpace.configuration({env}), {
name: 'JetBrains Space',
service: 'jetbrainsSpace',
commit: '12345',
build: '123',
branch: 'some_branch',
slug: 'test-project/test-repository',
});
});

0 comments on commit 5bad207

Please sign in to comment.