forked from provectus/kafka-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial commit * added timestamps and email recipient * Revert "added timestamps and email recipient" This reverts commit 4108570 * added steps to Jenkins pipeline * added steps to Jenkins pipeline * added script for creating release notes * fixed script for creating release notes * fixed script for creating release notes * Increased version * Revert "Increased version" This reverts commit 8694905 * added steps to Jenkins pipeline * Increased version * moved ci-cd from ci-cd branch to master * Revert "Increased version" This reverts commit 666ee94 * fixes in pipeline * fixed version for docker * fixed version for docker * testing PR build * testing PR build * testing PR build * testing PR build * testing PR build * added conditions to jenkinsfile * testing PR build * testing PR build * testing PR build * testing PR build * testing PR build * testing PR build * testing PR build * testing PR build * testing PR build * testing PR build * testing PR build * fixed release_json.sh script * fixed release_json.sh script * fixed release_json.sh script * testing PR build * testing PR build Co-authored-by: Bulat Yusupov <byusupov@provectus.com> Co-authored-by: 66632 <>
- Loading branch information
Showing
2 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
def VERSION | ||
|
||
pipeline { | ||
options { | ||
disableConcurrentBuilds() | ||
} | ||
|
||
tools { | ||
maven 'mvn_3.6.3' | ||
} | ||
|
||
environment { | ||
registry = "provectuslabs/kafka-ui-api" | ||
registryCredential = 'docker-hub-credentials' | ||
} | ||
|
||
agent { | ||
kubernetes { | ||
label 'kafka-ui' | ||
yaml ''' | ||
apiVersion: v1 | ||
kind: Pod | ||
spec: | ||
containers: | ||
- name: docker-client | ||
image: docker:19.03.1 | ||
command: | ||
- sleep | ||
args: | ||
- 99d | ||
env: | ||
- name: DOCKER_HOST | ||
value: tcp://localhost:2375 | ||
volumeMounts: | ||
- name: cache | ||
mountPath: /tmp/repository | ||
- name: docker-daemon | ||
image: docker:19.03.1-dind | ||
securityContext: | ||
privileged: true | ||
env: | ||
- name: DOCKER_TLS_CERTDIR | ||
value: "" | ||
volumeMounts: | ||
- name: cache | ||
mountPath: /var/lib/docker | ||
volumes: | ||
- name: cache | ||
hostPath: | ||
path: /tmp | ||
type: Directory | ||
''' | ||
} | ||
} | ||
stages { | ||
stage('Checkout release branch') { | ||
when { | ||
expression { return env.GIT_BRANCH == 'origin/master'; } | ||
} | ||
steps { | ||
sh 'git checkout -b release' | ||
} | ||
} | ||
stage('Merge to release branch') { | ||
when { | ||
expression { return env.GIT_BRANCH == 'origin/master'; } | ||
} | ||
steps { | ||
sh 'git merge origin/master' | ||
} | ||
} | ||
stage('Remove SNAPSHOT from version') { | ||
steps { | ||
container('docker-client') { | ||
sh "docker run -v $WORKSPACE:/usr/src/mymaven -v /tmp/repository:/root/.m2/repository -w /usr/src/mymaven maven:3.6.3-jdk-13 bash -c 'mvn versions:set -DremoveSnapshot'" | ||
} | ||
} | ||
} | ||
stage('Tag release branch') { | ||
when { | ||
expression { return env.GIT_BRANCH == 'origin/master'; } | ||
} | ||
steps { | ||
script { | ||
pom = readMavenPom file: 'pom.xml' | ||
VERSION = pom.version | ||
sh "git tag -f v$VERSION" | ||
} | ||
} | ||
} | ||
stage('Build artifact') { | ||
steps { | ||
container('docker-client') { | ||
sh "docker run -v $WORKSPACE:/usr/src/mymaven -v /tmp/repository:/root/.m2/repository -w /usr/src/mymaven maven:3.6.3-jdk-13 bash -c 'mvn clean install'" | ||
} | ||
} | ||
} | ||
stage('Build docker image') { | ||
steps { | ||
container('docker-client') { | ||
dir(path: './kafka-ui-api') { | ||
script { | ||
dockerImage = docker.build( registry + ":$VERSION", "--build-arg JAR_FILE=*.jar -f Dockerfile ." ) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
stage('Publish docker image') { | ||
when { | ||
expression { return env.GIT_BRANCH == 'origin/master'; } | ||
} | ||
steps { | ||
container('docker-client') { | ||
script { | ||
docker.withRegistry( '', registryCredential ) { | ||
dockerImage.push() | ||
dockerImage.push('latest') | ||
} | ||
} | ||
} | ||
} | ||
} | ||
stage('Remove unused docker image') { | ||
steps{ | ||
container('docker-client') { | ||
sh "docker rmi $registry:$VERSION" | ||
} | ||
} | ||
} | ||
stage('Create github release with text from commits') { | ||
when { | ||
expression { return env.GIT_BRANCH == 'origin/master'; } | ||
} | ||
steps { | ||
script { | ||
withCredentials([usernamePassword(credentialsId: 'github-jenkins-internal-provectus', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USER')]) { | ||
sh "git push -f --tags https://$GIT_USER:$GIT_PASSWORD@github.com/provectus/kafka-ui.git" | ||
sh "bash release_json.sh v$VERSION" | ||
sh "curl -XPOST -u $GIT_USER:$GIT_PASSWORD --data @/tmp/release.json https://api.github.com/repos/provectus/kafka-ui/releases" | ||
} | ||
} | ||
} | ||
} | ||
stage('Checkout master') { | ||
when { | ||
expression { return env.GIT_BRANCH == 'origin/master'; } | ||
} | ||
steps { | ||
sh 'git checkout origin/master' | ||
} | ||
} | ||
stage('Increase version in master') { | ||
when { | ||
expression { return env.GIT_BRANCH == 'origin/master'; } | ||
} | ||
steps { | ||
container('docker-client') { | ||
sh "docker run -v $WORKSPACE:/usr/src/mymaven -v /tmp/repository:/root/.m2/repository -w /usr/src/mymaven maven:3.6.3-jdk-13 bash -c 'mvn build-helper:parse-version versions:set -DnewVersion=\\\${parsedVersion.majorVersion}.\\\${parsedVersion.minorVersion}.\\\${parsedVersion.nextIncrementalVersion}-SNAPSHOT versions:commit'" | ||
} | ||
} | ||
} | ||
stage('Push to master') { | ||
when { | ||
expression { return env.GIT_BRANCH == 'origin/master'; } | ||
} | ||
steps { | ||
script { | ||
withCredentials([usernamePassword(credentialsId: 'github-jenkins-internal-provectus', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USER')]) { | ||
sh "git add ." | ||
sh "git -c user.name=\"$GIT_USER\" -c user.email=\"\" commit -m \"Increased version in pom.xml\"" | ||
sh "git push https://$GIT_USER:$GIT_PASSWORD@github.com/provectus/kafka-ui.git HEAD:master" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
post { | ||
always { | ||
cleanWs() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
last_tag=$(git describe --tags --abbrev=0) | ||
|
||
if [ -z "$last_tag" ]; then | ||
last_tag="HEAD" | ||
else | ||
last_tag="$last_tag..HEAD" | ||
fi | ||
|
||
commits_list=$(git --no-pager log $last_tag --oneline --pretty=format:"- %s\\n" | uniq | tr -d '\n' | sed 's/\"/\\"/g') | ||
|
||
echo '{"tag_name":"'$1'","name":"'$1'","body":"'$commits_list'"}' > /tmp/release.json |