-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
59 lines (49 loc) · 2.75 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import groovy.json.JsonSlurperClassic
properties([
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10'))
])
//triggers {
// upstream(upstreamProjects: "jcustenborder/connect-utils/job/master", threshold: hudson.model.Result.SUCCESS)
//}
node {
stage('checkout') {
deleteDir()
checkout scm
}
def readmeText = readFile encoding: 'UTF-8', file: 'README_TEMPLATE.md'
sh 'mkdir build'
dir('build') {
git branch: 'master', changelog: false, credentialsId: '50a4ec3a-9caf-43d1-bfab-6465b47292da', poll: false, url: 'git@github.com:jcustenborder/kafka-connect-all.git'
sh 'git config user.email "jenkins@custenborder.com"'
sh 'git config user.name "Jenkins"'
stage('generate') {
def pluginsUrl = new URL("https://api.hub.confluent.io/api/plugins/jcustenborder")
def components = new JsonSlurperClassic().parse(pluginsUrl)
def baseVersion = '5.5.0.0'
def dockerFileText = "FROM confluentinc/cp-server-connect-operator:${baseVersion}\n" +
'ENV CONNECT_PLUGIN_PATH="/usr/share/java,/usr/share/confluent-hub-components"\n' +
'RUN confluent-hub install --no-prompt debezium/debezium-connector-mysql:latest\n' +
'RUN confluent-hub install --no-prompt confluentinc/kafka-connect-datagen:latest\n'
components.each {
def plugin_resource_url = new URL(it['plugin_resource_url'])
def plugin_resource = new JsonSlurperClassic().parse(plugin_resource_url)
def plugin_name = plugin_resource['name']
def plugin_owner = plugin_resource['owner']['username']
def plugin_version = plugin_resource['version']
def plugin_source = plugin_resource['source_url']
def plugin_documentation = plugin_resource['documentation_url']
dockerFileText += "RUN confluent-hub install --no-prompt ${plugin_owner}/${plugin_name}:${plugin_version}\n"
readmeText+= "| ${plugin_owner}/${plugin_name} | ${plugin_version} | [Documentation](${plugin_documentation}) | [Source](${plugin_source}) |\n"
}
writeFile encoding: 'UTF-8', file: 'Dockerfile', text: dockerFileText
writeFile encoding: 'UTF-8', file: 'README.md', text: readmeText
archiveArtifacts 'Dockerfile'
}
stage('push') {
sh "echo `git add --all . && git commit -m 'Build ${BUILD_NUMBER}' .`"
sshagent(credentials: ['50a4ec3a-9caf-43d1-bfab-6465b47292da']) {
sh "git push 'git@github.com:jcustenborder/kafka-connect-all.git' master"
}
}
}
}