@catladder/pipeline 1.144.1 → 1.146.0

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.
Files changed (335) hide show
  1. package/dist/bash/BashExpression.d.ts +40 -0
  2. package/dist/bash/BashExpression.js +124 -0
  3. package/dist/bash/bashExpressionPerPipelineType.d.ts +6 -0
  4. package/dist/bash/bashExpressionPerPipelineType.js +11 -0
  5. package/dist/bash/bashYaml.d.ts +10 -0
  6. package/dist/bash/bashYaml.js +46 -0
  7. package/dist/bash/getInjectVarsScript.d.ts +2 -0
  8. package/dist/bash/getInjectVarsScript.js +45 -0
  9. package/dist/bash/replaceAsync.d.ts +2 -0
  10. package/dist/{pipeline/commitInfo/getCommitInfo.js → bash/replaceAsync.js} +49 -21
  11. package/dist/build/base/__tests__/createArtifactsConfig.test.js +3 -1
  12. package/dist/build/base/constants.js +3 -1
  13. package/dist/build/base/createAppBuildJob.d.ts +2 -1
  14. package/dist/build/base/createAppBuildJob.js +10 -6
  15. package/dist/build/base/createArtifactsConfig.d.ts +1 -1
  16. package/dist/build/base/createArtifactsConfig.js +3 -1
  17. package/dist/build/base/index.js +3 -1
  18. package/dist/build/base/writeBuildInfo.js +4 -3
  19. package/dist/build/base/writeDotEnv.js +12 -3
  20. package/dist/build/custom/__tests__/testJob.test.js +3 -1
  21. package/dist/build/custom/buildJob.js +4 -12
  22. package/dist/build/custom/index.js +3 -1
  23. package/dist/build/custom/testJob.d.ts +1 -1
  24. package/dist/build/custom/testJob.js +18 -14
  25. package/dist/build/docker.d.ts +5 -31
  26. package/dist/build/docker.js +16 -9
  27. package/dist/build/index.d.ts +1 -1
  28. package/dist/build/index.js +13 -7
  29. package/dist/build/node/buildJob.js +4 -12
  30. package/dist/build/node/cache.js +6 -3
  31. package/dist/build/node/constants.js +3 -1
  32. package/dist/build/node/index.js +3 -1
  33. package/dist/build/node/meteor.js +5 -2
  34. package/dist/build/node/testJob.js +18 -14
  35. package/dist/build/node/yarn.d.ts +3 -2
  36. package/dist/build/node/yarn.js +6 -3
  37. package/dist/build/rails/build.js +3 -1
  38. package/dist/build/rails/index.js +3 -1
  39. package/dist/build/rails/test.js +15 -11
  40. package/dist/build/sbom.js +3 -1
  41. package/dist/build/types.d.ts +24 -18
  42. package/dist/build/types.js +3 -1
  43. package/dist/bundles/catladder-gitlab/index.js +3 -3
  44. package/dist/catladder-gitlab.js +10 -54
  45. package/dist/config/__tests__/configruedEnvs.test.js +3 -1
  46. package/dist/config/configruedEnvs.js +3 -1
  47. package/dist/config/index.js +13 -7
  48. package/dist/config/readConfig.js +6 -5
  49. package/dist/constants.js +5 -3
  50. package/dist/context/__tests__/resolveReferences.test.js +40 -8
  51. package/dist/context/getBuildInfoVariables.d.ts +7 -0
  52. package/dist/context/getBuildInfoVariables.js +29 -0
  53. package/dist/context/getEnvConfig.js +3 -1
  54. package/dist/context/getEnvType.js +3 -1
  55. package/dist/context/getEnvironment.d.ts +3 -3
  56. package/dist/context/getEnvironment.js +10 -14
  57. package/dist/context/getEnvironmentContext.d.ts +7 -3
  58. package/dist/context/getEnvironmentContext.js +21 -11
  59. package/dist/context/getEnvironmentVariables.d.ts +26 -5
  60. package/dist/context/getEnvironmentVariables.js +40 -25
  61. package/dist/context/getLabels.js +4 -2
  62. package/dist/context/getReviewSlug.d.ts +4 -0
  63. package/dist/context/getReviewSlug.js +22 -0
  64. package/dist/context/index.d.ts +12 -3
  65. package/dist/context/index.js +21 -15
  66. package/dist/context/resolveReferences.d.ts +3 -1
  67. package/dist/context/resolveReferences.js +53 -21
  68. package/dist/context/transformJobOnlyVars.d.ts +5 -2
  69. package/dist/context/transformJobOnlyVars.js +4 -2
  70. package/dist/context/utils/envVars.d.ts +1 -1
  71. package/dist/context/utils/envVars.js +5 -2
  72. package/dist/defaults/index.js +3 -1
  73. package/dist/deploy/base/deploy.d.ts +1 -1
  74. package/dist/deploy/base/deploy.js +12 -11
  75. package/dist/deploy/base/index.js +3 -1
  76. package/dist/deploy/base/rollback.d.ts +1 -1
  77. package/dist/deploy/base/rollback.js +13 -9
  78. package/dist/deploy/base/stop.d.ts +1 -1
  79. package/dist/deploy/base/stop.js +16 -11
  80. package/dist/deploy/base/types.d.ts +1 -1
  81. package/dist/deploy/base/types.js +3 -1
  82. package/dist/deploy/base/variables.js +3 -1
  83. package/dist/deploy/cloudRun/artifactsRegistry.d.ts +2 -1
  84. package/dist/deploy/cloudRun/artifactsRegistry.js +6 -4
  85. package/dist/deploy/cloudRun/cleanup.js +3 -1
  86. package/dist/deploy/cloudRun/cloudRunRevisions.js +3 -1
  87. package/dist/deploy/cloudRun/createJobs/cloudRunJobs.js +8 -5
  88. package/dist/deploy/cloudRun/createJobs/cloudRunServices.d.ts +2 -2
  89. package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +6 -3
  90. package/dist/deploy/cloudRun/createJobs/common.d.ts +3 -3
  91. package/dist/deploy/cloudRun/createJobs/common.js +3 -1
  92. package/dist/deploy/cloudRun/createJobs/constants.d.ts +1 -0
  93. package/dist/deploy/cloudRun/createJobs/constants.js +7 -0
  94. package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +10 -4
  95. package/dist/deploy/cloudRun/createJobs/getCloudRunStopScripts.js +3 -1
  96. package/dist/deploy/cloudRun/createJobs/index.js +25 -8
  97. package/dist/deploy/cloudRun/createJobs/volumes.js +3 -1
  98. package/dist/deploy/cloudRun/index.js +5 -3
  99. package/dist/deploy/cloudRun/utils/createArgsString.d.ts +2 -1
  100. package/dist/deploy/cloudRun/utils/createArgsString.js +3 -1
  101. package/dist/deploy/cloudRun/utils/database.js +13 -13
  102. package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.js +3 -1
  103. package/dist/deploy/cloudRun/utils/getServiceName.d.ts +1 -1
  104. package/dist/deploy/cloudRun/utils/getServiceName.js +3 -1
  105. package/dist/deploy/cloudRun/utils/jobName.d.ts +2 -1
  106. package/dist/deploy/cloudRun/utils/jobName.js +4 -2
  107. package/dist/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.js +3 -1
  108. package/dist/deploy/cloudSql/utils.d.ts +2 -1
  109. package/dist/deploy/cloudSql/utils.js +7 -2
  110. package/dist/deploy/custom/deployJob.js +3 -1
  111. package/dist/deploy/custom/index.js +3 -1
  112. package/dist/deploy/dockerTag/deployJob.js +3 -1
  113. package/dist/deploy/dockerTag/index.js +3 -1
  114. package/dist/deploy/index.d.ts +4 -3
  115. package/dist/deploy/index.js +13 -7
  116. package/dist/deploy/kubernetes/additionalSecretKeys.js +3 -1
  117. package/dist/deploy/kubernetes/cloudSql/index.d.ts +3 -2
  118. package/dist/deploy/kubernetes/cloudSql/index.js +6 -4
  119. package/dist/deploy/kubernetes/deployJob.js +22 -15
  120. package/dist/deploy/kubernetes/index.js +51 -14
  121. package/dist/deploy/kubernetes/kubeEnv.d.ts +3 -2
  122. package/dist/deploy/kubernetes/kubeEnv.js +7 -4
  123. package/dist/deploy/kubernetes/kubeValues.d.ts +2 -2
  124. package/dist/deploy/kubernetes/kubeValues.js +4 -5
  125. package/dist/deploy/kubernetes/mongodb.js +3 -1
  126. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +2 -1
  127. package/dist/deploy/kubernetes/processSecretsAsFiles.js +3 -1
  128. package/dist/deploy/sbom.js +3 -1
  129. package/dist/deploy/types/base.d.ts +8 -2
  130. package/dist/deploy/types/base.js +3 -1
  131. package/dist/deploy/types/custom.d.ts +1 -1
  132. package/dist/deploy/types/custom.js +3 -1
  133. package/dist/deploy/types/dockerTag.d.ts +1 -1
  134. package/dist/deploy/types/dockerTag.js +3 -1
  135. package/dist/deploy/types/googleCloudRun.d.ts +19 -18
  136. package/dist/deploy/types/googleCloudRun.js +3 -1
  137. package/dist/deploy/types/index.d.ts +6 -6
  138. package/dist/deploy/types/index.js +13 -7
  139. package/dist/deploy/types/kubernetes.d.ts +22 -22
  140. package/dist/deploy/types/kubernetes.js +3 -1
  141. package/dist/deploy/utils.js +3 -1
  142. package/dist/index.d.ts +3 -2
  143. package/dist/index.js +16 -9
  144. package/dist/packageInfos.d.ts +2 -0
  145. package/dist/packageInfos.js +14 -0
  146. package/dist/pipeline/createAllJobs.d.ts +13 -5
  147. package/dist/pipeline/createAllJobs.js +21 -10
  148. package/dist/pipeline/createChildPipeline.d.ts +1 -1
  149. package/dist/pipeline/createChildPipeline.js +24 -7
  150. package/dist/pipeline/createJobsForComponent.d.ts +3 -3
  151. package/dist/pipeline/createJobsForComponent.js +19 -18
  152. package/dist/pipeline/createMainPipeline.d.ts +3 -0
  153. package/dist/pipeline/createMainPipeline.js +248 -0
  154. package/dist/pipeline/generatePipelineFiles.d.ts +2 -0
  155. package/dist/pipeline/generatePipelineFiles.js +178 -0
  156. package/dist/pipeline/getPipelineStages.js +3 -1
  157. package/dist/pipeline/gitlab/createGitlabJobs.d.ts +15 -5
  158. package/dist/pipeline/gitlab/createGitlabJobs.js +98 -25
  159. package/dist/pipeline/gitlab/createGitlabPipeline.d.ts +7 -2
  160. package/dist/pipeline/gitlab/createGitlabPipeline.js +34 -17
  161. package/dist/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.d.ts +1 -0
  162. package/dist/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.js +29 -0
  163. package/dist/pipeline/gitlab/gitlabReleaseJobs.d.ts +33 -0
  164. package/dist/pipeline/gitlab/gitlabReleaseJobs.js +24 -0
  165. package/dist/pipeline/index.d.ts +3 -1
  166. package/dist/pipeline/index.js +16 -8
  167. package/dist/pipeline/packageManager.js +4 -2
  168. package/dist/pipeline/yarn/yarnUtils.js +6 -4
  169. package/dist/rules/index.d.ts +4 -1
  170. package/dist/rules/index.js +25 -18
  171. package/dist/runner/index.d.ts +1 -1
  172. package/dist/runner/index.js +3 -1
  173. package/dist/tsconfig.tsbuildinfo +1 -1
  174. package/dist/types/config.d.ts +18 -15
  175. package/dist/types/config.js +5 -2
  176. package/dist/types/context.d.ts +37 -32
  177. package/dist/types/context.js +3 -1
  178. package/dist/types/environmentContext.d.ts +11 -7
  179. package/dist/types/environmentContext.js +3 -1
  180. package/dist/types/gitlab-ci-yml.d.ts +30 -30
  181. package/dist/types/gitlab-ci-yml.js +3 -2
  182. package/dist/types/gitlab-types.d.ts +4 -6
  183. package/dist/types/gitlab-types.js +3 -1
  184. package/dist/types/index.js +13 -7
  185. package/dist/types/jobs.d.ts +23 -6
  186. package/dist/types/jobs.js +3 -1
  187. package/dist/types/pipeline.d.ts +4 -3
  188. package/dist/types/pipeline.js +3 -1
  189. package/dist/types/utils.d.ts +1 -1
  190. package/dist/types/utils.js +3 -1
  191. package/dist/utils/gitlab.js +3 -1
  192. package/dist/utils/index.d.ts +1 -1
  193. package/dist/utils/index.js +3 -1
  194. package/dist/utils/writeFiles.d.ts +7 -0
  195. package/dist/{pipeline/commitInfo/getBuildId.js → utils/writeFiles.js} +39 -22
  196. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +480 -384
  197. package/examples/__snapshots__/cloud-run-meteor-with-worker.ts.snap +462 -366
  198. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +480 -384
  199. package/examples/__snapshots__/cloud-run-no-service.ts.snap +501 -393
  200. package/examples/__snapshots__/cloud-run-non-public.ts.snap +480 -384
  201. package/examples/__snapshots__/cloud-run-post-stop-job.ts.snap +489 -392
  202. package/examples/__snapshots__/cloud-run-service-gen2.ts.snap +480 -384
  203. package/examples/__snapshots__/cloud-run-service-with-volumes.ts.snap +501 -401
  204. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +1155 -915
  205. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +1116 -888
  206. package/examples/__snapshots__/cloud-run-with-worker.ts.snap +482 -386
  207. package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +452 -356
  208. package/examples/__snapshots__/custom-build-job.ts.snap +434 -350
  209. package/examples/__snapshots__/custom-deploy.ts.snap +319 -223
  210. package/examples/__snapshots__/custom-envs.ts.snap +123 -81
  211. package/examples/__snapshots__/custom-sbom-java.ts.snap +434 -350
  212. package/examples/__snapshots__/kubernetes-application-customization.ts.snap +846 -969
  213. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +886 -957
  214. package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +894 -969
  215. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +1626 -1728
  216. package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +974 -1137
  217. package/examples/__snapshots__/local-dot-env.ts.snap +480 -384
  218. package/examples/__snapshots__/meteor-kubernetes.ts.snap +906 -1069
  219. package/examples/__snapshots__/multiline-var.ts.snap +4500 -0
  220. package/examples/__snapshots__/native-app.ts.snap +706 -578
  221. package/examples/__snapshots__/node-build-with-custom-image.ts.snap +480 -384
  222. package/examples/__snapshots__/node-build-with-docker-additions.ts.snap +488 -384
  223. package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1656 -1942
  224. package/examples/__snapshots__/wait-for-other-deploy.ts.snap +287 -231
  225. package/examples/__utils__/helpers.ts +2 -2
  226. package/examples/custom-deploy.ts +7 -7
  227. package/examples/multiline-var.ts +64 -0
  228. package/package.json +5 -8
  229. package/scripts/generate-gitlab-ci-types.ts +2 -2
  230. package/src/bash/BashExpression.ts +81 -0
  231. package/src/bash/bashExpressionPerPipelineType.ts +16 -0
  232. package/src/bash/bashYaml.ts +46 -0
  233. package/src/bash/getInjectVarsScript.ts +12 -0
  234. package/src/bash/replaceAsync.ts +50 -0
  235. package/src/build/base/__tests__/createArtifactsConfig.test.ts +3 -3
  236. package/src/build/base/createAppBuildJob.ts +8 -4
  237. package/src/build/base/createArtifactsConfig.ts +2 -2
  238. package/src/build/base/index.ts +1 -1
  239. package/src/build/base/writeBuildInfo.ts +1 -1
  240. package/src/build/base/writeDotEnv.ts +6 -1
  241. package/src/build/custom/__tests__/testJob.test.ts +1 -1
  242. package/src/build/custom/buildJob.ts +4 -6
  243. package/src/build/custom/testJob.ts +6 -5
  244. package/src/build/docker.ts +21 -13
  245. package/src/build/index.ts +1 -1
  246. package/src/build/node/buildJob.ts +3 -5
  247. package/src/build/node/cache.ts +4 -4
  248. package/src/build/node/meteor.ts +1 -1
  249. package/src/build/node/testJob.ts +6 -5
  250. package/src/build/node/yarn.ts +14 -9
  251. package/src/build/rails/test.ts +2 -1
  252. package/src/build/types.ts +8 -1
  253. package/src/catladder-gitlab.ts +8 -55
  254. package/src/config/configruedEnvs.ts +6 -6
  255. package/src/config/readConfig.ts +4 -5
  256. package/src/constants.ts +5 -2
  257. package/src/context/__tests__/resolveReferences.test.ts +11 -6
  258. package/src/context/getBuildInfoVariables.ts +40 -0
  259. package/src/context/getEnvConfig.ts +1 -1
  260. package/src/context/getEnvType.ts +1 -1
  261. package/src/context/getEnvironment.ts +7 -30
  262. package/src/context/getEnvironmentContext.ts +25 -29
  263. package/src/context/getEnvironmentVariables.ts +72 -47
  264. package/src/context/getReviewSlug.ts +27 -0
  265. package/src/context/index.ts +26 -25
  266. package/src/context/resolveReferences.ts +40 -17
  267. package/src/context/transformJobOnlyVars.ts +6 -3
  268. package/src/context/utils/envVars.ts +5 -4
  269. package/src/deploy/base/deploy.ts +25 -23
  270. package/src/deploy/base/index.ts +1 -1
  271. package/src/deploy/base/rollback.ts +9 -11
  272. package/src/deploy/base/stop.ts +9 -10
  273. package/src/deploy/cloudRun/artifactsRegistry.ts +13 -8
  274. package/src/deploy/cloudRun/cleanup.ts +3 -3
  275. package/src/deploy/cloudRun/cloudRunRevisions.ts +3 -3
  276. package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +22 -17
  277. package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +7 -6
  278. package/src/deploy/cloudRun/createJobs/common.ts +1 -1
  279. package/src/deploy/cloudRun/createJobs/constants.ts +1 -0
  280. package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +25 -7
  281. package/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.ts +1 -1
  282. package/src/deploy/cloudRun/createJobs/index.ts +18 -9
  283. package/src/deploy/cloudRun/createJobs/volumes.ts +2 -2
  284. package/src/deploy/cloudRun/index.ts +22 -10
  285. package/src/deploy/cloudRun/utils/createArgsString.ts +3 -2
  286. package/src/deploy/cloudRun/utils/database.ts +7 -7
  287. package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +1 -1
  288. package/src/deploy/cloudRun/utils/jobName.ts +7 -2
  289. package/src/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.ts +1 -1
  290. package/src/deploy/cloudSql/utils.ts +13 -10
  291. package/src/deploy/index.ts +5 -4
  292. package/src/deploy/kubernetes/cloudSql/index.ts +6 -5
  293. package/src/deploy/kubernetes/deployJob.ts +28 -14
  294. package/src/deploy/kubernetes/index.ts +15 -8
  295. package/src/deploy/kubernetes/kubeEnv.ts +9 -7
  296. package/src/deploy/kubernetes/kubeValues.ts +5 -6
  297. package/src/deploy/kubernetes/mongodb.ts +1 -1
  298. package/src/deploy/kubernetes/processSecretsAsFiles.ts +5 -4
  299. package/src/deploy/types/base.ts +6 -0
  300. package/src/deploy/types/googleCloudRun.ts +2 -0
  301. package/src/deploy/utils.ts +2 -2
  302. package/src/index.ts +2 -1
  303. package/src/packageInfos.ts +10 -0
  304. package/src/pipeline/createAllJobs.ts +28 -14
  305. package/src/pipeline/createChildPipeline.ts +20 -9
  306. package/src/pipeline/createJobsForComponent.ts +15 -23
  307. package/src/pipeline/createMainPipeline.ts +91 -0
  308. package/src/pipeline/generatePipelineFiles.ts +29 -0
  309. package/src/pipeline/getPipelineStages.ts +1 -1
  310. package/src/pipeline/gitlab/createGitlabJobs.ts +182 -59
  311. package/src/pipeline/gitlab/createGitlabPipeline.ts +16 -14
  312. package/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.ts +46 -0
  313. package/src/pipeline/gitlab/gitlabReleaseJobs.ts +20 -0
  314. package/src/pipeline/index.ts +2 -0
  315. package/src/pipeline/packageManager.ts +2 -2
  316. package/src/pipeline/yarn/yarnUtils.ts +7 -7
  317. package/src/rules/index.ts +15 -9
  318. package/src/types/config.ts +12 -3
  319. package/src/types/context.ts +39 -26
  320. package/src/types/environmentContext.ts +13 -7
  321. package/src/types/gitlab-ci-yml.ts +0 -1
  322. package/src/types/gitlab-types.ts +5 -4
  323. package/src/types/jobs.ts +29 -4
  324. package/src/types/pipeline.ts +4 -0
  325. package/src/types/utils.ts +4 -4
  326. package/src/utils/gitlab.ts +1 -1
  327. package/src/utils/index.ts +2 -2
  328. package/src/utils/writeFiles.ts +40 -0
  329. package/dist/deploy/cloudRun/createJobs/variables.d.ts +0 -5
  330. package/dist/deploy/cloudRun/createJobs/variables.js +0 -19
  331. package/dist/pipeline/commitInfo/getBuildId.d.ts +0 -6
  332. package/dist/pipeline/commitInfo/getCommitInfo.d.ts +0 -2
  333. package/src/deploy/cloudRun/createJobs/variables.ts +0 -21
  334. package/src/pipeline/commitInfo/getBuildId.ts +0 -17
  335. package/src/pipeline/commitInfo/getCommitInfo.ts +0 -15
@@ -1,17 +1,29 @@
1
1
  import { getAllEnvsByTrigger } from "../config";
2
- import type { Config, PipelineTrigger } from "../types";
3
- import type { CatladderJob } from "../types/jobs";
2
+ import type {
3
+ CatladderJobWithContext,
4
+ Config,
5
+ PipelineTrigger,
6
+ PipelineType,
7
+ } from "../types";
4
8
  import { createJobsForComponent } from "./createJobsForComponent";
5
9
 
6
10
  export type AllCatladderJobs = {
7
11
  [componentName: string]: {
8
- [env: string]: Array<CatladderJob>;
12
+ [env: string]: Array<CatladderJobWithContext>;
9
13
  };
10
14
  };
11
- export const createAllJobs = async (
12
- config: Config,
13
- trigger: PipelineTrigger
14
- ): Promise<AllCatladderJobs> => {
15
+
16
+ export type AllJobsContext = {
17
+ config: Config;
18
+ trigger: PipelineTrigger;
19
+ pipelineType: PipelineType;
20
+ };
21
+
22
+ export const createAllJobs = async ({
23
+ config,
24
+ trigger,
25
+ pipelineType,
26
+ }: AllJobsContext): Promise<AllCatladderJobs> => {
15
27
  return Object.fromEntries(
16
28
  await Promise.all(
17
29
  Object.keys(config.components).map(async (componentName) => {
@@ -22,17 +34,19 @@ export const createAllJobs = async (
22
34
  await Promise.all(
23
35
  envs.map(async (env) => [
24
36
  env,
25
- await createJobsForComponent(
37
+
38
+ await createJobsForComponent({
26
39
  config,
27
40
  componentName,
28
41
  env,
29
- trigger
30
- ),
31
- ])
32
- )
42
+ trigger,
43
+ pipelineType,
44
+ }),
45
+ ]),
46
+ ),
33
47
  ),
34
48
  ];
35
- })
36
- )
49
+ }),
50
+ ),
37
51
  );
38
52
  };
@@ -1,24 +1,35 @@
1
+ import { RULES_ALWAYS } from "../rules";
2
+
1
3
  import type { Pipeline, PipelineType } from "../types";
2
4
  import type { Config, PipelineTrigger } from "../types/config";
3
5
  import { createAllJobs } from "./createAllJobs";
4
6
  import { getPipelineStages } from "./getPipelineStages";
5
7
  import { createGitlabJobs } from "./gitlab/createGitlabJobs";
6
- import { createGitlabPipelineFromStagesAndJobs } from "./gitlab/createGitlabPipeline";
8
+ import { createGitlabPipelineWithDefaults } from "./gitlab/createGitlabPipeline";
7
9
 
8
10
  export const createChildPipeline = async <T extends PipelineType>(
9
- type: T,
11
+ pipelineType: T,
10
12
  trigger: PipelineTrigger,
11
- config: Config
13
+ config: Config,
12
14
  ): Promise<Pipeline<T>> => {
13
- const jobs = await createAllJobs(config, trigger);
15
+ const jobs = await createAllJobs({
16
+ config,
17
+ trigger,
18
+ pipelineType,
19
+ });
14
20
  const stages = getPipelineStages(config);
15
21
 
16
- if (type === "gitlab") {
22
+ if (pipelineType === "gitlab") {
17
23
  const gitlabJobs = await createGitlabJobs(jobs);
18
- return createGitlabPipelineFromStagesAndJobs(
24
+ return createGitlabPipelineWithDefaults({
25
+ workflow: {
26
+ rules: RULES_ALWAYS,
27
+ },
19
28
  stages,
20
- gitlabJobs
21
- ) as Pipeline<T>;
29
+ jobs: Object.fromEntries(
30
+ gitlabJobs.map(({ gitlabJob, name }) => [name, gitlabJob]),
31
+ ),
32
+ }) as Pipeline<T>;
22
33
  }
23
- throw new Error(`${type} is not supported`);
34
+ throw new Error(`${pipelineType} is not supported`);
24
35
  };
@@ -1,16 +1,15 @@
1
1
  import { isFunction } from "lodash";
2
2
  import { BUILD_TYPES } from "../build";
3
+ import type { CreateContextContext } from "../context";
3
4
  import { createContext } from "../context";
4
5
  import { DEPLOY_TYPES } from "../deploy";
5
- import type { Config, PipelineTrigger } from "../types/config";
6
- import type { CommitInfo, Context } from "../types/context";
6
+ import type { CatladderJobWithContext, Context } from "../types/context";
7
7
  import type { CatladderJob } from "../types/jobs";
8
- import { getBaseCommitInfo } from "./commitInfo/getCommitInfo";
9
8
  import { getPackageManagerInfo } from "./packageManager";
10
9
 
11
10
  const injectDefaultVarsInCustomJobs = (
12
11
  context: Context,
13
- jobs: CatladderJob[]
12
+ jobs: CatladderJob[],
14
13
  ) =>
15
14
  jobs.map(({ variables, ...job }) => ({
16
15
  variables: {
@@ -39,25 +38,18 @@ const createRawJobs = (context: Context): CatladderJob[] => {
39
38
  const customJobs = getCustomJobs(context);
40
39
  return [...buildJobs, ...deployJobs, ...customJobs];
41
40
  };
42
- export const createJobsForComponent = async (
43
- config: Config,
44
- componentName: string,
45
- env: string,
46
- trigger: PipelineTrigger
47
- ): Promise<Array<CatladderJob>> => {
48
- const commitInfo: CommitInfo = {
49
- ...(await getBaseCommitInfo()),
50
- trigger,
51
- };
52
-
53
- const packageManagerInfo = await getPackageManagerInfo(config, componentName);
54
41
 
55
- const context = await createContext(
56
- config,
57
- componentName,
58
- env,
59
- commitInfo,
60
- packageManagerInfo
42
+ export const createJobsForComponent = async (
43
+ contextContext: Omit<CreateContextContext, "packageManagerInfo">,
44
+ ): Promise<Array<CatladderJobWithContext>> => {
45
+ const packageManagerInfo = await getPackageManagerInfo(
46
+ contextContext.config,
47
+ contextContext.componentName,
61
48
  );
62
- return createRawJobs(context);
49
+
50
+ const context = await createContext({
51
+ ...contextContext,
52
+ packageManagerInfo,
53
+ });
54
+ return createRawJobs(context).map((job) => ({ ...job, context }));
63
55
  };
@@ -0,0 +1,91 @@
1
+ import {
2
+ RULE_IS_MAIN_BRANCH,
3
+ RULE_IS_MERGE_REQUEST,
4
+ RULE_IS_TAGGED_RELEASE,
5
+ RULE_NEVER_ON_RELEASE_COMMIT,
6
+ } from "../rules";
7
+ import type {
8
+ GitlabJobDef,
9
+ GitlabRule,
10
+ Pipeline,
11
+ PipelineTrigger,
12
+ PipelineType,
13
+ } from "../types";
14
+ import { ALL_PIPELINE_TRIGGERS, type Config } from "../types/config";
15
+ import { createAllJobs } from "./createAllJobs";
16
+ import { getPipelineStages } from "./getPipelineStages";
17
+ import { createGitlabJobs } from "./gitlab/createGitlabJobs";
18
+ import { createGitlabPipelineWithDefaults } from "./gitlab/createGitlabPipeline";
19
+ import { getGitlabReleaseJobs } from "./gitlab/gitlabReleaseJobs";
20
+
21
+ export const createMainPipeline = async <T extends PipelineType>(
22
+ pipelineType: T,
23
+ config: Config,
24
+ ): Promise<Pipeline<T>> => {
25
+ const stages = getPipelineStages(config);
26
+
27
+ if (pipelineType === "gitlab") {
28
+ // for all triggers create jobs and add base rules
29
+
30
+ const allJobsPerTrigger = await Promise.all(
31
+ ALL_PIPELINE_TRIGGERS.map(
32
+ async (trigger) =>
33
+ await createGitlabJobs(
34
+ await createAllJobs({ config, trigger, pipelineType }),
35
+ getGitlabRulesForTrigger(trigger),
36
+ ),
37
+ ),
38
+ );
39
+
40
+ const allJobs = allJobsPerTrigger
41
+ .flat()
42
+ // sort by componentName in the same order as they appear in the config
43
+ // this is purely for better readability in git diffs when you add new components
44
+ .sort((a, b) => {
45
+ const componentNames = Object.keys(config.components);
46
+ const aIndex = componentNames.findIndex((c) => c === a.componentName);
47
+ const bIndex = componentNames.findIndex((c) => c === b.componentName);
48
+ return aIndex - bIndex;
49
+ })
50
+
51
+ .reduce(
52
+ (acc, { gitlabJob, name }) => {
53
+ // merge jobs, if a job is already there, merge the rules
54
+ // this is currently needed because of envMode: "none", which creates the same job for all triggers, so it can appear multiple times
55
+ if (acc[name]) {
56
+ acc[name].rules = [
57
+ ...(acc[name].rules ?? []),
58
+ ...(gitlabJob.rules ?? []),
59
+ ];
60
+ } else {
61
+ acc[name] = gitlabJob;
62
+ }
63
+
64
+ return acc;
65
+ },
66
+ {} as { [key: string]: GitlabJobDef },
67
+ );
68
+
69
+ return createGitlabPipelineWithDefaults({
70
+ stages: [...stages, "release"],
71
+ jobs: {
72
+ ...allJobs,
73
+ ...getGitlabReleaseJobs(),
74
+ },
75
+ }) as Pipeline<T>;
76
+ }
77
+ throw new Error(`${pipelineType} is not supported`);
78
+ };
79
+ function getGitlabRulesForTrigger(trigger: PipelineTrigger): GitlabRule[] {
80
+ // mainBranch: on push to main branch
81
+ // mr: on merge request
82
+ // taggedRelease: on tag
83
+ switch (trigger) {
84
+ case "mainBranch":
85
+ return [RULE_NEVER_ON_RELEASE_COMMIT, RULE_IS_MAIN_BRANCH];
86
+ case "mr":
87
+ return [RULE_IS_MERGE_REQUEST];
88
+ case "taggedRelease":
89
+ return [RULE_IS_TAGGED_RELEASE];
90
+ }
91
+ }
@@ -0,0 +1,29 @@
1
+ import type { Config, PipelineMode, PipelineType } from "../types";
2
+ import { writeYamlfile } from "../utils/writeFiles";
3
+ import { createChildPipeline } from "./createChildPipeline";
4
+ import { createMainPipeline } from "./createMainPipeline";
5
+ import { getPipelineTriggerForGitlabChildPipeline } from "./gitlab/getPipelineTriggerForGitlabChildPipeline";
6
+ export async function generatePipelineFiles<T extends PipelineType>(
7
+ config: Config,
8
+ pipelineType: T,
9
+ mode: PipelineMode<T>,
10
+ ) {
11
+ if (mode === "childpipeline") {
12
+ const trigger = getPipelineTriggerForGitlabChildPipeline();
13
+
14
+ const { jobs, ...mainPipeline } = await createChildPipeline(
15
+ pipelineType,
16
+ trigger,
17
+ config,
18
+ );
19
+ // need to spread out the jobs, forgot why
20
+ await writeYamlfile(`__pipeline.yml`, { ...jobs, ...mainPipeline });
21
+ } else {
22
+ const { jobs, ...mainPipeline } = await createMainPipeline(
23
+ pipelineType,
24
+ config,
25
+ );
26
+ // need to spread out the jobs, forgot why
27
+ await writeYamlfile(`.gitlab-ci.yml`, { ...jobs, ...mainPipeline });
28
+ }
29
+ }
@@ -16,7 +16,7 @@ export function getPipelineStages(config: Config) {
16
16
  baseStage,
17
17
  ...allEnvs.map((e) => `${baseStage} ${e}`),
18
18
  ],
19
- []
19
+ [],
20
20
  );
21
21
  return stages;
22
22
  }
@@ -1,20 +1,33 @@
1
- import { isObject } from "lodash";
1
+ import { isObject, merge } from "lodash";
2
+ import { getInjectVarsScript } from "../../bash/getInjectVarsScript";
2
3
  import { BASE_RETRY } from "../../defaults";
3
- import type { GitlabJobDef } from "../../types";
4
+ import type {
5
+ CatladderJobWithContext,
6
+ Context,
7
+ GitlabJobDef,
8
+ GitlabRule,
9
+ } from "../../types";
4
10
  import type { CatladderJob, CatladderJobNeed } from "../../types/jobs";
5
- import type { AllCatladderJobs } from "../createAllJobs";
6
11
  import { notNil } from "../../utils";
12
+ import { collapseableSection } from "../../utils/gitlab";
13
+ import type { AllCatladderJobs } from "../createAllJobs";
7
14
 
8
- export type AllGitlabJobs = Record<string, GitlabJobDef>;
15
+ export type AllGitlabJobs = {
16
+ name: string;
17
+ gitlabJob: GitlabJobDef;
18
+ componentName: string;
19
+ env: string;
20
+ }[];
9
21
 
10
- const removeUndefined = <T extends Record<string, unknown>>(obj: T): T =>
22
+ export const GITLAB_ENVIRONMENT_URL_VARIABLE = "CL_GITLAB_ENVIRONMENT_URL";
23
+ const removeUndefined = (obj: GitlabJobDef): GitlabJobDef =>
11
24
  Object.fromEntries(
12
- Object.entries(obj).filter(([, value]) => value !== undefined)
13
- ) as T;
25
+ Object.entries(obj).filter(([, value]) => value !== undefined),
26
+ ) as GitlabJobDef;
14
27
  const getFullJobName = (
15
28
  name: string,
16
29
  componentName: string,
17
- env?: string | null
30
+ env?: string | null,
18
31
  ) => {
19
32
  if (env) {
20
33
  return `${componentName} ${name} | ${env} `;
@@ -26,14 +39,14 @@ const getFullReferencedJobName = (
26
39
  referencedJobName: string,
27
40
  componentName: string,
28
41
  env: string,
29
- allJobs: AllCatladderJobs
42
+ allJobs: AllCatladderJobs,
30
43
  ) => {
31
44
  const referencedJob = allJobs[componentName]?.[env]?.find(
32
- (j) => j.name === referencedJobName
45
+ (j) => j.name === referencedJobName,
33
46
  );
34
47
  if (!referencedJob) {
35
48
  throw new Error(
36
- `unknown job referenced: '${referencedJobName}' from '${env}:${componentName}'`
49
+ `unknown job referenced: '${referencedJobName}' from '${env}:${componentName}'`,
37
50
  );
38
51
  }
39
52
  const envToSet = referencedJob.envMode !== "none" ? env : null;
@@ -47,6 +60,7 @@ export const makeGitlabJob = (
47
60
  componentName: string,
48
61
  env: string,
49
62
  {
63
+ environment,
50
64
  envMode,
51
65
  needsStages,
52
66
  needsOtherComponent,
@@ -54,9 +68,14 @@ export const makeGitlabJob = (
54
68
  needs,
55
69
  jobTags,
56
70
  script,
71
+ context,
72
+ variables,
73
+ runnerVariables,
74
+ when,
57
75
  ...job
58
- }: CatladderJob<string>,
59
- allJobs: AllCatladderJobs
76
+ }: CatladderJobWithContext<string>,
77
+ allJobs: AllCatladderJobs,
78
+ baseRules?: GitlabRule[],
60
79
  ): [fullName: string, job: GitlabJobDef] => {
61
80
  const stage = envMode === "stagePerEnv" ? `${job.stage} ${env}` : job.stage;
62
81
 
@@ -88,11 +107,11 @@ export const makeGitlabJob = (
88
107
  n.job,
89
108
  n.componentName ?? componentName,
90
109
  env,
91
- allJobs
110
+ allJobs,
92
111
  ),
93
112
  artifacts: n.artifacts,
94
113
  }
95
- : getFullReferencedJobName(n, componentName, env, allJobs)
114
+ : getFullReferencedJobName(n, componentName, env, allJobs),
96
115
  ) // sort in a predictable manner for snapshot tests
97
116
  .sort((a, b) => getJobName(a).localeCompare(getJobName(b)));
98
117
 
@@ -103,60 +122,164 @@ export const makeGitlabJob = (
103
122
  const fullJobName = getFullJobName(
104
123
  name,
105
124
  componentName,
106
- envMode !== "none" ? env : undefined
125
+ envMode !== "none" ? env : undefined,
107
126
  );
108
127
 
109
- const gitlabJob: GitlabJobDef = removeUndefined({
110
- ...job,
111
- script: script?.filter(notNil),
112
- tags: jobTags,
113
- stage,
114
- environment: job.environment?.on_stop
115
- ? {
116
- ...job.environment,
117
- on_stop: getFullReferencedJobName(
118
- job.environment.on_stop,
119
- componentName,
120
- env,
121
- allJobs
122
- ),
123
- }
124
- : job.environment,
125
- // sort in a predictable manner for snapshot tests
126
- needs: deduplicatedGitlabNeeds,
127
- retry: BASE_RETRY,
128
- interruptible: true,
129
- });
128
+ // backwards compatibility, some may still use KUBERNETES_CPU_REQUEST, KUBERNETES_MEMORY_REQUEST, etc. in variables.
129
+ // those should now be set in the runnerVariables as they don't work in the variables key of the catladder job, becuase those get injected
130
+ const PIPELINE_RUNNER_VARIABLES = [
131
+ "KUBERNETES_CPU_REQUEST",
132
+ "KUBERNETES_MEMORY_REQUEST",
133
+ "KUBERNETES_CPU_LIMIT",
134
+ "KUBERNETES_MEMORY_LIMIT",
135
+ ];
136
+ // remove those from variables and add them to runnerVariables
137
+
138
+ const varsInjectScripts = collapseableSection(
139
+ "injectvars",
140
+ "Injecting variables",
141
+ )([
142
+ ...getInjectVarsScript(
143
+ // remove legacy variables
144
+ Object.fromEntries(
145
+ Object.entries(variables ?? {}).filter(
146
+ ([key]) => !PIPELINE_RUNNER_VARIABLES.includes(key),
147
+ ),
148
+ ),
149
+ ),
150
+ ]);
151
+
152
+ const legacyRunnerVariables = Object.fromEntries(
153
+ Object.entries(variables ?? {}).filter(([key]) =>
154
+ PIPELINE_RUNNER_VARIABLES.includes(key),
155
+ ),
156
+ );
157
+
158
+ if (Object.keys(legacyRunnerVariables).length > 0) {
159
+ console.warn(
160
+ `Legacy variables detected in ${fullJobName}: ${Object.keys(
161
+ legacyRunnerVariables,
162
+ ).join(", ")}. Please move them to the runnerVariables key.`,
163
+ );
164
+ }
165
+ const rules = [
166
+ ...(job.rules ?? []),
167
+ ...(baseRules
168
+ ? baseRules.map((rule) => ({
169
+ when: when,
170
+ ...rule,
171
+ }))
172
+ : when
173
+ ? [{ when }]
174
+ : []),
175
+ ];
176
+ const modified = addGitlabEnvironment(
177
+ context,
178
+ environment,
179
+ {
180
+ ...job,
181
+ rules: rules.length > 0 ? rules : undefined,
182
+ variables: {
183
+ ...legacyRunnerVariables,
184
+ ...runnerVariables,
185
+ },
186
+ script: [...varsInjectScripts, ...(script?.filter(notNil) ?? [])],
187
+ tags: jobTags,
188
+ stage,
189
+
190
+ // sort in a predictable manner for snapshot tests
191
+ needs: deduplicatedGitlabNeeds,
192
+ retry: BASE_RETRY,
193
+ interruptible: true,
194
+ },
195
+ componentName,
196
+ env,
197
+ allJobs,
198
+ );
199
+
200
+ const gitlabJob: GitlabJobDef = removeUndefined(modified);
130
201
 
131
202
  return [fullJobName, gitlabJob];
132
203
  };
133
204
 
205
+ const addGitlabEnvironment = (
206
+ context: Context,
207
+ environment: CatladderJob["environment"],
208
+ job: GitlabJobDef,
209
+ componentName: string,
210
+ env: string, // TODO: we could actually pull this from contxt
211
+ allJobs: AllCatladderJobs,
212
+ ): GitlabJobDef => {
213
+ if (!environment) {
214
+ return job;
215
+ }
216
+ const { url, envType } = context.environment;
217
+ const { on_stop, ...restEnvironment } = environment;
218
+ // those can be dynamic, so we therefore have to do this: https://docs.gitlab.com/ee/ci/environments/#set-a-dynamic-environment-url
219
+
220
+ const dotEnvFile = "gitlab_environment.env";
221
+
222
+ const scriptToAdd = [
223
+ `echo "${GITLAB_ENVIRONMENT_URL_VARIABLE}=${url}" >> ${dotEnvFile}`,
224
+ ];
225
+
226
+ // this is NOT a bashVariable since it NEEDS to be used as a string in gitlab
227
+ const gitlabEnvironmentName =
228
+ envType === "review"
229
+ ? `${env}/$CI_COMMIT_REF_NAME/${componentName}` // FIXME: should be replaced with mr name as well
230
+ : `${env}/${componentName}`;
231
+
232
+ return {
233
+ ...job,
234
+ environment: {
235
+ name: gitlabEnvironmentName,
236
+ url: `$${GITLAB_ENVIRONMENT_URL_VARIABLE}`,
237
+ ...(on_stop
238
+ ? {
239
+ on_stop: getFullReferencedJobName(
240
+ on_stop,
241
+ componentName,
242
+ env,
243
+ allJobs,
244
+ ),
245
+ }
246
+ : {}),
247
+ ...restEnvironment,
248
+ },
249
+ artifacts: merge(job.artifacts ?? {}, {
250
+ reports: {
251
+ dotenv: `${dotEnvFile}`,
252
+ },
253
+ }),
254
+
255
+ script: [...(job.script ?? []), ...scriptToAdd],
256
+ };
257
+ };
258
+
134
259
  export const createGitlabJobs = async (
135
- allJobs: AllCatladderJobs
260
+ allJobs: AllCatladderJobs,
261
+ baseRules?: GitlabRule[],
136
262
  ): Promise<AllGitlabJobs> => {
137
- return Object.keys(allJobs).reduce((accForComponents, componentName) => {
263
+ return Object.keys(allJobs).flatMap((componentName) => {
138
264
  const componentJobs = allJobs[componentName];
139
- return {
140
- ...accForComponents,
141
- ...Object.keys(componentJobs).reduce((accForEnvs, env) => {
142
- const jobs = componentJobs[env];
265
+ return Object.keys(componentJobs).flatMap((env) => {
266
+ const jobs = componentJobs[env];
143
267
 
268
+ return jobs.flatMap((job) => {
269
+ const [fullJobName, gitlabJob] = makeGitlabJob(
270
+ componentName,
271
+ env,
272
+ job,
273
+ allJobs,
274
+ baseRules,
275
+ );
144
276
  return {
145
- ...accForEnvs,
146
- ...jobs.reduce((accForJobs, job) => {
147
- const [fullJobName, gitlabJob] = makeGitlabJob(
148
- componentName,
149
- env,
150
- job,
151
- allJobs
152
- );
153
- return {
154
- ...accForJobs,
155
- [fullJobName]: gitlabJob,
156
- };
157
- }, {} as AllGitlabJobs),
277
+ name: fullJobName,
278
+ gitlabJob,
279
+ componentName,
280
+ env,
158
281
  };
159
- }, {} as AllGitlabJobs),
160
- };
161
- }, {} as AllGitlabJobs);
282
+ });
283
+ });
284
+ });
162
285
  };
@@ -1,22 +1,24 @@
1
- import { RULES_ALWAYS } from "../../rules";
2
1
  import { getRunnerImage } from "../../runner";
3
2
  import type { Pipeline } from "../../types";
4
- import type { AllGitlabJobs } from "./createGitlabJobs";
5
3
 
6
- export function createGitlabPipelineFromStagesAndJobs(
7
- stages: string[],
8
- gitlabJobs: AllGitlabJobs
9
- ): Pipeline<"gitlab"> {
4
+ type PickRequired<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
5
+
6
+ export const createGitlabPipelineWithDefaults = ({
7
+ image,
8
+ variables,
9
+ ...config
10
+ }: PickRequired<
11
+ Partial<Pipeline<"gitlab">>,
12
+ "stages" | "jobs"
13
+ >): Pipeline<"gitlab"> => {
10
14
  return {
11
- image: getRunnerImage("jobs-default"), // default image
15
+ image: image ?? getRunnerImage("jobs-default"), // default image
12
16
  variables: {
13
17
  FF_USE_FASTZIP: "true",
14
- GIT_DEPTH: 1, // no need the full depth
15
- },
16
- workflow: {
17
- rules: RULES_ALWAYS,
18
+ GIT_DEPTH: "1", // no need the full depth
19
+ ...(variables ?? {}),
18
20
  },
19
- stages,
20
- jobs: gitlabJobs,
21
+
22
+ ...config,
21
23
  };
22
- }
24
+ };
@@ -0,0 +1,46 @@
1
+ import type { PipelineTrigger } from "../..";
2
+ import { PIPELINE_IMAGE_TAG } from "../../constants";
3
+
4
+ export function getPipelineTriggerForGitlabChildPipeline() {
5
+ const {
6
+ CI_MERGE_REQUEST_ID,
7
+ CI_COMMIT_TAG,
8
+ CI_COMMIT_BRANCH,
9
+ CI_DEFAULT_BRANCH,
10
+ } = process.env;
11
+
12
+ const isDefaultBranch =
13
+ Boolean(CI_DEFAULT_BRANCH) && CI_COMMIT_BRANCH === CI_DEFAULT_BRANCH;
14
+ const isHotfixBranch = CI_COMMIT_BRANCH
15
+ ? /^[0-9]+\.([0-9]+|x)\.x$/.test(CI_COMMIT_BRANCH)
16
+ : false;
17
+ const isMergeRequest = Boolean(CI_MERGE_REQUEST_ID);
18
+ const isTaggedRelease = Boolean(CI_COMMIT_TAG);
19
+
20
+ console.info(`catladder version ${PIPELINE_IMAGE_TAG}`);
21
+
22
+ const trigger: PipelineTrigger | null =
23
+ isMergeRequest || isHotfixBranch
24
+ ? "mr"
25
+ : isDefaultBranch
26
+ ? "mainBranch"
27
+ : isTaggedRelease
28
+ ? "taggedRelease"
29
+ : null;
30
+
31
+ if (!trigger) {
32
+ throw new Error(
33
+ "no matching trigger: " +
34
+ JSON.stringify(
35
+ {
36
+ isMergeRequest,
37
+ isDefaultBranch,
38
+ isTaggedRelease,
39
+ },
40
+ null,
41
+ 2,
42
+ ),
43
+ );
44
+ }
45
+ return trigger;
46
+ }