@invarn/cibuild 1.3.16 → 1.3.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +1 -1
- package/dist/src/cli.d.ts +3 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +987 -0
- package/dist/src/commands/android-scanner.d.ts +32 -0
- package/dist/src/commands/android-scanner.d.ts.map +1 -0
- package/dist/src/commands/android-scanner.js +667 -0
- package/dist/src/commands/build.d.ts +5 -0
- package/dist/src/commands/build.d.ts.map +1 -0
- package/dist/src/commands/build.js +1096 -0
- package/dist/src/commands/edit.d.ts +3 -0
- package/dist/src/commands/edit.d.ts.map +1 -0
- package/dist/src/commands/edit.js +651 -0
- package/dist/src/commands/file-secret-collector.d.ts +37 -0
- package/dist/src/commands/file-secret-collector.d.ts.map +1 -0
- package/dist/src/commands/file-secret-collector.js +199 -0
- package/dist/src/commands/github-workflow.d.ts +5 -0
- package/dist/src/commands/github-workflow.d.ts.map +1 -0
- package/dist/src/commands/github-workflow.js +45 -0
- package/dist/src/commands/ios-scanner.d.ts +27 -0
- package/dist/src/commands/ios-scanner.d.ts.map +1 -0
- package/dist/src/commands/ios-scanner.js +337 -0
- package/dist/src/commands/reset.d.ts +7 -0
- package/dist/src/commands/reset.d.ts.map +1 -0
- package/dist/src/commands/reset.js +81 -0
- package/dist/src/commands/secrets-sync-workflow.d.ts +15 -0
- package/dist/src/commands/secrets-sync-workflow.d.ts.map +1 -0
- package/dist/src/commands/secrets-sync-workflow.js +255 -0
- package/dist/src/commands/secrets-upload.d.ts +21 -0
- package/dist/src/commands/secrets-upload.d.ts.map +1 -0
- package/dist/src/commands/secrets-upload.js +177 -0
- package/dist/src/commands/secrets-upload.test.d.ts +5 -0
- package/dist/src/commands/secrets-upload.test.d.ts.map +1 -0
- package/dist/src/commands/secrets-upload.test.js +60 -0
- package/dist/src/config.d.ts +3 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +46 -0
- package/dist/src/envman/cli.d.ts +21 -0
- package/dist/src/envman/cli.d.ts.map +1 -0
- package/dist/src/envman/cli.js +240 -0
- package/dist/src/envman/envman.d.ts +83 -0
- package/dist/src/envman/envman.d.ts.map +1 -0
- package/dist/src/envman/envman.js +361 -0
- package/dist/src/envman/envman.test.d.ts +5 -0
- package/dist/src/envman/envman.test.d.ts.map +1 -0
- package/dist/src/envman/envman.test.js +236 -0
- package/dist/src/envman/index.d.ts +23 -0
- package/dist/src/envman/index.d.ts.map +1 -0
- package/dist/src/envman/index.js +23 -0
- package/dist/src/envman/types.d.ts +55 -0
- package/dist/src/envman/types.d.ts.map +1 -0
- package/dist/src/envman/types.js +12 -0
- package/dist/src/lib.d.ts +27 -0
- package/dist/src/lib.d.ts.map +1 -0
- package/dist/src/lib.js +32 -0
- package/dist/src/pipeline.d.ts +3 -0
- package/dist/src/pipeline.d.ts.map +1 -0
- package/dist/src/pipeline.js +57 -0
- package/dist/src/runner.d.ts +17 -0
- package/dist/src/runner.d.ts.map +1 -0
- package/dist/src/runner.js +234 -0
- package/dist/src/types.d.ts +57 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/yaml/bitrise-compat.d.ts +65 -0
- package/dist/src/yaml/bitrise-compat.d.ts.map +1 -0
- package/dist/src/yaml/bitrise-compat.js +206 -0
- package/dist/src/yaml/bitrise-compat.test.d.ts +5 -0
- package/dist/src/yaml/bitrise-compat.test.d.ts.map +1 -0
- package/dist/src/yaml/bitrise-compat.test.js +347 -0
- package/dist/src/yaml/converter.d.ts +33 -0
- package/dist/src/yaml/converter.d.ts.map +1 -0
- package/dist/src/yaml/converter.js +222 -0
- package/dist/src/yaml/converter.test.d.ts +5 -0
- package/dist/src/yaml/converter.test.d.ts.map +1 -0
- package/dist/src/yaml/converter.test.js +348 -0
- package/dist/src/yaml/e2e.test.d.ts +6 -0
- package/dist/src/yaml/e2e.test.d.ts.map +1 -0
- package/dist/src/yaml/e2e.test.js +446 -0
- package/dist/src/yaml/env-resolver.d.ts +120 -0
- package/dist/src/yaml/env-resolver.d.ts.map +1 -0
- package/dist/src/yaml/env-resolver.js +405 -0
- package/dist/src/yaml/env-resolver.test.d.ts +5 -0
- package/dist/src/yaml/env-resolver.test.d.ts.map +1 -0
- package/dist/src/yaml/env-resolver.test.js +502 -0
- package/dist/src/yaml/interactive-prompts.d.ts +71 -0
- package/dist/src/yaml/interactive-prompts.d.ts.map +1 -0
- package/dist/src/yaml/interactive-prompts.js +258 -0
- package/dist/src/yaml/missing-env-handler.d.ts +45 -0
- package/dist/src/yaml/missing-env-handler.d.ts.map +1 -0
- package/dist/src/yaml/missing-env-handler.js +64 -0
- package/dist/src/yaml/parser.d.ts +33 -0
- package/dist/src/yaml/parser.d.ts.map +1 -0
- package/dist/src/yaml/parser.js +145 -0
- package/dist/src/yaml/pipeline-with-secrets.d.ts +25 -0
- package/dist/src/yaml/pipeline-with-secrets.d.ts.map +1 -0
- package/dist/src/yaml/pipeline-with-secrets.js +76 -0
- package/dist/src/yaml/platform-detector.d.ts +83 -0
- package/dist/src/yaml/platform-detector.d.ts.map +1 -0
- package/dist/src/yaml/platform-detector.js +188 -0
- package/dist/src/yaml/platform-detector.test.d.ts +5 -0
- package/dist/src/yaml/platform-detector.test.d.ts.map +1 -0
- package/dist/src/yaml/platform-detector.test.js +414 -0
- package/dist/src/yaml/preflight-validation.d.ts +40 -0
- package/dist/src/yaml/preflight-validation.d.ts.map +1 -0
- package/dist/src/yaml/preflight-validation.js +152 -0
- package/dist/src/yaml/secrets-manager.d.ts +77 -0
- package/dist/src/yaml/secrets-manager.d.ts.map +1 -0
- package/dist/src/yaml/secrets-manager.js +219 -0
- package/dist/src/yaml/step-validator.d.ts +54 -0
- package/dist/src/yaml/step-validator.d.ts.map +1 -0
- package/dist/src/yaml/step-validator.js +403 -0
- package/dist/src/yaml/steps/android-sign.d.ts +35 -0
- package/dist/src/yaml/steps/android-sign.d.ts.map +1 -0
- package/dist/src/yaml/steps/android-sign.js +147 -0
- package/dist/src/yaml/steps/android-version.d.ts +26 -0
- package/dist/src/yaml/steps/android-version.d.ts.map +1 -0
- package/dist/src/yaml/steps/android-version.js +128 -0
- package/dist/src/yaml/steps/android-version.test.d.ts +5 -0
- package/dist/src/yaml/steps/android-version.test.d.ts.map +1 -0
- package/dist/src/yaml/steps/android-version.test.js +196 -0
- package/dist/src/yaml/steps/android.d.ts +95 -0
- package/dist/src/yaml/steps/android.d.ts.map +1 -0
- package/dist/src/yaml/steps/android.js +916 -0
- package/dist/src/yaml/steps/app-store-deploy.d.ts +48 -0
- package/dist/src/yaml/steps/app-store-deploy.d.ts.map +1 -0
- package/dist/src/yaml/steps/app-store-deploy.js +162 -0
- package/dist/src/yaml/steps/base.d.ts +238 -0
- package/dist/src/yaml/steps/base.d.ts.map +1 -0
- package/dist/src/yaml/steps/base.js +345 -0
- package/dist/src/yaml/steps/bitrise-android-tools.d.ts +26 -0
- package/dist/src/yaml/steps/bitrise-android-tools.d.ts.map +1 -0
- package/dist/src/yaml/steps/bitrise-android-tools.js +198 -0
- package/dist/src/yaml/steps/bitrise-android-tools.test.d.ts +5 -0
- package/dist/src/yaml/steps/bitrise-android-tools.test.d.ts.map +1 -0
- package/dist/src/yaml/steps/bitrise-android-tools.test.js +280 -0
- package/dist/src/yaml/steps/bitrise-apk-info.d.ts +22 -0
- package/dist/src/yaml/steps/bitrise-apk-info.d.ts.map +1 -0
- package/dist/src/yaml/steps/bitrise-apk-info.js +144 -0
- package/dist/src/yaml/steps/bitrise-apk-info.test.d.ts +5 -0
- package/dist/src/yaml/steps/bitrise-apk-info.test.d.ts.map +1 -0
- package/dist/src/yaml/steps/bitrise-apk-info.test.js +331 -0
- package/dist/src/yaml/steps/bitrise-slack.d.ts +49 -0
- package/dist/src/yaml/steps/bitrise-slack.d.ts.map +1 -0
- package/dist/src/yaml/steps/bitrise-slack.js +280 -0
- package/dist/src/yaml/steps/bitrise-slack.test.d.ts +5 -0
- package/dist/src/yaml/steps/bitrise-slack.test.d.ts.map +1 -0
- package/dist/src/yaml/steps/bitrise-slack.test.js +484 -0
- package/dist/src/yaml/steps/bitrise-ssh.d.ts +27 -0
- package/dist/src/yaml/steps/bitrise-ssh.d.ts.map +1 -0
- package/dist/src/yaml/steps/bitrise-ssh.js +134 -0
- package/dist/src/yaml/steps/bitrise-ssh.test.d.ts +5 -0
- package/dist/src/yaml/steps/bitrise-ssh.test.d.ts.map +1 -0
- package/dist/src/yaml/steps/bitrise-ssh.test.js +205 -0
- package/dist/src/yaml/steps/cache.d.ts +52 -0
- package/dist/src/yaml/steps/cache.d.ts.map +1 -0
- package/dist/src/yaml/steps/cache.js +351 -0
- package/dist/src/yaml/steps/fastlane.d.ts +27 -0
- package/dist/src/yaml/steps/fastlane.d.ts.map +1 -0
- package/dist/src/yaml/steps/fastlane.js +79 -0
- package/dist/src/yaml/steps/file.d.ts +27 -0
- package/dist/src/yaml/steps/file.d.ts.map +1 -0
- package/dist/src/yaml/steps/file.js +35 -0
- package/dist/src/yaml/steps/flutter.d.ts +63 -0
- package/dist/src/yaml/steps/flutter.d.ts.map +1 -0
- package/dist/src/yaml/steps/flutter.js +215 -0
- package/dist/src/yaml/steps/git-clone.d.ts +26 -0
- package/dist/src/yaml/steps/git-clone.d.ts.map +1 -0
- package/dist/src/yaml/steps/git-clone.js +111 -0
- package/dist/src/yaml/steps/google-play-deploy.d.ts +37 -0
- package/dist/src/yaml/steps/google-play-deploy.d.ts.map +1 -0
- package/dist/src/yaml/steps/google-play-deploy.js +193 -0
- package/dist/src/yaml/steps/google-play-deploy.test.d.ts +5 -0
- package/dist/src/yaml/steps/google-play-deploy.test.d.ts.map +1 -0
- package/dist/src/yaml/steps/google-play-deploy.test.js +310 -0
- package/dist/src/yaml/steps/index.d.ts +10 -0
- package/dist/src/yaml/steps/index.d.ts.map +1 -0
- package/dist/src/yaml/steps/index.js +1361 -0
- package/dist/src/yaml/steps/ios-deps.d.ts +43 -0
- package/dist/src/yaml/steps/ios-deps.d.ts.map +1 -0
- package/dist/src/yaml/steps/ios-deps.js +141 -0
- package/dist/src/yaml/steps/ios-deps.test.d.ts +5 -0
- package/dist/src/yaml/steps/ios-deps.test.d.ts.map +1 -0
- package/dist/src/yaml/steps/ios-deps.test.js +90 -0
- package/dist/src/yaml/steps/ios-signing.d.ts +31 -0
- package/dist/src/yaml/steps/ios-signing.d.ts.map +1 -0
- package/dist/src/yaml/steps/ios-signing.js +144 -0
- package/dist/src/yaml/steps/ios-version.d.ts +47 -0
- package/dist/src/yaml/steps/ios-version.d.ts.map +1 -0
- package/dist/src/yaml/steps/ios-version.js +151 -0
- package/dist/src/yaml/steps/linting.d.ts +47 -0
- package/dist/src/yaml/steps/linting.d.ts.map +1 -0
- package/dist/src/yaml/steps/linting.js +148 -0
- package/dist/src/yaml/steps/phase2.test.d.ts +6 -0
- package/dist/src/yaml/steps/phase2.test.d.ts.map +1 -0
- package/dist/src/yaml/steps/phase2.test.js +197 -0
- package/dist/src/yaml/steps/phase3.test.d.ts +5 -0
- package/dist/src/yaml/steps/phase3.test.d.ts.map +1 -0
- package/dist/src/yaml/steps/phase3.test.js +144 -0
- package/dist/src/yaml/steps/phase4.test.d.ts +5 -0
- package/dist/src/yaml/steps/phase4.test.d.ts.map +1 -0
- package/dist/src/yaml/steps/phase4.test.js +166 -0
- package/dist/src/yaml/steps/phase5.test.d.ts +6 -0
- package/dist/src/yaml/steps/phase5.test.d.ts.map +1 -0
- package/dist/src/yaml/steps/phase5.test.js +263 -0
- package/dist/src/yaml/steps/registry.d.ts +88 -0
- package/dist/src/yaml/steps/registry.d.ts.map +1 -0
- package/dist/src/yaml/steps/registry.js +125 -0
- package/dist/src/yaml/steps/registry.test.d.ts +5 -0
- package/dist/src/yaml/steps/registry.test.d.ts.map +1 -0
- package/dist/src/yaml/steps/registry.test.js +235 -0
- package/dist/src/yaml/steps/release.d.ts +50 -0
- package/dist/src/yaml/steps/release.d.ts.map +1 -0
- package/dist/src/yaml/steps/release.js +154 -0
- package/dist/src/yaml/steps/script.d.ts +23 -0
- package/dist/src/yaml/steps/script.d.ts.map +1 -0
- package/dist/src/yaml/steps/script.js +63 -0
- package/dist/src/yaml/steps/spec-validation.test.d.ts +6 -0
- package/dist/src/yaml/steps/spec-validation.test.d.ts.map +1 -0
- package/dist/src/yaml/steps/spec-validation.test.js +130 -0
- package/dist/src/yaml/steps/steps.test.d.ts +6 -0
- package/dist/src/yaml/steps/steps.test.d.ts.map +1 -0
- package/dist/src/yaml/steps/steps.test.js +474 -0
- package/dist/src/yaml/steps/test-config.d.ts +3 -0
- package/dist/src/yaml/steps/test-config.d.ts.map +1 -0
- package/dist/src/yaml/steps/test-config.js +16 -0
- package/dist/src/yaml/steps/xcode-new.test.d.ts +5 -0
- package/dist/src/yaml/steps/xcode-new.test.d.ts.map +1 -0
- package/dist/src/yaml/steps/xcode-new.test.js +211 -0
- package/dist/src/yaml/steps/xcode.d.ts +222 -0
- package/dist/src/yaml/steps/xcode.d.ts.map +1 -0
- package/dist/src/yaml/steps/xcode.js +999 -0
- package/dist/src/yaml/types.d.ts +68 -0
- package/dist/src/yaml/types.d.ts.map +1 -0
- package/dist/src/yaml/types.js +5 -0
- package/dist/src/yaml/validation-types.d.ts +96 -0
- package/dist/src/yaml/validation-types.d.ts.map +1 -0
- package/dist/src/yaml/validation-types.js +8 -0
- package/dist/src/yaml/yaml-updater.d.ts +24 -0
- package/dist/src/yaml/yaml-updater.d.ts.map +1 -0
- package/dist/src/yaml/yaml-updater.js +128 -0
- package/package.json +16 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitrise-slack.test.d.ts","sourceRoot":"","sources":["../../../../src/yaml/steps/bitrise-slack.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for Bitrise slack step
|
|
3
|
+
*/
|
|
4
|
+
import { describe, test, expect } from '@jest/globals';
|
|
5
|
+
import { BitriseSlackStepExecutor } from './bitrise-slack.js';
|
|
6
|
+
describe('BitriseSlackStepExecutor', () => {
|
|
7
|
+
const mockConfig = {
|
|
8
|
+
artifactsDir: '/ci/artifacts',
|
|
9
|
+
interpreters: {
|
|
10
|
+
python: '/usr/bin/python3',
|
|
11
|
+
ruby: '/usr/bin/ruby',
|
|
12
|
+
node: '/usr/bin/node',
|
|
13
|
+
bash: '/bin/bash',
|
|
14
|
+
},
|
|
15
|
+
maxConcurrentJobs: 4,
|
|
16
|
+
paths: {
|
|
17
|
+
buildsDir: '/ci/builds',
|
|
18
|
+
cacheDir: '/ci/cache',
|
|
19
|
+
derivedDataDir: '/ci/derived_data',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
describe('Basic functionality', () => {
|
|
23
|
+
test('should create Slack notification script with minimal inputs', async () => {
|
|
24
|
+
const executor = new BitriseSlackStepExecutor();
|
|
25
|
+
const env = {};
|
|
26
|
+
const inputs = {
|
|
27
|
+
webhook_url: 'https://hooks.slack.com/services/TEST/WEBHOOK/URL',
|
|
28
|
+
text: 'Build completed!',
|
|
29
|
+
};
|
|
30
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
31
|
+
expect(result.kind).toBe('script');
|
|
32
|
+
expect(result.name).toBe('slack');
|
|
33
|
+
expect(result.script).toContain('Sending Slack notification');
|
|
34
|
+
expect(result.script).toContain('https://hooks.slack.com/services/TEST/WEBHOOK/URL');
|
|
35
|
+
expect(result.script).toContain('Build completed!');
|
|
36
|
+
});
|
|
37
|
+
test('should use text input for message content', async () => {
|
|
38
|
+
const executor = new BitriseSlackStepExecutor();
|
|
39
|
+
const env = {};
|
|
40
|
+
const inputs = {
|
|
41
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
42
|
+
text: 'Test message',
|
|
43
|
+
};
|
|
44
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
45
|
+
expect(result.script).toContain('Test message');
|
|
46
|
+
});
|
|
47
|
+
test('should fall back to message input if text not provided', async () => {
|
|
48
|
+
const executor = new BitriseSlackStepExecutor();
|
|
49
|
+
const env = {};
|
|
50
|
+
const inputs = {
|
|
51
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
52
|
+
message: 'Fallback message',
|
|
53
|
+
};
|
|
54
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
55
|
+
expect(result.script).toContain('Fallback message');
|
|
56
|
+
});
|
|
57
|
+
test('should use default message if neither text nor message provided', async () => {
|
|
58
|
+
const executor = new BitriseSlackStepExecutor();
|
|
59
|
+
const env = {};
|
|
60
|
+
const inputs = {
|
|
61
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
62
|
+
};
|
|
63
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
64
|
+
expect(result.script).toContain('CI Build build notification');
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
describe('Webhook URL handling', () => {
|
|
68
|
+
test('should use webhook_url from inputs', async () => {
|
|
69
|
+
const executor = new BitriseSlackStepExecutor();
|
|
70
|
+
const env = {};
|
|
71
|
+
const inputs = {
|
|
72
|
+
webhook_url: 'https://hooks.slack.com/services/CUSTOM',
|
|
73
|
+
text: 'Test',
|
|
74
|
+
};
|
|
75
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
76
|
+
expect(result.script).toContain('https://hooks.slack.com/services/CUSTOM');
|
|
77
|
+
});
|
|
78
|
+
test('should fall back to SLACK_WEBHOOK_URL environment variable', async () => {
|
|
79
|
+
const executor = new BitriseSlackStepExecutor();
|
|
80
|
+
const env = {
|
|
81
|
+
SLACK_WEBHOOK_URL: 'https://hooks.slack.com/services/FROM_ENV',
|
|
82
|
+
};
|
|
83
|
+
const inputs = {
|
|
84
|
+
text: 'Test',
|
|
85
|
+
};
|
|
86
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
87
|
+
expect(result.script).toContain('https://hooks.slack.com/services/FROM_ENV');
|
|
88
|
+
});
|
|
89
|
+
test('should prefer input over environment variable', async () => {
|
|
90
|
+
const executor = new BitriseSlackStepExecutor();
|
|
91
|
+
const env = {
|
|
92
|
+
SLACK_WEBHOOK_URL: 'https://hooks.slack.com/env',
|
|
93
|
+
};
|
|
94
|
+
const inputs = {
|
|
95
|
+
webhook_url: 'https://hooks.slack.com/input',
|
|
96
|
+
text: 'Test',
|
|
97
|
+
};
|
|
98
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
99
|
+
expect(result.script).toContain('https://hooks.slack.com/input');
|
|
100
|
+
expect(result.script).not.toContain('https://hooks.slack.com/env');
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
describe('Message formatting', () => {
|
|
104
|
+
test('should include channel when provided', async () => {
|
|
105
|
+
const executor = new BitriseSlackStepExecutor();
|
|
106
|
+
const env = {};
|
|
107
|
+
const inputs = {
|
|
108
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
109
|
+
text: 'Test',
|
|
110
|
+
channel: '#builds',
|
|
111
|
+
};
|
|
112
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
113
|
+
expect(result.script).toContain('"channel": "#builds"');
|
|
114
|
+
});
|
|
115
|
+
test('should include custom username', async () => {
|
|
116
|
+
const executor = new BitriseSlackStepExecutor();
|
|
117
|
+
const env = {};
|
|
118
|
+
const inputs = {
|
|
119
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
120
|
+
text: 'Test',
|
|
121
|
+
from_username: 'Build Bot',
|
|
122
|
+
};
|
|
123
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
124
|
+
expect(result.script).toContain('"username": "Build Bot"');
|
|
125
|
+
});
|
|
126
|
+
test('should use default username CI Build', async () => {
|
|
127
|
+
const executor = new BitriseSlackStepExecutor();
|
|
128
|
+
const env = {};
|
|
129
|
+
const inputs = {
|
|
130
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
131
|
+
text: 'Test',
|
|
132
|
+
};
|
|
133
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
134
|
+
expect(result.script).toContain('"username": "CI Build"');
|
|
135
|
+
});
|
|
136
|
+
test('should include icon_emoji when provided', async () => {
|
|
137
|
+
const executor = new BitriseSlackStepExecutor();
|
|
138
|
+
const env = {};
|
|
139
|
+
const inputs = {
|
|
140
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
141
|
+
text: 'Test',
|
|
142
|
+
icon_emoji: ':robot_face:',
|
|
143
|
+
};
|
|
144
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
145
|
+
expect(result.script).toContain('"icon_emoji": ":robot_face:"');
|
|
146
|
+
});
|
|
147
|
+
test('should include icon_url when provided', async () => {
|
|
148
|
+
const executor = new BitriseSlackStepExecutor();
|
|
149
|
+
const env = {};
|
|
150
|
+
const inputs = {
|
|
151
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
152
|
+
text: 'Test',
|
|
153
|
+
icon_url: 'https://example.com/icon.png',
|
|
154
|
+
};
|
|
155
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
156
|
+
expect(result.script).toContain('"icon_url": "https://example.com/icon.png"');
|
|
157
|
+
});
|
|
158
|
+
test('should include color attachment', async () => {
|
|
159
|
+
const executor = new BitriseSlackStepExecutor();
|
|
160
|
+
const env = {};
|
|
161
|
+
const inputs = {
|
|
162
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
163
|
+
text: 'Test',
|
|
164
|
+
color: 'danger',
|
|
165
|
+
};
|
|
166
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
167
|
+
expect(result.script).toContain('"color": "danger"');
|
|
168
|
+
});
|
|
169
|
+
test('should use default color good', async () => {
|
|
170
|
+
const executor = new BitriseSlackStepExecutor();
|
|
171
|
+
const env = {};
|
|
172
|
+
const inputs = {
|
|
173
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
174
|
+
text: 'Test',
|
|
175
|
+
};
|
|
176
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
177
|
+
expect(result.script).toContain('"color": "good"');
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
describe('Advanced formatting', () => {
|
|
181
|
+
test('should include pretext when provided', async () => {
|
|
182
|
+
const executor = new BitriseSlackStepExecutor();
|
|
183
|
+
const env = {};
|
|
184
|
+
const inputs = {
|
|
185
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
186
|
+
text: 'Test',
|
|
187
|
+
pretext: 'Build notification:',
|
|
188
|
+
};
|
|
189
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
190
|
+
expect(result.script).toContain('"pretext": "Build notification:"');
|
|
191
|
+
});
|
|
192
|
+
test('should include author_name when provided', async () => {
|
|
193
|
+
const executor = new BitriseSlackStepExecutor();
|
|
194
|
+
const env = {};
|
|
195
|
+
const inputs = {
|
|
196
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
197
|
+
text: 'Test',
|
|
198
|
+
author_name: 'John Doe',
|
|
199
|
+
};
|
|
200
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
201
|
+
expect(result.script).toContain('"author_name": "John Doe"');
|
|
202
|
+
});
|
|
203
|
+
test('should include title and title_link', async () => {
|
|
204
|
+
const executor = new BitriseSlackStepExecutor();
|
|
205
|
+
const env = {};
|
|
206
|
+
const inputs = {
|
|
207
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
208
|
+
text: 'Test',
|
|
209
|
+
title: 'Build #42',
|
|
210
|
+
title_link: 'https://ci.example.com/builds/42',
|
|
211
|
+
};
|
|
212
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
213
|
+
expect(result.script).toContain('"title": "Build #42"');
|
|
214
|
+
expect(result.script).toContain('"title_link": "https://ci.example.com/builds/42"');
|
|
215
|
+
});
|
|
216
|
+
test('should include footer when provided', async () => {
|
|
217
|
+
const executor = new BitriseSlackStepExecutor();
|
|
218
|
+
const env = {};
|
|
219
|
+
const inputs = {
|
|
220
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
221
|
+
text: 'Test',
|
|
222
|
+
footer: 'CI Build',
|
|
223
|
+
footer_icon: 'https://example.com/footer.png',
|
|
224
|
+
};
|
|
225
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
226
|
+
expect(result.script).toContain('"footer": "CI Build"');
|
|
227
|
+
expect(result.script).toContain('"footer_icon": "https://example.com/footer.png"');
|
|
228
|
+
});
|
|
229
|
+
test('should include timestamp when provided', async () => {
|
|
230
|
+
const executor = new BitriseSlackStepExecutor();
|
|
231
|
+
const env = {};
|
|
232
|
+
const inputs = {
|
|
233
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
234
|
+
text: 'Test',
|
|
235
|
+
timestamp: '1234567890',
|
|
236
|
+
};
|
|
237
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
238
|
+
expect(result.script).toContain('"ts": 1234567890');
|
|
239
|
+
});
|
|
240
|
+
test('should include fields when provided', async () => {
|
|
241
|
+
const executor = new BitriseSlackStepExecutor();
|
|
242
|
+
const env = {};
|
|
243
|
+
const inputs = {
|
|
244
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
245
|
+
text: 'Test',
|
|
246
|
+
fields: '[{"title":"Status","value":"Success","short":true}]',
|
|
247
|
+
};
|
|
248
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
249
|
+
expect(result.script).toContain('"fields": [{"title":"Status","value":"Success","short":true}]');
|
|
250
|
+
});
|
|
251
|
+
test('should include buttons when provided', async () => {
|
|
252
|
+
const executor = new BitriseSlackStepExecutor();
|
|
253
|
+
const env = {};
|
|
254
|
+
const inputs = {
|
|
255
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
256
|
+
text: 'Test',
|
|
257
|
+
buttons: 'View Build|https://example.com',
|
|
258
|
+
};
|
|
259
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
260
|
+
// Buttons are now base64-encoded and processed as inline links, not JSON actions
|
|
261
|
+
expect(result.script).toContain('BUTTONS_DATA=$(echo "');
|
|
262
|
+
expect(result.script).toContain('base64 -d)');
|
|
263
|
+
expect(result.script).toContain('BUTTON_LINKS');
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
describe('JSON payload generation', () => {
|
|
267
|
+
test('should generate valid JSON structure', async () => {
|
|
268
|
+
const executor = new BitriseSlackStepExecutor();
|
|
269
|
+
const env = {};
|
|
270
|
+
const inputs = {
|
|
271
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
272
|
+
text: 'Test message',
|
|
273
|
+
};
|
|
274
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
275
|
+
expect(result.script).toContain('cat > /tmp/slack-payload.json');
|
|
276
|
+
expect(result.script).toContain('"attachments": [');
|
|
277
|
+
expect(result.script).toContain('"text": "$SLACK_MESSAGE_TEXT"');
|
|
278
|
+
});
|
|
279
|
+
test('should use curl POST request', async () => {
|
|
280
|
+
const executor = new BitriseSlackStepExecutor();
|
|
281
|
+
const env = {};
|
|
282
|
+
const inputs = {
|
|
283
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
284
|
+
text: 'Test',
|
|
285
|
+
};
|
|
286
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
287
|
+
expect(result.script).toContain('curl -X POST');
|
|
288
|
+
expect(result.script).toContain('-H "Content-Type: application/json"');
|
|
289
|
+
expect(result.script).toContain('-d @/tmp/slack-payload.json');
|
|
290
|
+
});
|
|
291
|
+
test('should clean up temporary file', async () => {
|
|
292
|
+
const executor = new BitriseSlackStepExecutor();
|
|
293
|
+
const env = {};
|
|
294
|
+
const inputs = {
|
|
295
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
296
|
+
text: 'Test',
|
|
297
|
+
};
|
|
298
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
299
|
+
expect(result.script).toContain('rm -f /tmp/slack-payload.json');
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
describe('Debug mode', () => {
|
|
303
|
+
test('should not display payload by default', async () => {
|
|
304
|
+
const executor = new BitriseSlackStepExecutor();
|
|
305
|
+
const env = {};
|
|
306
|
+
const inputs = {
|
|
307
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
308
|
+
text: 'Test',
|
|
309
|
+
};
|
|
310
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
311
|
+
expect(result.script).not.toContain('Debug: Display payload');
|
|
312
|
+
});
|
|
313
|
+
test('should display payload when is_debug_mode is true', async () => {
|
|
314
|
+
const executor = new BitriseSlackStepExecutor();
|
|
315
|
+
const env = {};
|
|
316
|
+
const inputs = {
|
|
317
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
318
|
+
text: 'Test',
|
|
319
|
+
is_debug_mode: 'true',
|
|
320
|
+
};
|
|
321
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
322
|
+
expect(result.script).toContain('Debug: Display payload');
|
|
323
|
+
expect(result.script).toContain('cat /tmp/slack-payload.json');
|
|
324
|
+
});
|
|
325
|
+
test('should display payload when is_debug_mode is yes', async () => {
|
|
326
|
+
const executor = new BitriseSlackStepExecutor();
|
|
327
|
+
const env = {};
|
|
328
|
+
const inputs = {
|
|
329
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
330
|
+
text: 'Test',
|
|
331
|
+
is_debug_mode: 'yes',
|
|
332
|
+
};
|
|
333
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
334
|
+
expect(result.script).toContain('Debug: Display payload');
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
describe('Error handling', () => {
|
|
338
|
+
test('should throw error when webhook_url is missing', async () => {
|
|
339
|
+
const executor = new BitriseSlackStepExecutor();
|
|
340
|
+
const env = {};
|
|
341
|
+
const inputs = {
|
|
342
|
+
text: 'Test',
|
|
343
|
+
};
|
|
344
|
+
await expect(executor.execute(inputs, env, mockConfig)).rejects.toThrow(/Missing environment variable: 'SLACK_WEBHOOK_URL'/);
|
|
345
|
+
});
|
|
346
|
+
test('should include helpful error message for missing webhook', async () => {
|
|
347
|
+
const executor = new BitriseSlackStepExecutor();
|
|
348
|
+
const env = {};
|
|
349
|
+
const inputs = {};
|
|
350
|
+
await expect(executor.execute(inputs, env, mockConfig)).rejects.toThrow(/Missing environment variable: 'SLACK_WEBHOOK_URL'[\s\S]*Slack webhook URL/);
|
|
351
|
+
});
|
|
352
|
+
test('should check curl exit status', async () => {
|
|
353
|
+
const executor = new BitriseSlackStepExecutor();
|
|
354
|
+
const env = {};
|
|
355
|
+
const inputs = {
|
|
356
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
357
|
+
text: 'Test',
|
|
358
|
+
};
|
|
359
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
360
|
+
expect(result.script).toContain('if [ "$HTTP_CODE" = "200" ] || [ "$RESPONSE_BODY" = "ok" ]; then');
|
|
361
|
+
expect(result.script).toContain('Slack notification sent successfully');
|
|
362
|
+
expect(result.script).toContain('Failed to send Slack notification');
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
describe('Special characters handling', () => {
|
|
366
|
+
test('should escape quotes in message text', async () => {
|
|
367
|
+
const executor = new BitriseSlackStepExecutor();
|
|
368
|
+
const env = {};
|
|
369
|
+
const inputs = {
|
|
370
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
371
|
+
text: 'Build "success" message',
|
|
372
|
+
};
|
|
373
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
374
|
+
expect(result.script).toContain('Build \\"success\\" message');
|
|
375
|
+
});
|
|
376
|
+
test('should escape newlines in message text', async () => {
|
|
377
|
+
const executor = new BitriseSlackStepExecutor();
|
|
378
|
+
const env = {};
|
|
379
|
+
const inputs = {
|
|
380
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
381
|
+
text: 'Line 1\nLine 2',
|
|
382
|
+
};
|
|
383
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
384
|
+
expect(result.script).toContain('Line 1\\nLine 2');
|
|
385
|
+
});
|
|
386
|
+
test('should escape backslashes in message text', async () => {
|
|
387
|
+
const executor = new BitriseSlackStepExecutor();
|
|
388
|
+
const env = {};
|
|
389
|
+
const inputs = {
|
|
390
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
391
|
+
text: 'Path: C:\\Windows\\System32',
|
|
392
|
+
};
|
|
393
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
394
|
+
expect(result.script).toContain('C:\\\\Windows\\\\System32');
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
describe('Script structure', () => {
|
|
398
|
+
test('should include bash error handling directives', async () => {
|
|
399
|
+
const executor = new BitriseSlackStepExecutor();
|
|
400
|
+
const env = {};
|
|
401
|
+
const inputs = {
|
|
402
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
403
|
+
text: 'Test',
|
|
404
|
+
};
|
|
405
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
406
|
+
expect(result.script).toContain('#!/bin/bash');
|
|
407
|
+
expect(result.script).toContain('set -e');
|
|
408
|
+
expect(result.script).toContain('set -o pipefail');
|
|
409
|
+
});
|
|
410
|
+
test('should include informative messages', async () => {
|
|
411
|
+
const executor = new BitriseSlackStepExecutor();
|
|
412
|
+
const env = {};
|
|
413
|
+
const inputs = {
|
|
414
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
415
|
+
text: 'Test',
|
|
416
|
+
};
|
|
417
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
418
|
+
expect(result.script).toContain('Bitrise slack step → CI Build Slack notification');
|
|
419
|
+
expect(result.script).toContain('Sending Slack notification');
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
describe('Integration scenarios', () => {
|
|
423
|
+
test('should work with all formatting options combined', async () => {
|
|
424
|
+
const executor = new BitriseSlackStepExecutor();
|
|
425
|
+
const env = {};
|
|
426
|
+
const inputs = {
|
|
427
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
428
|
+
text: 'Build completed',
|
|
429
|
+
channel: '#deployments',
|
|
430
|
+
from_username: 'Deploy Bot',
|
|
431
|
+
icon_emoji: ':rocket:',
|
|
432
|
+
color: 'good',
|
|
433
|
+
pretext: 'Deployment notification',
|
|
434
|
+
author_name: 'CI Build',
|
|
435
|
+
title: 'Production Deploy',
|
|
436
|
+
title_link: 'https://example.com/deploy',
|
|
437
|
+
footer: 'CI Build',
|
|
438
|
+
timestamp: '1234567890',
|
|
439
|
+
};
|
|
440
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
441
|
+
expect(result.kind).toBe('script');
|
|
442
|
+
expect(result.script).toContain('#deployments');
|
|
443
|
+
expect(result.script).toContain('Deploy Bot');
|
|
444
|
+
expect(result.script).toContain(':rocket:');
|
|
445
|
+
expect(result.script).toContain('Production Deploy');
|
|
446
|
+
});
|
|
447
|
+
test('should work with minimal configuration', async () => {
|
|
448
|
+
const executor = new BitriseSlackStepExecutor();
|
|
449
|
+
const env = {
|
|
450
|
+
SLACK_WEBHOOK_URL: 'https://hooks.slack.com/minimal',
|
|
451
|
+
};
|
|
452
|
+
const inputs = {};
|
|
453
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
454
|
+
expect(result.kind).toBe('script');
|
|
455
|
+
expect(result.script).toContain('CI Build build notification');
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
describe('Bitrise compatibility', () => {
|
|
459
|
+
test('should support Bitrise input naming conventions', async () => {
|
|
460
|
+
const executor = new BitriseSlackStepExecutor();
|
|
461
|
+
const env = {};
|
|
462
|
+
const inputs = {
|
|
463
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
464
|
+
text: 'Build message',
|
|
465
|
+
from_username: 'Bitrise',
|
|
466
|
+
icon_emoji: ':bitrise:',
|
|
467
|
+
};
|
|
468
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
469
|
+
expect(result.script).toBeDefined();
|
|
470
|
+
expect(result.kind).toBe('script');
|
|
471
|
+
});
|
|
472
|
+
test('should map to CI Build Slack notification pattern', async () => {
|
|
473
|
+
const executor = new BitriseSlackStepExecutor();
|
|
474
|
+
const env = {};
|
|
475
|
+
const inputs = {
|
|
476
|
+
webhook_url: 'https://hooks.slack.com/test',
|
|
477
|
+
text: 'Test',
|
|
478
|
+
};
|
|
479
|
+
const result = await executor.execute(inputs, env, mockConfig);
|
|
480
|
+
expect(result.script).toContain('CI Build Slack notification');
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
//# sourceMappingURL=bitrise-slack.test.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bitrise activate-ssh-key step implementation
|
|
3
|
+
* Maps Bitrise activate-ssh-key@* to CI Build SSH key activation
|
|
4
|
+
*/
|
|
5
|
+
import { BaseStepExecutor } from './base.js';
|
|
6
|
+
import type { StepDef, CIConfig } from '../../types.js';
|
|
7
|
+
import type { ValidationRequirement } from '../validation-types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Inputs for activate-ssh-key step
|
|
10
|
+
*/
|
|
11
|
+
export interface BitriseSSHInputs {
|
|
12
|
+
ssh_rsa_private_key?: string;
|
|
13
|
+
ssh_key_save_path?: string;
|
|
14
|
+
is_remove_other_identities?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Bitrise activate-ssh-key step executor (FR-2)
|
|
18
|
+
* Activates an SSH key for Git operations
|
|
19
|
+
*
|
|
20
|
+
* Supports Bitrise step versions: activate-ssh-key@1, @2, @3, @4
|
|
21
|
+
*/
|
|
22
|
+
export declare class BitriseSSHStepExecutor extends BaseStepExecutor {
|
|
23
|
+
isSkippedInLocalMode(): boolean;
|
|
24
|
+
getValidationRequirements(_inputs: BitriseSSHInputs, env: Record<string, string>, config: CIConfig): ValidationRequirement[];
|
|
25
|
+
execute(inputs: BitriseSSHInputs, env: Record<string, string>, config: CIConfig): Promise<StepDef>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=bitrise-ssh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitrise-ssh.d.ts","sourceRoot":"","sources":["../../../../src/yaml/steps/bitrise-ssh.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0BAA0B,CAAC,EAAE,MAAM,CAAC;CACrC;AAED;;;;;GAKG;AACH,qBAAa,sBAAuB,SAAQ,gBAAgB;IAC1D,oBAAoB,IAAI,OAAO;IAI/B,yBAAyB,CACvB,OAAO,EAAE,gBAAgB,EACzB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC3B,MAAM,EAAE,QAAQ,GACf,qBAAqB,EAAE;IAsBpB,OAAO,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;CAmIzG"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bitrise activate-ssh-key step implementation
|
|
3
|
+
* Maps Bitrise activate-ssh-key@* to CI Build SSH key activation
|
|
4
|
+
*/
|
|
5
|
+
import { BaseStepExecutor } from './base.js';
|
|
6
|
+
import { MissingEnvironmentVariableError } from '../env-resolver.js';
|
|
7
|
+
/**
|
|
8
|
+
* Bitrise activate-ssh-key step executor (FR-2)
|
|
9
|
+
* Activates an SSH key for Git operations
|
|
10
|
+
*
|
|
11
|
+
* Supports Bitrise step versions: activate-ssh-key@1, @2, @3, @4
|
|
12
|
+
*/
|
|
13
|
+
export class BitriseSSHStepExecutor extends BaseStepExecutor {
|
|
14
|
+
isSkippedInLocalMode() {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
getValidationRequirements(_inputs, env, config) {
|
|
18
|
+
if (config.local)
|
|
19
|
+
return [];
|
|
20
|
+
return [
|
|
21
|
+
this.requireEnvVar('SSH_RSA_PRIVATE_KEY', 'SSH private key for git authentication', env, 'Set SSH_RSA_PRIVATE_KEY environment variable with your private key'),
|
|
22
|
+
this.requireCommand('ssh-agent', 'SSH agent for managing SSH keys', 'ssh-agent should be pre-installed on macOS and Linux'),
|
|
23
|
+
this.requireCommand('ssh-add', 'SSH key management tool', 'ssh-add should be pre-installed on macOS and Linux'),
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
async execute(inputs, env, config) {
|
|
27
|
+
const stepName = 'activate-ssh-key';
|
|
28
|
+
if (config.local) {
|
|
29
|
+
const script = this.createBashScriptFromCommands(['echo "⏭️ activate-ssh-key: skipped in local mode"'], stepName);
|
|
30
|
+
return this.createScriptStep(script, stepName);
|
|
31
|
+
}
|
|
32
|
+
// Get SSH key from environment variable (FR-2.3)
|
|
33
|
+
const sshKeyEnvVar = 'SSH_RSA_PRIVATE_KEY';
|
|
34
|
+
// Check if SSH key is available
|
|
35
|
+
if (!env[sshKeyEnvVar]) {
|
|
36
|
+
throw new MissingEnvironmentVariableError(sshKeyEnvVar, stepName, 'SSH private key used for Git authentication and repository access.\n\n' +
|
|
37
|
+
'Expected format (PEM):\n' +
|
|
38
|
+
' ┌────────────────────────────────────────┐\n' +
|
|
39
|
+
' │ -----BEGIN RSA PRIVATE KEY----- │\n' +
|
|
40
|
+
' │ MIIEpAIBAAKCAQEA... │\n' +
|
|
41
|
+
' │ -----END RSA PRIVATE KEY----- │\n' +
|
|
42
|
+
' └────────────────────────────────────────┘\n\n' +
|
|
43
|
+
'Or OpenSSH format:\n' +
|
|
44
|
+
' ┌────────────────────────────────────────┐\n' +
|
|
45
|
+
' │ -----BEGIN OPENSSH PRIVATE KEY----- │\n' +
|
|
46
|
+
' │ b3BlbnNzaC1rZXktdjEAAAAA... │\n' +
|
|
47
|
+
' │ -----END OPENSSH PRIVATE KEY----- │\n' +
|
|
48
|
+
' └────────────────────────────────────────┘\n\n' +
|
|
49
|
+
'How to generate:\n' +
|
|
50
|
+
' • ssh-keygen -t rsa -b 4096 -C "ci@example.com"\n' +
|
|
51
|
+
' • Add public key to GitHub/GitLab deploy keys\n' +
|
|
52
|
+
' • Store private key in CI secrets');
|
|
53
|
+
}
|
|
54
|
+
// Get SSH key save path (FR-2.4)
|
|
55
|
+
// Use YAML filename in key path to avoid conflicts between different pipeline files
|
|
56
|
+
const yamlFilename = env['CIBUILD_YAML_FILENAME'] || env['CIBUILD_TRIGGERED_WORKFLOW_ID'] || 'default';
|
|
57
|
+
const defaultKeyPath = `~/.ssh/${yamlFilename}.pem`;
|
|
58
|
+
const sshKeyPath = this.getInput(inputs, 'ssh_key_save_path', defaultKeyPath);
|
|
59
|
+
// Get remove other identities flag
|
|
60
|
+
const removeOtherIdentities = this.getInput(inputs, 'is_remove_other_identities', 'true');
|
|
61
|
+
// Get the actual SSH key value to embed in the script
|
|
62
|
+
const sshKeyValue = env[sshKeyEnvVar];
|
|
63
|
+
const commands = [];
|
|
64
|
+
commands.push('# Bitrise activate-ssh-key step → CI Build SSH activation');
|
|
65
|
+
commands.push('echo "📋 Setting up SSH key for Git operations..."');
|
|
66
|
+
commands.push('');
|
|
67
|
+
// Create .ssh directory if it doesn't exist
|
|
68
|
+
commands.push('# Create .ssh directory with proper permissions');
|
|
69
|
+
commands.push('mkdir -p ~/.ssh');
|
|
70
|
+
commands.push('chmod 700 ~/.ssh');
|
|
71
|
+
commands.push('');
|
|
72
|
+
// Write SSH key to file using node to handle newlines properly
|
|
73
|
+
// Export the key using heredoc to preserve special characters
|
|
74
|
+
commands.push('# Export SSH key from YAML config');
|
|
75
|
+
commands.push(`export ${sshKeyEnvVar}=$(cat <<'SSHKEY_EOF'`);
|
|
76
|
+
commands.push(sshKeyValue);
|
|
77
|
+
commands.push('SSHKEY_EOF');
|
|
78
|
+
commands.push(')');
|
|
79
|
+
commands.push('');
|
|
80
|
+
// Write SSH private key to file
|
|
81
|
+
// Use tr to convert \r to \n, then printf %b to interpret escape sequences
|
|
82
|
+
const keyFileName = sshKeyPath.replace('~/.ssh/', '');
|
|
83
|
+
commands.push('# Write SSH private key to file');
|
|
84
|
+
commands.push(`echo "Writing SSH key to ${sshKeyPath}"`);
|
|
85
|
+
commands.push(`echo "\${${sshKeyEnvVar}}" | tr '\\r' '\\n' > ~/.ssh/${keyFileName}`);
|
|
86
|
+
commands.push(`chmod 600 ${sshKeyPath}`);
|
|
87
|
+
commands.push('');
|
|
88
|
+
// Remove other SSH identities if requested
|
|
89
|
+
if (removeOtherIdentities === 'true' || removeOtherIdentities === 'yes') {
|
|
90
|
+
commands.push('# Remove other SSH identities from agent');
|
|
91
|
+
commands.push('ssh-add -D 2>/dev/null || true');
|
|
92
|
+
commands.push('');
|
|
93
|
+
}
|
|
94
|
+
// Start SSH agent and add key (FR-2.5)
|
|
95
|
+
commands.push('# Start SSH agent and add key');
|
|
96
|
+
commands.push('eval "$(ssh-agent -s)"');
|
|
97
|
+
commands.push(`ssh-add ${sshKeyPath}`);
|
|
98
|
+
commands.push('');
|
|
99
|
+
// Configure SSH to use the key file and avoid host key verification issues
|
|
100
|
+
// This ensures the key is used in subsequent steps without needing ssh-agent
|
|
101
|
+
commands.push('# Configure SSH client to use the key file');
|
|
102
|
+
commands.push('cat >> ~/.ssh/config << EOF');
|
|
103
|
+
commands.push('Host github.com');
|
|
104
|
+
commands.push(` IdentityFile ${sshKeyPath}`);
|
|
105
|
+
commands.push(' StrictHostKeyChecking no');
|
|
106
|
+
commands.push(' UserKnownHostsFile=/dev/null');
|
|
107
|
+
commands.push(' LogLevel ERROR');
|
|
108
|
+
commands.push('');
|
|
109
|
+
commands.push('Host gitlab.com');
|
|
110
|
+
commands.push(` IdentityFile ${sshKeyPath}`);
|
|
111
|
+
commands.push(' StrictHostKeyChecking no');
|
|
112
|
+
commands.push(' UserKnownHostsFile=/dev/null');
|
|
113
|
+
commands.push(' LogLevel ERROR');
|
|
114
|
+
commands.push('');
|
|
115
|
+
commands.push('Host bitbucket.org');
|
|
116
|
+
commands.push(` IdentityFile ${sshKeyPath}`);
|
|
117
|
+
commands.push(' StrictHostKeyChecking no');
|
|
118
|
+
commands.push(' UserKnownHostsFile=/dev/null');
|
|
119
|
+
commands.push(' LogLevel ERROR');
|
|
120
|
+
commands.push('');
|
|
121
|
+
commands.push('Host *');
|
|
122
|
+
commands.push(` IdentityFile ${sshKeyPath}`);
|
|
123
|
+
commands.push(' StrictHostKeyChecking no');
|
|
124
|
+
commands.push(' UserKnownHostsFile=/dev/null');
|
|
125
|
+
commands.push(' LogLevel ERROR');
|
|
126
|
+
commands.push('EOF');
|
|
127
|
+
commands.push('chmod 600 ~/.ssh/config');
|
|
128
|
+
commands.push('');
|
|
129
|
+
commands.push('echo "✅ SSH key activated successfully"');
|
|
130
|
+
const script = this.createBashScriptFromCommands(commands, stepName);
|
|
131
|
+
return this.createScriptStep(script, stepName);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=bitrise-ssh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitrise-ssh.test.d.ts","sourceRoot":"","sources":["../../../../src/yaml/steps/bitrise-ssh.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|