jenkins에서 script를 이용하여 version file 생성
# sh ../build_version.sh ${WORKSPACE}/src/main/webapp $JOB_NAME $branch $releaseVersion $addGit
# vi build_version.sh
#!/bin/sh #set -x #path=./src/main/resources file_name=version.dat path=$1/$file_name job_name=$2 branch=$3 version=$4 addgit=$5 current_time=$(date "+%Y%m%d-%H%M%S") report_path=/home/jenkins/version/${job_name}/${file_name} #echo project = $job_name #echo branch = $branch #echo version = $version echo build Time = $current_time echo addgit = $addgit echo "Build Version Infomation" > ${path} if [ ! -z $job_name ] then echo "project=$job_name" >> ${path} echo project = $job_name fi if [ ! -z $branch ] then echo "branch=$branch" >> ${path} echo branch = $branch fi if [ ! -z "$version" ] then echo "version=$version" >> ${path} echo version = $version fi echo "buildTime=$current_time" >> ${path} if [ "$addgit" == "true" ] then echo "Update build version to git on ${job_name}" git checkout ${branch} git add ${path} git commit -m "Update Build Version $version from jenkins" git push echo "Finish update build version!!" else echo finish update!! fi echo Copy Version File cp -f ${path} ${report_path} echo Finished Version File |