Skip to content

Commit

Permalink
[feat] build & Distribution system
Browse files Browse the repository at this point in the history
  • Loading branch information
dnxorjs1 committed Jan 20, 2021
1 parent 5e3736d commit 86d4819
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 2 deletions.
69 changes: 69 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"

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}"
}
}
}


4 changes: 2 additions & 2 deletions install_yaml/hc-api-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 58 additions & 0 deletions scripts/hypercloud-changelog.sh
Original file line number Diff line number Diff line change
@@ -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<!-------------------- v$version start -------------------->" >> $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"

0 comments on commit 86d4819

Please sign in to comment.