Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jenkins Docker Compose构建React #22

Open
jerrychir opened this issue Mar 1, 2019 · 0 comments
Open

Jenkins Docker Compose构建React #22

jerrychir opened this issue Mar 1, 2019 · 0 comments

Comments

@jerrychir
Copy link
Owner

jerrychir commented Mar 1, 2019

Jenkins docker-compose自动构建React并发布

约定

jenkins已经装了ssh、docker、git、jdk、maven等插件

1.创建一个自由风格的软件项目,命名为sangoes-web,点击确定.

image

2.配置项目描述,丢弃规则

image

3.点击git,配置git文件,url,用户名密码等

image

4.配置node构建环境,选择在系统配置里面配置好的node

image

5.点击构建选择执行shell

image

 # 安装依赖
 echo '安装依赖'
 yarn install
 # 删除打包文件
 echo '删除打包文件'
 rm -rf ./dist
 # 打包
 echo '打包'
 yarn run build
 # 复制
 echo '复制./dist至docker'
 cp -r ./dist ./docker/dist

6.点击构建后,选择send build articfacts over ssh,备份旧的文件

image

 echo "备份docker"
 cp -r /home/coach-web/docker /home/coach-web/docker-$BUILD_TIMESTAMP
 echo "启动ssh传送docker文件"

 echo "删除旧的docker"
 rm -rf /home/nickms-web/docker
 echo "启动ssh传送docker文件"

7.点击add transfer set,运行docker

image

echo "进入docker"
cd /home/coach-web/docker
echo "停止服务"
docker-compose stop coach-web
echo "删除原始的coach-web"
docker-compose rm -f coach-web
echo "删除原始的coach-web镜像"
docker rmi -f coach-web:latest
echo "构建"
docker build -t coach-web:latest .
echo "运行"
docker-compose up -d
echo "完成"

到这应该可以成功不是咯,但我遇到个问题
[Exec timed out or was interrupted after 120,000 ms] Build step 'Send build artifacts over SSH' changed build result to UNSTABLE

解决方案,点击(send build articfacts over ssh)高级,设置Exec timeout 420000

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant