@toptal/davinci-ci 6.0.1-alpha-fx-4497-storybook-13e9f909.10 → 7.0.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.
@@ -1,159 +0,0 @@
1
- @Library('globalLibrary@master') _
2
-
3
- helmVersion = '3'
4
- sentryOrg = 'toptal'
5
-
6
- def hasCommandInDavinci(args) {
7
- def command = args.command
8
- def repoName = args.repoName
9
- def tag = args.tag
10
-
11
- def davinciHelpOutput = sh(
12
- script: """
13
- docker run \
14
- --rm \
15
- -u 469:469 \
16
- us-central1-docker.pkg.dev/toptal-hub/containers/${repoName}:${tag} \
17
- yarn davinci help
18
- """,
19
- returnStdout: true
20
- ).trim() as String
21
-
22
- return davinciHelpOutput.contains(command)
23
- }
24
-
25
- pipeline {
26
- agent { label 'docker' }
27
-
28
- options {
29
- ansiColor('xterm')
30
- timestamps()
31
- timeout(time: 1, unit: 'HOURS')
32
- buildDiscarder(logRotator(numToKeepStr: '20'))
33
- skipDefaultCheckout()
34
- }
35
-
36
- parameters {
37
- string(name: 'HELM_BRANCH', defaultValue: 'master', description: 'Helm branch')
38
- string(name: 'REPOSITORY_NAME', defaultValue: '', description: 'Name of repository')
39
- string(name: 'TAG', defaultValue: '', description: 'Image tag to deploy')
40
- string(name: 'RELEASE', defaultValue: 'internal', description: 'Release name')
41
- string(name: 'ENV', defaultValue: 'ENV=null', description: 'Environment values in format ENV.key1=value1,ENV.key2=value2')
42
- }
43
-
44
- environment {
45
- SENTRY_AUTH_TOKEN = credentials('sentry_auth_token')
46
- }
47
-
48
- stages {
49
- stage('Check params') {
50
- steps {
51
- script {
52
- if (
53
- (params.REPOSITORY_NAME == "") ||
54
- (params.TAG == "") ||
55
- (params.RELEASE == "")
56
- ) {
57
- error("== REPOSITORY_NAME, TAG and RELEASE are mandatory parameters ==")
58
- }
59
- }
60
- }
61
- } //stage
62
-
63
- stage('Deploy with Helm') {
64
- agent { docker { image "gcr.io/toptal-hub/helm:${helmVersion}" } }
65
-
66
- stages {
67
- stage('Git checkout Helm') {
68
- steps {
69
- script {
70
- info "== Checking out ${params.HELM_BRANCH} =="
71
-
72
- gitCheckout(
73
- branches: params.HELM_BRANCH,
74
- credentials: [username: 'git', description: 'jenkins/inf-helm'],
75
- url: 'git@github.com:toptal/inf-helm.git',
76
- additionalBehaviours: [
77
- cleanBeforeCheckout: true
78
- ]
79
- )
80
-
81
- success "== Checked out ${params.HELM_BRANCH} at ${gitCommit()}"
82
-
83
- configuration = new helpers.JobHelper().readYaml('configuration.yml')
84
- configurationName = "${params.REPOSITORY_NAME}-${params.RELEASE}-deployment"
85
- data = configuration[configurationName]
86
- release = data.release
87
- chart = data.chart
88
- project = data.project
89
- cluster = data.cluster
90
- zone = data.zone
91
- // in case of an empty string value, fallback to helm_vars by not setting ENV at all
92
- set_params_env = (params.ENV == '') ? "" : "--set ${params.ENV}"
93
- }
94
- }
95
- } //stage
96
-
97
- stage('Deploy helm chart') {
98
- environment {
99
- GOOGLE_APPLICATION_CREDENTIALS = credentials("jenkins-helm-deployments-${project}")
100
- }
101
-
102
- steps {
103
- script {
104
- chart = 'davinci-app'
105
- sh """
106
- gcloud auth activate-service-account --key-file $GOOGLE_APPLICATION_CREDENTIALS
107
- gcloud config set project $project
108
- gcloud container clusters get-credentials $cluster --zone $zone --project $project
109
- HELM_OPTS='\
110
- $set_params_env \
111
- --set image.tag=${params.TAG} \
112
- --set image.repository=us-central1-docker.pkg.dev/toptal-hub/containers/${params.REPOSITORY_NAME}-release' \
113
- make $chart $release dep_build upgrade
114
- """
115
- }
116
-
117
- success "== Deployed tag ${params.TAG} =="
118
- }
119
- } //stage
120
- } //stages
121
- } //stage
122
-
123
- stage('Upload source maps to Sentry') {
124
- steps {
125
- script {
126
- def commandExists = hasCommandInDavinci(
127
- command: 'sentry-upload-source-maps',
128
- repoName: REPOSITORY_NAME,
129
- tag: TAG
130
- )
131
-
132
- if (commandExists) {
133
- sh """
134
- docker run \
135
- --rm \
136
- -u 469:469 \
137
- -e SENTRY_ORG=${sentryOrg} \
138
- -e SENTRY_PROJECT=${REPOSITORY_NAME} \
139
- -e SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN} \
140
- us-central1-docker.pkg.dev/toptal-hub/containers/${REPOSITORY_NAME}:${TAG} \
141
- yarn davinci-engine sentry-upload-source-maps
142
- """
143
- } else {
144
- info "Your current davinci version is not supporting uploading source maps to Sentry. Please update davinci package version in your app."
145
- }
146
- }
147
- } //steps
148
- } //stage
149
- } //stages
150
-
151
- post {
152
- always {
153
- script {
154
- sendBuildData(currentBuild)
155
- }
156
- }
157
- }
158
- }
159
- // vim:ft=groovy
@@ -1,107 +0,0 @@
1
- <flow-definition plugin="workflow-job@2.35">
2
- <actions>
3
- <org.jenkinsci.plugins.pipeline.modeldefinition.actions.DeclarativeJobAction plugin="pipeline-model-definition@1.3.9" />
4
- <org.jenkinsci.plugins.pipeline.modeldefinition.actions.DeclarativeJobPropertyTrackerAction plugin="pipeline-model-definition@1.3.9">
5
- <jobProperties>
6
- <string>jenkins.model.BuildDiscarderProperty</string>
7
- </jobProperties>
8
- <triggers />
9
- <parameters>
10
- <string>HELM_BRANCH</string>
11
- <string>REPOSITORY_NAME</string>
12
- <string>TAG</string>
13
- <string>RELEASE</string>
14
- <string>ENV</string>
15
- </parameters>
16
- <options>
17
- <string>skipDefaultCheckout</string>
18
- </options>
19
- </org.jenkinsci.plugins.pipeline.modeldefinition.actions.DeclarativeJobPropertyTrackerAction>
20
- </actions>
21
- <description />
22
- <keepDependencies>false</keepDependencies>
23
- <properties>
24
- <hudson.model.ParametersDefinitionProperty>
25
- <parameterDefinitions>
26
- <hudson.model.StringParameterDefinition>
27
- <name>HELM_BRANCH</name>
28
- <description>Helm branch</description>
29
- <defaultValue>master</defaultValue>
30
- <trim>false</trim>
31
- </hudson.model.StringParameterDefinition>
32
- <hudson.model.StringParameterDefinition>
33
- <name>REPOSITORY_NAME</name>
34
- <description>Name of repository</description>
35
- <defaultValue />
36
- <trim>false</trim>
37
- </hudson.model.StringParameterDefinition>
38
- <hudson.model.StringParameterDefinition>
39
- <name>TAG</name>
40
- <description>Image tag to deploy</description>
41
- <defaultValue />
42
- <trim>false</trim>
43
- </hudson.model.StringParameterDefinition>
44
- <hudson.model.StringParameterDefinition>
45
- <name>RELEASE</name>
46
- <description>Release name</description>
47
- <defaultValue />
48
- <trim>false</trim>
49
- </hudson.model.StringParameterDefinition>
50
- <hudson.model.StringParameterDefinition>
51
- <name>ENV</name>
52
- <description>Environment values in format ENV.key1=value1,ENV.key2=value2</description>
53
- <defaultValue>ENV=null</defaultValue>
54
- <trim>false</trim>
55
- </hudson.model.StringParameterDefinition>
56
- </parameterDefinitions>
57
- </hudson.model.ParametersDefinitionProperty>
58
- <hudson.plugins.jira.JiraProjectProperty plugin="jira@3.0.7" />
59
- <jenkins.model.BuildDiscarderProperty>
60
- <strategy class="hudson.tasks.LogRotator">
61
- <daysToKeep>-1</daysToKeep>
62
- <numToKeep>20</numToKeep>
63
- <artifactDaysToKeep>-1</artifactDaysToKeep>
64
- <artifactNumToKeep>-1</artifactNumToKeep>
65
- </strategy>
66
- </jenkins.model.BuildDiscarderProperty>
67
- <com.sonyericsson.jenkins.plugins.bfa.model.ScannerJobProperty plugin="build-failure-analyzer@1.20.0">
68
- <doNotScan>false</doNotScan>
69
- </com.sonyericsson.jenkins.plugins.bfa.model.ScannerJobProperty>
70
- <com.coravy.hudson.plugins.github.GithubProjectProperty plugin="github@1.29.4">
71
- <projectUrl>$PROJECT_URL</projectUrl>
72
- <displayName />
73
- </com.coravy.hudson.plugins.github.GithubProjectProperty>
74
- <hudson.plugins.throttleconcurrents.ThrottleJobProperty plugin="throttle-concurrents@2.0.1">
75
- <maxConcurrentPerNode>0</maxConcurrentPerNode>
76
- <maxConcurrentTotal>0</maxConcurrentTotal>
77
- <categories class="java.util.concurrent.CopyOnWriteArrayList" />
78
- <throttleEnabled>false</throttleEnabled>
79
- <throttleOption>project</throttleOption>
80
- <limitOneJobWithMatchingParams>false</limitOneJobWithMatchingParams>
81
- <paramsToUseForLimit />
82
- </hudson.plugins.throttleconcurrents.ThrottleJobProperty>
83
- </properties>
84
- <definition class="org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition" plugin="workflow-cps@2.74">
85
- <scm class="hudson.plugins.git.GitSCM" plugin="git@3.10.1">
86
- <configVersion>2</configVersion>
87
- <userRemoteConfigs>
88
- <hudson.plugins.git.UserRemoteConfig>
89
- <url>git@github.com:toptal/davinci.git</url>
90
- <credentialsId>$CREDENTIALS_ID</credentialsId>
91
- </hudson.plugins.git.UserRemoteConfig>
92
- </userRemoteConfigs>
93
- <branches>
94
- <hudson.plugins.git.BranchSpec>
95
- <name>master</name>
96
- </hudson.plugins.git.BranchSpec>
97
- </branches>
98
- <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
99
- <submoduleCfg class="list" />
100
- <extensions />
101
- </scm>
102
- <scriptPath>packages/ci/src/configs/jobs/deploy-helm-run/Jenkinsfile</scriptPath>
103
- <lightweight>true</lightweight>
104
- </definition>
105
- <triggers />
106
- <disabled>false</disabled>
107
- </flow-definition>
@@ -1,200 +0,0 @@
1
- @Library('globalLibrary@master') _
2
-
3
- ghHelper = new helpers.GithubNotifyHelper()
4
- helper = new helpers.Helpers()
5
- jobHelper = new helpers.JobHelper()
6
-
7
- buildImageResult = []
8
-
9
- environment = "production"
10
-
11
- repositoryName = params.REPOSITORY_NAME
12
- repositorySSHUrl = "git@github.com:toptal/${repositoryName}.git"
13
- targetBranch = "master"
14
- configDavinciYaml = "davinci.yaml"
15
- def repoBullhornSlackChannel
16
- env.REPO_NAME_FOR_COMMIT = "toptal/${repositoryName}"
17
-
18
- buildImageJobName = "${repositoryName}-build-image"
19
- buildReleaseImageJobName = "${repositoryName}-build-release-image"
20
- deployHelmRunJobName = "${repositoryName}-deploy-helm-run"
21
-
22
- String readDavinciYaml(String section, String defaultValue = '') {
23
- if (fileExists(configDavinciYaml)) {
24
- configuration = jobHelper.readYaml(configDavinciYaml)
25
-
26
- if (configuration[section]) {
27
- return "${configuration[section]}"
28
- }
29
- }
30
-
31
- return defaultValue
32
- }
33
-
34
- def getEnvironmentVariables(environmentName) {
35
- def environmentFilename = ".env.${environmentName}"
36
-
37
- if(!fileExists(environmentFilename)) {
38
- return 'ENV=null'
39
- }
40
-
41
- return sh(
42
- script: "egrep -v '^(#|\$)' ${environmentFilename} | sed 's/^/ENV./'| awk '{print}' ORS=',' | sed 's/,*\$//g'",
43
- returnStdout: true
44
- ).trim() as String
45
- }
46
-
47
- String getCommitDetails() {
48
- def commitId = gitCommit()
49
- def shortSha = commitId.substring(0, 12)
50
- def gitCommitLink = "https://github.com/toptal/${repositoryName}/commit/${commitId}"
51
- def author = gitAuthor(commitId)
52
- def pullRequestId = gitHubPullRequestId(commitId)
53
- def pullRequestLink = gitHubPullRequestLink(repositoryName, commitId)
54
-
55
- if (pullRequestId.trim() == "") {
56
- return "Build <${env.BUILD_URL}|#${env.BUILD_NUMBER}> with <${gitCommitLink}|${shortSha}> (by ${author})."
57
- }
58
-
59
- info "pullRequestId: ${pullRequestId}"
60
- info "pullRequestLink: ${pullRequestLink}"
61
- return "Build <${env.BUILD_URL}|#${env.BUILD_NUMBER}> with <${gitCommitLink}|${shortSha}> (PR <${pullRequestLink}|#${pullRequestId}> by ${author})."
62
- }
63
-
64
- pipeline {
65
- agent { label 'docker' }
66
-
67
- options {
68
- ansiColor('xterm')
69
- timestamps()
70
- timeout(time: 1, unit: 'HOURS')
71
- buildDiscarder(logRotator(numToKeepStr: '20'))
72
- skipDefaultCheckout()
73
- }
74
-
75
- parameters {
76
- string(name: 'REPOSITORY_NAME', defaultValue: '', description: 'Name of repository')
77
- }
78
-
79
- stages {
80
- stage('Git checkout PR') {
81
- steps {
82
- info "== Checking out Git revision ${targetBranch}"
83
-
84
- gitCheckout(
85
- branches: "${targetBranch}",
86
- credentials: [username: 'toptal-build', description: 'toptal-build-ssh-key'],
87
- url: repositorySSHUrl,
88
- refspec: "+refs/heads/${targetBranch}:refs/remotes/origin/${targetBranch}",
89
- additionalBehaviours: [
90
- advancedCheckoutBehaviour: [timeout: 120],
91
- advancedCloneBehaviour : [depth: 0, noTags: true, reference: '', shallow: false, timeout: 340],
92
- cleanBeforeCheckout : false,
93
- calculateChangelog : [compareRemote: 'origin', compareTarget: "${targetBranch}"],
94
- mergeBeforeBuild : [mergeRemote: 'origin', mergeTarget: "${targetBranch}", mergeStrategy: 'DEFAULT', fastForwardMode: 'FF']
95
- ]
96
- )
97
-
98
- info "Git commit: ${gitCommit()}"
99
- info "Git branch: ${gitBranch()}"
100
- script { env.COMMIT_FOR_ANVIL = gitCommit() }
101
- success 'Checkout finished'
102
-
103
- script {
104
- if (fileExists(configDavinciYaml)) {
105
- info "davinci.yaml file was found in the project root folder"
106
- info "Extracting values from the davinci.yaml file"
107
- repoBullhornSlackChannel = readDavinciYaml('slack_channel', "${repositoryName}-bullhorn")
108
- } else {
109
- info "davinci.yaml file was not found, using standard CI configuration"
110
- }
111
- }
112
- }
113
- } //stage
114
-
115
- stage('Build image') {
116
- steps {
117
- script {
118
- buildImageResult[0] = buildWithParameters(
119
- jobName: buildImageJobName,
120
- propagate: true,
121
- wait: true,
122
- parameters: [
123
- VERSION: gitCommit(),
124
- IMAGE_NAME: repositoryName,
125
- REPOSITORY_NAME: repositoryName
126
- ]
127
- )
128
- }
129
- } //steps
130
- } //stage
131
-
132
- stage('Build release image') {
133
- steps {
134
- script {
135
- buildImageResult[1] = buildWithParameters(
136
- jobName: buildReleaseImageJobName,
137
- propagate: true,
138
- wait: true,
139
- parameters: [
140
- IMAGE_TAG: gitCommit(),
141
- REPOSITORY_NAME: repositoryName
142
- ]
143
- )
144
- }
145
- } //steps
146
- } //stage
147
-
148
- stage('Trigger deploy') {
149
- steps {
150
- script {
151
- def productionEnvironmentVariables = getEnvironmentVariables(environment)
152
-
153
- buildImageResult[2] = buildWithParameters(
154
- jobName: deployHelmRunJobName,
155
- propagate: false,
156
- wait: true,
157
- parameters: [
158
- REPOSITORY_NAME: repositoryName,
159
- TAG: gitCommit(),
160
- ENV: productionEnvironmentVariables
161
- ]
162
- )
163
- }
164
- } //steps
165
- } //stage
166
-
167
- stage('Check images build status') {
168
- steps {
169
- script {
170
- helper.setBuildStatus(buildImageResult)
171
- }
172
- } //steps
173
- } //stage
174
-
175
- } //stages
176
-
177
- post {
178
- always{
179
- sendBuildData(currentBuild)
180
- }
181
-
182
- failure {
183
- script {
184
- slackSend color: 'danger',
185
- channel: repoBullhornSlackChannel,
186
- message: "<!here> The latest master version of ${repositoryName} was not deployed to '${environment}' environment.\n${getCommitDetails()}"
187
- }
188
- }
189
-
190
- success {
191
- script {
192
- slackSend color: 'good',
193
- channel: repoBullhornSlackChannel,
194
- message: "The latest master version of ${repositoryName} was deployed to '${environment}' environment :green_heart:.\n${getCommitDetails()}"
195
- }
196
- }
197
- }
198
-
199
- }
200
- // vim:ft=groovy