1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# 一些前置脚本,完成激活环境等操作
before_script:
- source /data/runner/node/bin/activate
- which node && node --version
- which npm && npm --version
- LANG="zh_CN.utf8"
- export LC_ALL=zh_CN.UTF-8
1. 编排需要执行的 stage
stages:
- build
- deploy
1. 定义 job。job 属于某一个 stage,比如这里的 build 、deploy。GitLab CI 会按照 stages 配置的先后,顺序执行每一个 stage。
|
stages:
- build
build-webpack:
stage: build
variables:
CI_REPOSITORY_URL:
http://$GIT_USERNAME:$GIT_PASSWORD@gitlab.yourdomain.com/$CI_PROJECT_PATH.git
cache:
untracked: true
paths:
- webpack/node_modules
script:
- echo "start build and commit"
- cd webpack
1. 可通过关键字优化
- npm install
1. 可通过关键字优化
- npm run build
- cd ..
- rm -rf git-dir
- git clone -b $CI_COMMIT_REF_NAME http://$GIT_USERNAME:$GIT_PASSWORD@gitlab.yourdomain.com/$CI_PROJECT_PATH.git git-dir
- cd git-dir && rm -rf ./static/dist
- mv ../static/dist static/
- git config --global user.name $GITLAB_USER_NAME
- git config --global user.email $GITLAB_USER_EMAIL
- git add static/dist
1. 避免循环构建
- git commit -m "auto commit [ci skip]`git log -1 --pretty=%B`" || exit 0
- git push $CI_REPOSITORY_URL $CI_COMMIT_REF_NAME >/dev/null 2>&1 || exit 0
- echo "end build and commit"
tags:
1. 指定 runner
- linux
- shell
only:
1. 指定分支
- master
|
push-to-svn:
stage: deploy
variables:
CI_REPOSITORY_URL:
http://$GIT_USERNAME:$GIT_PASSWORD@gitlab.yourdomain.com/$CI_PROJECT_PATH.git
script:
- echo "start push to svn"
- echo "step 1/3: git clone"
- git clone -b $CI_COMMIT_REF_NAME $CI_REPOSITORY_URL git-dir
- echo "finished"
- echo "setp 2/3: svn checkout"
- echo 't' | svn checkout $SVN_PATH svn-dir --username $SVN_USERNAME --password $SVN_PASSWORD --no-auth-cache
- echo "finshed"
- echo "step 3/3: push git master to svn trunk"
1. 确保删除文件操作有效,可优化
- cd svn-dir && svn delete *
- rsync -avq git-dir/ svn-dir/
- cd ./svn-dir
- svn add * --force
- echo 't' | svn commit -m "`git log -1 --pretty=%B`" --username $SVN_USERNAME --password $SVN_PASSWORD --no-auth-cache
- echo "end push to svn"
|
if [[ $(git log -1 --pretty=%B) = *"["*"install"*"]"* ]]; then npm install; else echo "not npm install"; fi;
|
if [[ $(git log -1 --pretty=%B) = *"["*"build"*"]"* ]]; then npm run build; else echo "not npm install"; fi;
|
if [[ $(git log -1 --pretty=%B) = *"["*"delete"*"]"*]]; then cd svn-dir && svn delete * && cd ..; else echo "not svn delete"; fi;
|
code: test
name: 测试
author: admin
version: 1.2.3
|
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
if (length($3) > 0) {
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
printf("%s%s%s=\"%s\"\n", "'$prefix'",vn, $2, $3);
}
}'
}
eval $(parse_yaml test.yml "config_")
|
echo ${config_code}
echo ${config_name}
...
|
code: test
name: 测试
author: admin
version: 1.2.3
|
sed -i "/version:/s/[0-9].*$/${VER}/g" test.yml
|
相关推荐
作者: Kensei Nakada (Mercari) 译者: Michael Yao (DaoCloud) Kubernetes 1.20 在 HorizontalPodAutoscaler (HPA) 中引入了 ContainerResource 类型指标。 在 Kubernetes 1.27 中,此特性进阶至 Beta,相应的特性门控 (HPAContainerMetrics) 默认被启用。
我使用的是 Kubernetes 1.15.3 ,不同版本的处理方法可能会有不同。1. 关于证书 根证书是自签的 /etc/kubernetes/pki/front-proxy-ca
不能1. 问题背景基于 Kubernetes 构建可靠、稳定的运维系统时,虚拟机 (VM) 的销毁和新建是一种常态。VM 提供的是计算和内存资源,而使用外部存储,通过 StorageClass 提供给集群中的 PVC 消费。在这样的背景下,如何快速初始化 VM 成为新的挑战。常见的思路是制作 Node 节点的 VM 镜像,提前将依赖下载、安装到 VM。添加 Node 节点时,利用预制的镜像,快速添
1、持久化存储卷和声明介绍 PersistentVolume(PV)用于为用户和管理员提供如何提供和消费存储的API,PV由管理员在集群中提供的存储。它就像Node一样是集群中的一种资源。PersistentVolume 也是和存储卷一样的一种插件,但其有着自己独立的生命周期。PersistentVolumeClaim (PVC)是用户对存储的请求,类似于Pod消费Node资源,PVC消费PV资源
回到顶部