加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Jenkinsfile 2.85 KB
一键复制 编辑 原始数据 按行查看 历史
maoguy 提交于 2023-07-26 06:51 . update Jenkinsfile.
#!groovy
@Library("library@master") _
build_script = '''
echo "------build_start------"
echo "${WORKSPACE}"
docker pull ${BUILD_IMAGE_TOOL}
docker run -t --init --cap-add=SYS_ADMIN --rm -v ${WORKSPACE}:/app ${BUILD_IMAGE_TOOL} bash -c "cd /app && apt-get install g++ make python3 && \
npm install node-gyp --registry=https://registry.npmmirror.com && \
yarn config set registry https://registry.npmmirror.com && \
yarn config set disturl https://npmmirror.com/mirrors/node/ && \
yarn config set iltorb_binary_host https://mirrors.apusic.com/src/iltorb
yarn && \
yarn site"
echo "------build_end------"
'''
deploy_script = '''
echo "------deploy_start------"
cd ${DEPLOY_DIR}
tar xvf _site.tgz
echo "------deploy_end------"
'''
def _config = [
agent:[
label:'ubuntu-node'
],
environment: [
DISABLE_PROXY: true ,
BUILD_IMAGE_TOOL: 'harbor.apusic.com/library/node:14' ,
DEPLOY_HOST: '172.18.100.65',
DEPLOY_DIR: '/root/lao/apusic-ui',
],
parameters: [
[
string: [
defaultValue: 'dev',
description: '分支名称',
name:'branch'
],
booleanParam: [
defaultValue: false,
description: '清空工作空间',
name:'clean'
],
]
],
triggers:[
gitee: "dev",
cron: 'H 23 * * *'
],
checkout: [
url: "https://gitee.com/apusic-frontend/apusic-ui.git",
disableSubmodules: true
],
stages:[
[
stage:"build_UI",
alwaysPass:false,
timeout:15,
steps:[
localScript:[
[text: build_script]
]
]
],
[
stage:"archive_UI",
alwaysPass:false,
timeout:15,
when: [
not:[
[triggeredBy: "TimerTrigger"]
]
],
steps:[
archiveArtifacts: [
artifacts: "_site",
packaging: "tgz" ,
filepath: "_site.tgz"
]
]
],
[
stage:"deploy_UI",
alwaysPass:false,
timeout:20,
when:[not:[triggeredBy:"TimerTrigger"]],
steps:[
sshCopy:[
src:'_site.tgz',
dest:'${DEPLOY_DIR}',
hosts:'${DEPLOY_HOST}'
],
sshScript:[
text: deploy_script,
hosts:'${DEPLOY_HOST}'
]
]
]
]
]
pipelineLoad(_config);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化