diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100755 index 0000000..d946a71 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,69 @@ +node { + def gitHubBaseAddress = "github.com" + def hcBuildDir = "/var/lib/jenkins/workspace/hypercloud-api-server-golang" + def imageBuildHome = "${hcBuildDir}" + + def scriptHome = "${hcBuildDir}/scripts" + + def gitHcAddress = "${gitHubBaseAddress}/tmax-cloud/hypercloud-api-server.git" + + def version = "${params.majorVersion}.${params.minorVersion}.${params.tinyVersion}.${params.hotfixVersion}" + def preVersion = "${params.preVersion}" + + def imageTag = "b${version}" + + def userName = "taegeon_woo" + def userEmail = "taegeon_woo@tmax.co.kr" + + stage('git pull & Go build') { + dir(imageBuildHome){ + // git pull + sh "git checkout ${params.buildBranch}" + sh "git config --global user.name ${userName}" + sh "git config --global user.email ${userEmail}" + sh "git config --global credential.helper store" + + sh "git fetch --all" + sh "git reset --hard origin/${params.buildBranch}" + sh "git pull origin ${params.buildBranch}" + + //go build + sh "go build main.go" + } + } + + stage('image build & push'){ + dir(imageBuildHome){ + sh "sudo docker build --tag tmaxcloudck/hypercloud-api-server:${imageTag} ." + sh "sudo docker push tmaxcloudck/hypercloud-api-server:${imageTag}" + } + } + + stage('make change log'){ + sh "sudo sh ${scriptHome}/hypercloud-changelog.sh ${version} ${preVersion}" + } + + + stage('git push'){ + dir ("${imageBuildHome}") { + sh "git checkout ${params.buildBranch}" + + sh "git config --global user.name ${userName}" + sh "git config --global user.email ${userEmail}" + sh "git config --global credential.helper store" + sh "git add -A" + + sh (script:'git commit -m "[Distribution] Hypercloud-api-server- ${version} " || true') + sh "git tag v${version}" + + sh "sudo git push -u origin +${params.buildBranch}" + sh "sudo git push origin v${version}" + + sh "git fetch --all" + sh "git reset --hard origin/${params.buildBranch}" + sh "git pull origin ${params.buildBranch}" + } + } +} + + diff --git a/install_yaml/hc-api-server.yaml b/install_yaml/hc-api-server.yaml index c007e41..470d083 100644 --- a/install_yaml/hc-api-server.yaml +++ b/install_yaml/hc-api-server.yaml @@ -37,8 +37,8 @@ spec: - key: node-role.kubernetes.io/master operator: Equal effect: "NoSchedule" - nodeSelector: - kubernetes.io/hostname: ck-2 # need to be changed per Env + # nodeSelector: + # kubernetes.io/hostname: ck-2 # need to be changed per Env #imagePullSecrets: # - name : docker-pull-secret serviceAccount: hypercloud5-admin diff --git a/scripts/hypercloud-changelog.sh b/scripts/hypercloud-changelog.sh new file mode 100755 index 0000000..65b76c3 --- /dev/null +++ b/scripts/hypercloud-changelog.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# by taegeon_woo + +# destination file +output=CHANGELOG.md +timestamp=`date` +version=$1 +prev_version=$2 + +if [ -z $version ]; then +version=4.0.0.x +fi + +if [ -z $prev_version ]; then +prev_version=4.0.0.0 +fi + +backup="CHANGELOG_$prev_version.md" +if [ -f $output ]; then +echo "!!!changelog file exist" +mv $output $backup +fi + +echo "workdir: `pwd`" +echo "!!!make changelog for $version" +echo "!!!prev version: $prev_version" + +# gen file +echo "# Hypercloud-api-server changelog!!" > $output +echo "All notable changes to this project will be documented in this file." >> $output + +echo -e "\n" >> $output +echo -e "\n## Hypercloud-api-server $version ($timestamp)" >> $output + +# make commit log to changelog +echo -e "\n### Added" >> $output +git log v$prev_version..HEAD --no-merges --oneline --format=" - %s by %cN" --grep="^\[feat\].*" -i >> $output +#git log v$prev_version..HEAD --no-merges --oneline --format=" - %s by %cN" >> $output + +echo -e "\n### Changed" >> $output +git log v$prev_version..HEAD --no-merges --oneline --format=" - %s by %cN" --grep="^\[mod\].*" -i >> $output + +echo -e "\n### Fixed" >> $output +git log v$prev_version..HEAD --no-merges --oneline --format=" - %s by %cN" --grep="^\[ims\]\[[0-9]*\].*" -i >> $output + +echo -e "\n### CRD yaml" >> $output +git log v$prev_version..HEAD --no-merges --oneline --format=" - %s by %cN" --grep="^\[crd\].*" -i >> $output + +echo -e "\n### Etc" >> $output +git log v$prev_version..HEAD --no-merges --oneline --format=" - %s by %cN" --grep="^\[etc\].*" -i >> $output + +if [ -f $backup ]; then +echo "!!!add previous changelog" +sed '1,2d' $backup >> $output +rm $backup +fi + +echo "!!!done"