@toptal/davinci-ci 3.0.1-alpha-chore-improve-packages-building-14e3a950.51 → 3.0.2-alpha-chore-improve-packages-building-4fb91e1f.10
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/package.json +6 -5
- package/src/commands/danger.js +67 -0
- package/src/configs/danger/conventional-commits/dangerfile.js +17 -0
- package/src/configs/danger/conventional-commits/plugins/conventional-commits/index.js +52 -0
- package/src/configs/danger/conventional-commits/plugins/conventional-pr-title/index.js +53 -0
- package/src/configs/danger/conventional-commits/plugins/index.js +7 -0
- package/src/configs/danger/plugins/empty-assignee.js +24 -0
- package/src/configs/danger/toptal/config.js +30 -0
- package/src/configs/danger/toptal/dangerfile.js +17 -0
- package/src/configs/danger/toptal/plugins/index.js +7 -0
- package/src/configs/danger/toptal/plugins/toptal-commits/index.js +73 -0
- package/src/configs/danger/toptal/plugins/toptal-commits/toptal-commits.test.js +128 -0
- package/src/configs/danger/toptal/plugins/toptal-pr-title/index.js +62 -0
- package/src/configs/danger/toptal/plugins/toptal-pr-title/toptal-pr-title.test.js +68 -0
- package/src/configs/docker/Dockerfile +30 -0
- package/src/configs/docker/Dockerfile.gha-deploy +33 -0
- package/src/configs/docker/Dockerfile.release +28 -0
- package/src/configs/docker/Dockerfile.storybook +20 -0
- package/src/configs/docker/env-runtime.entrypoint.sh +47 -0
- package/src/configs/docker/nginx-vhost-storybook.conf +20 -0
- package/src/configs/docker/nginx-vhost.conf +18 -0
- package/src/configs/jobs/build-image/Jenkinsfile +142 -0
- package/src/configs/jobs/build-image/config.xml +119 -0
- package/src/configs/jobs/build-release-image/Jenkinsfile +154 -0
- package/src/configs/jobs/build-release-image/config.xml +102 -0
- package/src/configs/jobs/consumer-contracts-verify/Jenkinsfile +117 -0
- package/src/configs/jobs/consumer-contracts-verify/config.xml +114 -0
- package/src/configs/jobs/deploy/config.xml +107 -0
- package/src/configs/jobs/deploy-helm-run/Jenkinsfile +159 -0
- package/src/configs/jobs/deploy-helm-run/config.xml +107 -0
- package/src/configs/jobs/deploy-helm-run-trigger/Jenkinsfile +200 -0
- package/src/configs/jobs/master-main/Jenkinsfile +460 -0
- package/src/configs/jobs/master-main/config.xml +119 -0
- package/src/configs/jobs/pr-tests/Jenkinsfile +407 -0
- package/src/configs/jobs/pr-tests/config.xml +134 -0
- package/src/configs/jobs/publish-alpha-package/Jenkinsfile +189 -0
- package/src/configs/jobs/publish-alpha-package/config.xml +136 -0
- package/src/configs/jobs/temploy-helm-run/Jenkinsfile +141 -0
- package/src/configs/jobs/temploy-helm-run/config.xml +97 -0
- package/src/index.js +17 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
@Library('globalLibrary@master') _
|
|
2
|
+
|
|
3
|
+
ghHelper = new helpers.GithubNotifyHelper()
|
|
4
|
+
|
|
5
|
+
repositoryUrl = params.GITHUB_REPO_GIT_URL
|
|
6
|
+
pullRequestId = params.GITHUB_PR_NUMBER
|
|
7
|
+
commitId = params.GITHUB_PR_HEAD_SHA
|
|
8
|
+
sourceBranch = params.GITHUB_PR_SOURCE_BRANCH
|
|
9
|
+
targetBranch = params.GITHUB_PR_TARGET_BRANCH
|
|
10
|
+
|
|
11
|
+
repositoryName = repositoryUrl.tokenize('/').last().split("\\.")[0]
|
|
12
|
+
repositorySSHUrl = "git@github.com:toptal/${repositoryName}.git"
|
|
13
|
+
|
|
14
|
+
buildImageJobName = "${repositoryName}-build-image"
|
|
15
|
+
|
|
16
|
+
pipeline {
|
|
17
|
+
agent { label 'slave_aws' }
|
|
18
|
+
|
|
19
|
+
options {
|
|
20
|
+
ansiColor('xterm')
|
|
21
|
+
timestamps()
|
|
22
|
+
timeout(time: 35, unit: 'MINUTES')
|
|
23
|
+
buildDiscarder(logRotator(numToKeepStr: '20'))
|
|
24
|
+
skipDefaultCheckout()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
parameters {
|
|
28
|
+
string(name: 'GITHUB_PR_SOURCE_BRANCH', defaultValue: '', description: 'Source branch')
|
|
29
|
+
string(name: 'GITHUB_PR_TARGET_BRANCH', defaultValue: '', description: 'Target branch')
|
|
30
|
+
string(name: 'GITHUB_REPO_GIT_URL', defaultValue: '', description: 'Repository url')
|
|
31
|
+
string(name: 'GITHUB_PR_NUMBER', defaultValue: '', description: 'Pull request Id')
|
|
32
|
+
string(name: 'GITHUB_PR_HEAD_SHA', defaultValue: '', description: 'Commit Id')
|
|
33
|
+
string(name: 'BUILD_PACKAGE_SCRIPT_NAME', defaultValue: 'build:package', description: 'Yarn script name to build the package')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
environment {
|
|
37
|
+
GCE_ACCOUNT_KEY = credentials('jenkins-storage-administrator')
|
|
38
|
+
NPM_TOKEN = credentials('npm-token-for-toptal-private-registry')
|
|
39
|
+
GITHUB_TOKEN = credentials('toptal-devbot-personal-token')
|
|
40
|
+
PUBLISH_NPM_TOKEN = credentials('npm-token-for-toptal-private-registry-publish')
|
|
41
|
+
GIT_COMMITTER_NAME = 'toptal-bot'
|
|
42
|
+
GIT_COMMITTER_EMAIL = 'bot@toptal.com'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
stages {
|
|
46
|
+
stage('Git checkout PR') {
|
|
47
|
+
steps {
|
|
48
|
+
script {
|
|
49
|
+
ghHelper.notifyPR('Package alpha release', 'PENDING', 'running', "${commitId}", "${BUILD_URL}", repositoryName)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
info "== Checking out Git revision ${commitId}"
|
|
53
|
+
|
|
54
|
+
gitCheckout(
|
|
55
|
+
branches: "${commitId}",
|
|
56
|
+
credentials: [username: 'toptal-build', description: "toptal-build-ssh-key"],
|
|
57
|
+
url: repositorySSHUrl,
|
|
58
|
+
refspec: "+refs/heads/${targetBranch}:refs/remotes/origin/${targetBranch} +refs/pull/${pullRequestId}/*:refs/remotes/origin/pr/${pullRequestId}/*",
|
|
59
|
+
additionalBehaviours: [
|
|
60
|
+
advancedCheckoutBehaviour: [timeout: 120],
|
|
61
|
+
advancedCloneBehaviour : [depth: 0, noTags: true, reference: '', shallow: false, timeout: 340],
|
|
62
|
+
cleanBeforeCheckout : false,
|
|
63
|
+
calculateChangelog : [compareRemote: 'origin', compareTarget: "${targetBranch}"]
|
|
64
|
+
]
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
info "Git commit: ${gitCommit()}"
|
|
68
|
+
info "Git branch: ${gitBranch()}"
|
|
69
|
+
success 'Checkout finished'
|
|
70
|
+
}
|
|
71
|
+
} //stage
|
|
72
|
+
|
|
73
|
+
stage('Build image') {
|
|
74
|
+
steps {
|
|
75
|
+
script {
|
|
76
|
+
buildWithParameters(
|
|
77
|
+
jobName: buildImageJobName,
|
|
78
|
+
propagate: true,
|
|
79
|
+
wait: true,
|
|
80
|
+
parameters: [
|
|
81
|
+
BRANCH: sourceBranch,
|
|
82
|
+
VERSION: commitId,
|
|
83
|
+
IMAGE_NAME: repositoryName,
|
|
84
|
+
REPOSITORY_NAME: repositoryName
|
|
85
|
+
]
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
} //steps
|
|
89
|
+
} //stage
|
|
90
|
+
|
|
91
|
+
stage('Publish as alpha package') {
|
|
92
|
+
steps {
|
|
93
|
+
script {
|
|
94
|
+
PWD = sh(returnStdout: true, script: 'pwd').trim()
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
sshagent(credentials: ['toptal-build-ssh-key']) {
|
|
98
|
+
// $SSH_AUTH_SOCK - is the ssh key passed from ssh agent
|
|
99
|
+
//
|
|
100
|
+
// -u 469:469 \
|
|
101
|
+
// - all those need to be passed to reuse jenkins user from Jenkins
|
|
102
|
+
// and it's .ssh folder, keys and passwords
|
|
103
|
+
//
|
|
104
|
+
// -v ${PWD}:/artifacts - needs to pass .versions file
|
|
105
|
+
//
|
|
106
|
+
// -e JENKINS_URL=${JENKINS_URL} \
|
|
107
|
+
// -e GIT_BRANCH=${branch} \
|
|
108
|
+
// - need to make semantic-release to think
|
|
109
|
+
// that we are running it inside CI environment
|
|
110
|
+
//
|
|
111
|
+
// -e GITHUB_TOKEN needed for semantic-release to authenticated with GitHub
|
|
112
|
+
//
|
|
113
|
+
sh """
|
|
114
|
+
docker run \
|
|
115
|
+
--rm \
|
|
116
|
+
-e GIT_COMMITTER_EMAIL=${GIT_COMMITTER_EMAIL} \
|
|
117
|
+
-e GIT_COMMITTER_NAME=${GIT_COMMITTER_NAME} \
|
|
118
|
+
-e GITHUB_TOKEN=${GITHUB_TOKEN} \
|
|
119
|
+
-e NPM_TOKEN=${PUBLISH_NPM_TOKEN} \
|
|
120
|
+
-e JENKINS_URL=${JENKINS_URL} \
|
|
121
|
+
-e GIT_BRANCH=${sourceBranch} \
|
|
122
|
+
-v ${PWD}:/artifacts \
|
|
123
|
+
-u 469:469 \
|
|
124
|
+
-v $SSH_AUTH_SOCK:/ssh-agent \
|
|
125
|
+
-e SSH_AUTH_SOCK=/ssh-agent \
|
|
126
|
+
-v ${PWD}/.git:/app/.git \
|
|
127
|
+
us-central1-docker.pkg.dev/toptal-hub/containers/${repositoryName}:${commitId} \
|
|
128
|
+
/bin/bash -c "yarn ${params.BUILD_PACKAGE_SCRIPT_NAME} && \
|
|
129
|
+
yarn davinci-engine publish-package \
|
|
130
|
+
--alpha \
|
|
131
|
+
--outputVersion /artifacts/.version \
|
|
132
|
+
--branch ${sourceBranch}"
|
|
133
|
+
"""
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
script {
|
|
137
|
+
NEW_VERSION = sh(returnStdout: true, script: 'cat .version').trim()
|
|
138
|
+
}
|
|
139
|
+
} //steps
|
|
140
|
+
|
|
141
|
+
post {
|
|
142
|
+
success {
|
|
143
|
+
success "Alpha package released"
|
|
144
|
+
script {
|
|
145
|
+
def notes
|
|
146
|
+
|
|
147
|
+
isLikelyMonorepo = [
|
|
148
|
+
'@toptal/picasso',
|
|
149
|
+
'@topkit',
|
|
150
|
+
'@toptal/davinci',
|
|
151
|
+
'@toptal/staff-portal'
|
|
152
|
+
].any { NEW_VERSION.contains(it) }
|
|
153
|
+
|
|
154
|
+
if (isLikelyMonorepo) {
|
|
155
|
+
notes = ""
|
|
156
|
+
NEW_VERSION.split(' ').each{name -> notes += "`yarn add $name`<br/>"}
|
|
157
|
+
} else {
|
|
158
|
+
releasedPackageName = "@toptal/${repositoryName}@${NEW_VERSION}"
|
|
159
|
+
notes = "Alpha package release: `yarn add ${releasedPackageName}`"
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
comment = "Your alpha package is ready :tada:<br/>" + notes
|
|
163
|
+
gitHubPostComment("${repositoryName}", "${pullRequestId}", comment, GITHUB_TOKEN)
|
|
164
|
+
|
|
165
|
+
ghHelper.notifyPR('Package alpha release', 'SUCCESS', 'Done!', "${commitId}", "${BUILD_URL}", repositoryName)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
} //stage
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
post {
|
|
173
|
+
failure {
|
|
174
|
+
err "Alpha package was not released"
|
|
175
|
+
script {
|
|
176
|
+
notes = "It looks like publish-alpha-package job failed by some reason."
|
|
177
|
+
comment = "Your alpha package was not released :x:<br/>" + notes
|
|
178
|
+
gitHubPostComment("${repositoryName}", "${pullRequestId}", comment, GITHUB_TOKEN)
|
|
179
|
+
ghHelper.notifyPR('Package alpha release', 'FAILURE', notes, "${commitId}", "${BUILD_URL}", repositoryName)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
always {
|
|
184
|
+
script {
|
|
185
|
+
sendBuildData(currentBuild)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<flow-definition plugin="workflow-job@2.39">
|
|
2
|
+
<actions>
|
|
3
|
+
<org.jenkinsci.plugins.pipeline.modeldefinition.actions.DeclarativeJobAction plugin="pipeline-model-definition@1.7.1"/>
|
|
4
|
+
<org.jenkinsci.plugins.pipeline.modeldefinition.actions.DeclarativeJobPropertyTrackerAction plugin="pipeline-model-definition@1.7.1">
|
|
5
|
+
<jobProperties>
|
|
6
|
+
<string>jenkins.model.BuildDiscarderProperty</string>
|
|
7
|
+
</jobProperties>
|
|
8
|
+
<triggers/>
|
|
9
|
+
<parameters>
|
|
10
|
+
<string>GITHUB_PR_SOURCE_BRANCH</string>
|
|
11
|
+
<string>GITHUB_PR_HEAD_SHA</string>
|
|
12
|
+
<string>GITHUB_REPO_GIT_URL</string>
|
|
13
|
+
<string>GITHUB_PR_NUMBER</string>
|
|
14
|
+
<string>BUILD_PACKAGE_SCRIPT_NAME</string>
|
|
15
|
+
</parameters>
|
|
16
|
+
<options>
|
|
17
|
+
<string>skipDefaultCheckout</string>
|
|
18
|
+
</options>
|
|
19
|
+
</org.jenkinsci.plugins.pipeline.modeldefinition.actions.DeclarativeJobPropertyTrackerAction>
|
|
20
|
+
</actions>
|
|
21
|
+
<description></description>
|
|
22
|
+
<keepDependencies>false</keepDependencies>
|
|
23
|
+
<properties>
|
|
24
|
+
<hudson.plugins.jira.JiraProjectProperty plugin="jira@3.0.15"/>
|
|
25
|
+
<jenkins.model.BuildDiscarderProperty>
|
|
26
|
+
<strategy class="hudson.tasks.LogRotator">
|
|
27
|
+
<daysToKeep>-1</daysToKeep>
|
|
28
|
+
<numToKeep>20</numToKeep>
|
|
29
|
+
<artifactDaysToKeep>-1</artifactDaysToKeep>
|
|
30
|
+
<artifactNumToKeep>-1</artifactNumToKeep>
|
|
31
|
+
</strategy>
|
|
32
|
+
</jenkins.model.BuildDiscarderProperty>
|
|
33
|
+
<com.sonyericsson.jenkins.plugins.bfa.model.ScannerJobProperty plugin="build-failure-analyzer@1.26.0">
|
|
34
|
+
<doNotScan>false</doNotScan>
|
|
35
|
+
</com.sonyericsson.jenkins.plugins.bfa.model.ScannerJobProperty>
|
|
36
|
+
<com.coravy.hudson.plugins.github.GithubProjectProperty plugin="github@1.30.0">
|
|
37
|
+
<projectUrl>$PROJECT_URL</projectUrl>
|
|
38
|
+
<displayName></displayName>
|
|
39
|
+
</com.coravy.hudson.plugins.github.GithubProjectProperty>
|
|
40
|
+
<com.sonyericsson.rebuild.RebuildSettings plugin="rebuild@1.31">
|
|
41
|
+
<autoRebuild>false</autoRebuild>
|
|
42
|
+
<rebuildDisabled>false</rebuildDisabled>
|
|
43
|
+
</com.sonyericsson.rebuild.RebuildSettings>
|
|
44
|
+
<org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
|
|
45
|
+
<triggers>
|
|
46
|
+
<org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger plugin="github-pullrequest@0.2.8">
|
|
47
|
+
<spec></spec>
|
|
48
|
+
<triggerMode>HEAVY_HOOKS</triggerMode>
|
|
49
|
+
<cancelQueued>true</cancelQueued>
|
|
50
|
+
<abortRunning>true</abortRunning>
|
|
51
|
+
<skipFirstRun>false</skipFirstRun>
|
|
52
|
+
<repoProviders>
|
|
53
|
+
<com.github.kostyasha.github.integration.generic.repoprovider.GitHubPluginRepoProvider>
|
|
54
|
+
<cacheConnection>true</cacheConnection>
|
|
55
|
+
<manageHooks>true</manageHooks>
|
|
56
|
+
<repoPermission>ADMIN</repoPermission>
|
|
57
|
+
</com.github.kostyasha.github.integration.generic.repoprovider.GitHubPluginRepoProvider>
|
|
58
|
+
</repoProviders>
|
|
59
|
+
<errorsAction>
|
|
60
|
+
<description>GitHub Pull Requests Trigger Errors</description>
|
|
61
|
+
<errors class="java.util.Collections$SynchronizedSet" serialization="custom">
|
|
62
|
+
<java.util.Collections_-SynchronizedCollection>
|
|
63
|
+
<default>
|
|
64
|
+
<c class="set"/>
|
|
65
|
+
<mutex class="java.util.Collections$SynchronizedSet" reference="../../.."/>
|
|
66
|
+
</default>
|
|
67
|
+
</java.util.Collections_-SynchronizedCollection>
|
|
68
|
+
</errors>
|
|
69
|
+
</errorsAction>
|
|
70
|
+
<events>
|
|
71
|
+
<org.jenkinsci.plugins.github.pullrequest.events.impl.GitHubPRCommentEvent>
|
|
72
|
+
<comment>@toptal-bot run package:alpha-release</comment>
|
|
73
|
+
</org.jenkinsci.plugins.github.pullrequest.events.impl.GitHubPRCommentEvent>
|
|
74
|
+
</events>
|
|
75
|
+
<preStatus>false</preStatus>
|
|
76
|
+
</org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger>
|
|
77
|
+
</triggers>
|
|
78
|
+
</org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
|
|
79
|
+
<hudson.model.ParametersDefinitionProperty>
|
|
80
|
+
<parameterDefinitions>
|
|
81
|
+
<hudson.model.StringParameterDefinition>
|
|
82
|
+
<name>GITHUB_PR_SOURCE_BRANCH</name>
|
|
83
|
+
<description>Source branch</description>
|
|
84
|
+
<defaultValue></defaultValue>
|
|
85
|
+
<trim>false</trim>
|
|
86
|
+
</hudson.model.StringParameterDefinition>
|
|
87
|
+
<hudson.model.StringParameterDefinition>
|
|
88
|
+
<name>GITHUB_REPO_GIT_URL</name>
|
|
89
|
+
<description>Repository url</description>
|
|
90
|
+
<trim>false</trim>
|
|
91
|
+
</hudson.model.StringParameterDefinition>
|
|
92
|
+
<hudson.model.StringParameterDefinition>
|
|
93
|
+
<name>GITHUB_PR_NUMBER</name>
|
|
94
|
+
<description>Pull request Id</description>
|
|
95
|
+
<defaultValue></defaultValue>
|
|
96
|
+
<trim>false</trim>
|
|
97
|
+
</hudson.model.StringParameterDefinition>
|
|
98
|
+
<hudson.model.StringParameterDefinition>
|
|
99
|
+
<name>GITHUB_PR_HEAD_SHA</name>
|
|
100
|
+
<description>Commit Id</description>
|
|
101
|
+
<defaultValue></defaultValue>
|
|
102
|
+
<trim>false</trim>
|
|
103
|
+
</hudson.model.StringParameterDefinition>
|
|
104
|
+
<hudson.model.StringParameterDefinition>
|
|
105
|
+
<name>BUILD_PACKAGE_SCRIPT_NAME</name>
|
|
106
|
+
<description>Yarn script name to build the package</description>
|
|
107
|
+
<defaultValue>build:package</defaultValue>
|
|
108
|
+
<trim>false</trim>
|
|
109
|
+
</hudson.model.StringParameterDefinition>
|
|
110
|
+
</parameterDefinitions>
|
|
111
|
+
</hudson.model.ParametersDefinitionProperty>
|
|
112
|
+
</properties>
|
|
113
|
+
<definition class="org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition" plugin="workflow-cps@2.82">
|
|
114
|
+
<scm class="hudson.plugins.git.GitSCM" plugin="git@4.3.0">
|
|
115
|
+
<configVersion>2</configVersion>
|
|
116
|
+
<userRemoteConfigs>
|
|
117
|
+
<hudson.plugins.git.UserRemoteConfig>
|
|
118
|
+
<url>git@github.com:toptal/davinci.git</url>
|
|
119
|
+
<credentialsId>$CREDENTIALS_ID</credentialsId>
|
|
120
|
+
</hudson.plugins.git.UserRemoteConfig>
|
|
121
|
+
</userRemoteConfigs>
|
|
122
|
+
<branches>
|
|
123
|
+
<hudson.plugins.git.BranchSpec>
|
|
124
|
+
<name>master</name>
|
|
125
|
+
</hudson.plugins.git.BranchSpec>
|
|
126
|
+
</branches>
|
|
127
|
+
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
|
|
128
|
+
<submoduleCfg class="list"/>
|
|
129
|
+
<extensions/>
|
|
130
|
+
</scm>
|
|
131
|
+
<scriptPath>packages/ci/src/configs/jobs/publish-alpha-package/Jenkinsfile</scriptPath>
|
|
132
|
+
<lightweight>false</lightweight>
|
|
133
|
+
</definition>
|
|
134
|
+
<triggers/>
|
|
135
|
+
<disabled>false</disabled>
|
|
136
|
+
</flow-definition>
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
@Library('globalLibrary@master') _
|
|
2
|
+
|
|
3
|
+
helmVersion = '3'
|
|
4
|
+
|
|
5
|
+
project = 'compute-engine-1069'
|
|
6
|
+
cluster = 'temploys'
|
|
7
|
+
zone = 'us-central1-b'
|
|
8
|
+
|
|
9
|
+
pipeline {
|
|
10
|
+
agent { label 'docker' }
|
|
11
|
+
|
|
12
|
+
options {
|
|
13
|
+
ansiColor('xterm')
|
|
14
|
+
timestamps()
|
|
15
|
+
timeout(time: 1, unit: 'HOURS')
|
|
16
|
+
buildDiscarder(logRotator(numToKeepStr: '20'))
|
|
17
|
+
skipDefaultCheckout()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
parameters {
|
|
21
|
+
string(name: 'HELM_BRANCH', defaultValue: 'master', description: 'Helm branch')
|
|
22
|
+
string(name: 'REPOSITORY_NAME', defaultValue: '', description: 'Name of repository')
|
|
23
|
+
string(name: 'TAG', defaultValue: '', description: 'Image tag to deploy')
|
|
24
|
+
string(name: 'RELEASE', defaultValue: '', description: 'Release name')
|
|
25
|
+
string(name: 'ENV', defaultValue: 'ENV=null', description: 'Environment values in format ENV.key1=value1,ENV.key2=value2')
|
|
26
|
+
string(name: 'DOCKER_REGISTRY', defaultValue: 'gcr.io/toptal-hub', description: 'Name of registry')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
stages {
|
|
30
|
+
stage('Check params') {
|
|
31
|
+
steps {
|
|
32
|
+
script {
|
|
33
|
+
if (
|
|
34
|
+
(params.REPOSITORY_NAME == "") ||
|
|
35
|
+
(params.TAG == "") ||
|
|
36
|
+
(params.RELEASE == "")
|
|
37
|
+
) {
|
|
38
|
+
error("== REPOSITORY_NAME, TAG and RELEASE are mandatory parameters ==")
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
stage('Deploy with Helm') {
|
|
45
|
+
agent { docker { image "gcr.io/toptal-hub/helm:${helmVersion}" } }
|
|
46
|
+
|
|
47
|
+
environment {
|
|
48
|
+
GOOGLE_APPLICATION_CREDENTIALS = credentials("jenkins-deployment")
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
steps {
|
|
52
|
+
script {
|
|
53
|
+
info "== Checking out ${params.HELM_BRANCH} =="
|
|
54
|
+
|
|
55
|
+
gitCheckout(
|
|
56
|
+
branches: params.HELM_BRANCH,
|
|
57
|
+
credentials: [username: 'git', description: 'jenkins/inf-helm'],
|
|
58
|
+
url: 'git@github.com:toptal/inf-helm.git',
|
|
59
|
+
additionalBehaviours: [
|
|
60
|
+
cleanBeforeCheckout: true
|
|
61
|
+
]
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
success "== Checked out ${params.HELM_BRANCH} at ${gitCommit()}"
|
|
65
|
+
|
|
66
|
+
configuration = new helpers.JobHelper().readYaml('configuration.yml')
|
|
67
|
+
configurationName = "${params.REPOSITORY_NAME}-temploy-deployment"
|
|
68
|
+
data = configuration[configurationName]
|
|
69
|
+
|
|
70
|
+
if (data) {
|
|
71
|
+
chart = data.chart
|
|
72
|
+
} else {
|
|
73
|
+
chart = 'davinci-app'
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
sh """
|
|
77
|
+
export HELM_EXPERIMENTAL_OCI=1
|
|
78
|
+
|
|
79
|
+
gcloud auth activate-service-account --key-file $GOOGLE_APPLICATION_CREDENTIALS
|
|
80
|
+
gcloud config set project $project
|
|
81
|
+
gcloud container clusters get-credentials $cluster --zone $zone --project $project
|
|
82
|
+
gcloud auth application-default print-access-token | helm registry login -u oauth2accesstoken --password-stdin https://us-east1-docker.pkg.dev/toptal-hub/helm-repo
|
|
83
|
+
|
|
84
|
+
kubectl get namespace ${params.RELEASE} >/dev/null 2>&1 || kubectl create namespace ${params.RELEASE}
|
|
85
|
+
helm dependency build charts/${chart}
|
|
86
|
+
|
|
87
|
+
if helm secrets upgrade \
|
|
88
|
+
--namespace=${params.RELEASE} \
|
|
89
|
+
--install --wait --timeout 240s \
|
|
90
|
+
-f helm_vars/${chart}/temploy/values.yaml \
|
|
91
|
+
-f helm_vars/${chart}/temploy/secrets.yaml \
|
|
92
|
+
-f helm_vars/tls-certs/toptal.rocks/values.yaml \
|
|
93
|
+
-f helm_vars/tls-certs/toptal.rocks/secrets.yaml \
|
|
94
|
+
--set image.repository=${params.DOCKER_REGISTRY}/${params.REPOSITORY_NAME}-release \
|
|
95
|
+
--set nameOverride=${params.REPOSITORY_NAME} \
|
|
96
|
+
--set-string image.tag=${params.TAG} \
|
|
97
|
+
--set davinci-app.image.repository=${params.DOCKER_REGISTRY}/${params.REPOSITORY_NAME}-release \
|
|
98
|
+
--set davinci-app.nameOverride=${params.REPOSITORY_NAME} \
|
|
99
|
+
--set-string davinci-app.image.tag=${params.TAG} \
|
|
100
|
+
--set ${params.ENV} \
|
|
101
|
+
${params.RELEASE} charts/${chart}
|
|
102
|
+
then
|
|
103
|
+
echo "\nHelm deploy succeeded!\n"
|
|
104
|
+
|
|
105
|
+
mkdir tmp
|
|
106
|
+
helm get notes --namespace=${params.RELEASE} ${params.RELEASE} | tail -n +2 > tmp/NOTES.txt
|
|
107
|
+
|
|
108
|
+
else
|
|
109
|
+
echo "\nHelm deploy failed! Some hints may be found below:\n"
|
|
110
|
+
kubectl get events --namespace="${params.RELEASE}" --sort-by='.lastTimestamp'
|
|
111
|
+
|
|
112
|
+
helm history --namespace "${params.RELEASE}" "${params.RELEASE}"
|
|
113
|
+
|
|
114
|
+
kubectl --namespace "${params.RELEASE}" get pods -o wide
|
|
115
|
+
|
|
116
|
+
kubectl --namespace ${params.RELEASE} get pods --no-headers -o custom-columns=":metadata.name" | while read pod; do
|
|
117
|
+
echo "\nFetching log tail for pod '\$pod'"
|
|
118
|
+
kubectl --namespace ${params.RELEASE} logs \$pod --tail=10
|
|
119
|
+
done
|
|
120
|
+
|
|
121
|
+
exit 1
|
|
122
|
+
fi
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
archiveArtifacts(artifacts: 'tmp/NOTES.txt')
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
success "== Deployed tag ${params.TAG} =="
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
post {
|
|
134
|
+
always {
|
|
135
|
+
script {
|
|
136
|
+
sendBuildData(currentBuild)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// vim:ft=groovy
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
</parameters>
|
|
15
|
+
<options>
|
|
16
|
+
<string>skipDefaultCheckout</string>
|
|
17
|
+
</options>
|
|
18
|
+
</org.jenkinsci.plugins.pipeline.modeldefinition.actions.DeclarativeJobPropertyTrackerAction>
|
|
19
|
+
</actions>
|
|
20
|
+
<description></description>
|
|
21
|
+
<keepDependencies>false</keepDependencies>
|
|
22
|
+
<properties>
|
|
23
|
+
<hudson.model.ParametersDefinitionProperty>
|
|
24
|
+
<parameterDefinitions>
|
|
25
|
+
<hudson.model.StringParameterDefinition>
|
|
26
|
+
<name>HELM_BRANCH</name>
|
|
27
|
+
<description>Helm branch</description>
|
|
28
|
+
<defaultValue>master</defaultValue>
|
|
29
|
+
<trim>false</trim>
|
|
30
|
+
</hudson.model.StringParameterDefinition>
|
|
31
|
+
<hudson.model.StringParameterDefinition>
|
|
32
|
+
<name>REPOSITORY_NAME</name>
|
|
33
|
+
<description>Name of repository</description>
|
|
34
|
+
<defaultValue></defaultValue>
|
|
35
|
+
<trim>false</trim>
|
|
36
|
+
</hudson.model.StringParameterDefinition>
|
|
37
|
+
<hudson.model.StringParameterDefinition>
|
|
38
|
+
<name>TAG</name>
|
|
39
|
+
<description>Image tag to deploy</description>
|
|
40
|
+
<defaultValue></defaultValue>
|
|
41
|
+
<trim>false</trim>
|
|
42
|
+
</hudson.model.StringParameterDefinition>
|
|
43
|
+
<hudson.model.StringParameterDefinition>
|
|
44
|
+
<name>RELEASE</name>
|
|
45
|
+
<description>Release name</description>
|
|
46
|
+
<defaultValue></defaultValue>
|
|
47
|
+
<trim>false</trim>
|
|
48
|
+
</hudson.model.StringParameterDefinition>
|
|
49
|
+
</parameterDefinitions>
|
|
50
|
+
</hudson.model.ParametersDefinitionProperty>
|
|
51
|
+
<jenkins.model.BuildDiscarderProperty>
|
|
52
|
+
<strategy class="hudson.tasks.LogRotator">
|
|
53
|
+
<daysToKeep>-1</daysToKeep>
|
|
54
|
+
<numToKeep>20</numToKeep>
|
|
55
|
+
<artifactDaysToKeep>-1</artifactDaysToKeep>
|
|
56
|
+
<artifactNumToKeep>-1</artifactNumToKeep>
|
|
57
|
+
</strategy>
|
|
58
|
+
</jenkins.model.BuildDiscarderProperty>
|
|
59
|
+
<hudson.plugins.jira.JiraProjectProperty plugin="jira@3.0.7"/>
|
|
60
|
+
<com.sonyericsson.jenkins.plugins.bfa.model.ScannerJobProperty plugin="build-failure-analyzer@1.20.0">
|
|
61
|
+
<doNotScan>false</doNotScan>
|
|
62
|
+
</com.sonyericsson.jenkins.plugins.bfa.model.ScannerJobProperty>
|
|
63
|
+
<hudson.plugins.throttleconcurrents.ThrottleJobProperty plugin="throttle-concurrents@2.0.1">
|
|
64
|
+
<maxConcurrentPerNode>0</maxConcurrentPerNode>
|
|
65
|
+
<maxConcurrentTotal>0</maxConcurrentTotal>
|
|
66
|
+
<categories class="java.util.concurrent.CopyOnWriteArrayList"/>
|
|
67
|
+
<throttleEnabled>false</throttleEnabled>
|
|
68
|
+
<throttleOption>project</throttleOption>
|
|
69
|
+
<limitOneJobWithMatchingParams>false</limitOneJobWithMatchingParams>
|
|
70
|
+
<paramsToUseForLimit></paramsToUseForLimit>
|
|
71
|
+
<configVersion>1</configVersion>
|
|
72
|
+
</hudson.plugins.throttleconcurrents.ThrottleJobProperty>
|
|
73
|
+
</properties>
|
|
74
|
+
<definition class="org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition" plugin="workflow-cps@2.74">
|
|
75
|
+
<scm class="hudson.plugins.git.GitSCM" plugin="git@3.10.1">
|
|
76
|
+
<configVersion>2</configVersion>
|
|
77
|
+
<userRemoteConfigs>
|
|
78
|
+
<hudson.plugins.git.UserRemoteConfig>
|
|
79
|
+
<url>git@github.com:toptal/davinci.git</url>
|
|
80
|
+
<credentialsId>$CREDENTIALS_ID</credentialsId>
|
|
81
|
+
</hudson.plugins.git.UserRemoteConfig>
|
|
82
|
+
</userRemoteConfigs>
|
|
83
|
+
<branches>
|
|
84
|
+
<hudson.plugins.git.BranchSpec>
|
|
85
|
+
<name>master</name>
|
|
86
|
+
</hudson.plugins.git.BranchSpec>
|
|
87
|
+
</branches>
|
|
88
|
+
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
|
|
89
|
+
<submoduleCfg class="list"/>
|
|
90
|
+
<extensions/>
|
|
91
|
+
</scm>
|
|
92
|
+
<scriptPath>packages/ci/src/configs/jobs/temploy-helm-run/Jenkinsfile</scriptPath>
|
|
93
|
+
<lightweight>true</lightweight>
|
|
94
|
+
</definition>
|
|
95
|
+
<triggers/>
|
|
96
|
+
<disabled>false</disabled>
|
|
97
|
+
</flow-definition>
|
package/src/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const dangerCommandCreator = require('./commands/danger')
|
|
2
|
+
const toptalPlugins = require('./configs/danger/toptal/plugins')
|
|
3
|
+
const conventionalCommitsPlugins = require('./configs/danger/conventional-commits/plugins')
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
commands: [dangerCommandCreator],
|
|
7
|
+
plugins: {
|
|
8
|
+
conventionalCommit: {
|
|
9
|
+
PRTitle: conventionalCommitsPlugins.conventionalPRTitle,
|
|
10
|
+
commits: conventionalCommitsPlugins.conventionalCommits,
|
|
11
|
+
},
|
|
12
|
+
toptal: {
|
|
13
|
+
PRTitle: toptalPlugins.toptalPRTitle,
|
|
14
|
+
commits: toptalPlugins.toptalCommits,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
}
|