|
variables: DIR: nginx
TOPNODE: package
.function: &function |
function build() {
echo "execute function:build"
chmod +x auto/configure
sh build.sh
}
function changelog() {
echo "execute function:changelog"
git log --graph -n 3 --name-status --pretty="%h -[%cd] - %s" > CHANGELOG
}
function test() {
echo "execute function:test"
sudo \cp modules/nginx-upload-module-master/nginx.conf /etc/nginx/nginx.conf
sudo sed -i '/error_log/,/working_directory/d' /etc/nginx/nginx.conf
if [ -f /run/nginx.pid ];then sudo nginx -s> sudo rm -rf /tmp/{0,1,2,3,4,5,6,7,8,9} && sudo mkdir /tmp/{0,1,2,3,4,5,6,7,8,9} && sudo chown -R nginx. /tmp/{0,1,2,3,4,5,6,7,8,9}
sudo echo nginx_upload > test && curl -F "filename=@test" http://localhost/upload
sudo find /tmp/{0,1,2,3,4,5,6,7,8,9} -type f -exec grep nginx_upload {} \;
}
function artifacts() {
echo "execute function:artifacts"
URL="https://xxx.com/upload?dir=${DIR}/${VERSION}&override=1&topNode=${TOPNODE}"
echo "push the artifacts:nginx_${VERSION}.tar.gz to $URL"
tar zcf /tmp/nginx_${VERSION}.tar.gz --exclude=".git*" --exclude=build .
curl -F "filename=@/tmp/${DIR}_${VERSION}.tar.gz" "$URL"
echo "push the CHANGELOG to $URL"
curl -F "filename=@CHANGELOG" "$URL"
}
function deploy() {
echo "execute function:deploy"
}
function clean() {
echo "execute function:clean"
if [ -f /run/nginx.pid ];then sudo kill `cat /run/nginx.pid`;fi
sudo rm -rf /tmp/{0,1,2,3,4,5,6,7,8,9} /tmp/nginx_${version}.tar.gz
}
#########only the section above need to be modify #################
before_script:
- VERSION=`head -n1 version`
- *function
stages:
- build
- test
- deploy
build:
stage: build
only:
- branches
except:
- master
script:
- build
- changelog
test:
stage: test
variables:
GIT_STRATEGY: none
only:
- branches
except:
- master
script:
- test
- artifacts
- clean
.job_template: &deploy_template
stage: deploy
variables:
GIT_STRATEGY: none
only:
- tags
script:
- deploy
- delete
when: manual
staging:
|
|
|