freeleaps-ops/first-class-pipeline/tests/Jenkinsfile
2025-02-07 18:06:20 +08:00

130 lines
6.8 KiB
Groovy

library 'first-class-pipeline'
executeFreeleapsPipeline {
// serviceName is the name of the service, which is used to identify the service
serviceName = 'gitops-mvp-app'
// serviceSlug used to identify the service environment
environmentSlug = 'alpha'
// serviceGitBranch used to specify the git repo branch of the service codes
serviceGitBranch = 'master'
// serviceGitRepo used to specify the git repo of the service codes
serviceGitRepo = "https://zhenyus@dev.azure.com/zhenyus/gitops-mvp-app/_git/gitops-mvp-app"
// serviceGitRepoType used to specify the git repo type of the service codes
// monorepo: all services codes are in the same repo and using sub-folders to separate them
// separated: each service has its own repo
serviceGitRepoType = 'monorepo' // monorepo, separated
// serviceGitCredentialsId used to specify the git credentials id of the service codes
// the credentials should be stored in Jenkins
serviceGitCredentialsId = 'gitops-mvp-app-azure-devops'
// executeMode used to specify the pipeline execution mode
// on-demand: the pipeline will be triggered with code changes, only changed components will be executed
// fully: the pipeline will be triggered without code changes, all components will be executed
executeMode = 'fully' // on-demand, fully
// commitMessageLintEnabled used to specify whether to enable commit message lint
commitMessageLintEnabled = true
// components used to specify the service components
components = [
[
// name is the name of the component, which is used to identify the component
name: 'frontend',
// root is the root folder of the component codes
root: 'frontend',
// language is the programming language of the component codes
language: 'javascript',
// dependenciesManager used to specify which dependencies manager to use
dependenciesManager: 'npm',
// npmPackageJsonFile used to specify the npm package.json file path when dependenciesManager set to npm
npmPackageJsonFile: 'package.json',
// buildCacheEnabled used to specify whether to enable build dependencies cache
buildCacheEnabled: true,
// buildAgentImage used to specify the build environment container image
buildAgentImage: 'node:lts',
// buildCommand used to specify the build command of the component
buildCommand: 'npm run build',
// buildArtifacts used to specify the build artifacts that needs to be stores and shares between components
buildArtifacts: ['dist'],
// lintEnabled used to specify whether to enable code lint
lintEnabled: true,
// linter used to specify the code linter
linter: 'eslint',
// eslintVersion used to specify the eslint version
eslintVersion: '7.32.0',
// eslintPlugins used to specify the eslint plugins
eslintPlugins: ['eslint-plugin-vue@8.0.3', '@typescript-eslint/parser@4.33.0', '@typescript-eslint/eslint-plugin@4.33.0'],
// linterConfig used to specify the code linter configuration file path, if not set, will use the default configuration
// linterConfig: '.eslintrc.js',
// sastEnabled used to specify whether to enable SAST scan
sastEnabled: false,
// sastScanner used to specify the SAST scanner
// FIXME: JS has no production-ready SAST scanner yet
// sastScanner: '',
// imageRegistry used to specify the which registry to push the image
imageRegistry: 'docker.io',
// imageRepository used to specify the image repository
imageRepository: 'sunzhenyucn',
// imageName used to specify the image name
imageName: 'gitops-mvp-app-frontend',
// imageBuilder used to specify the image builder
// dind: using docker-in-docker to build the image
// kaniko: using Kaniko to build the image
imageBuilder: 'dind',
// dockerfilePath used to specify the Dockerfile path
dockerfilePath: 'Dockerfile',
// imageBuildRoot used to specify the image build context root
imageBuildRoot: '.',
// imageReleaseArchitectures used to specify the released image architectures
imageReleaseArchitectures: ['linux/amd64', 'linux/arm64'],
// registryCredentialName used to specify the registry credential that stored in Freeleaps Kubernetes Cluster
registryCredentialName: 'gitops-mvp-app-secret',
// semanticReleaseEnabled used to specify whether to enable semantic release
semanticReleaseEnabled: true
],
[
// name is the name of the component, which is used to identify the component
name: 'backend',
// root is the root folder of the component codes
root: 'backend',
// language is the programming language of the component codes
language: 'python',
// dependenciesManager used to specify which dependencies manager to use
dependenciesManager: 'pip',
// buildAgentImage used to specify the build environment container image
buildAgentImage: 'python:3.8-slim-buster',
// buildArtifacts used to specify the build artifacts that needs to be stores and shares between components
buildArtifacts: ['.'],
// buildCacheEnabled used to specify whether to enable build dependencies cache
buildCacheEnabled: true,
// buildCommand used to specify the build command of the component
lintEnabled: true,
// linter used to specify the code linter
linter: 'pylint',
// linterConfig used to specify the code linter configuration file path, if not set, will use the default configuration
// linterConfig: '.pylintrc',
// sastEnabled used to specify whether to enable SAST scan
sastEnabled: true,
// sastScanner used to specify the SAST scanner
// FIXME: Python has no production-ready SAST scanner yet
sastScanner: 'bandit',
// imageRegistry used to specify the which registry to push the image
imageRegistry: 'docker.io',
// imageRepository used to specify the image repository
imageRepository: 'sunzhenyucn',
// imageName used to specify the image name
imageName: 'gitops-mvp-app-backend',
// imageBuilder used to specify the image builder
// dind: using docker-in-docker to build the image
// kaniko: using Kaniko to build the image
imageBuilder: 'dind',
// dockerfilePath used to specify the Dockerfile path
dockerfilePath: 'Dockerfile',
// imageBuildRoot used to specify the image build context root
imageBuildRoot: '.',
// imageReleaseArchitectures used to specify the released image architectures
imageReleaseArchitectures: ['linux/amd64', 'linux/arm64'],
// registryCredentialName used to specify the registry credential that stored in Freeleaps Kubernetes Cluster
registryCredentialName: 'gitops-mvp-app-secret',
// semanticReleaseEnabled used to specify whether to enable semantic release
semanticReleaseEnabled: true
]
]
}