-
Notifications
You must be signed in to change notification settings - Fork 0
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 getting start #39
Comments
Jenkins 初探[TOC] 安装本次通过 docker 安装。
运行 Jenkins
这条命令需要注意的是
用浏览器打开 loacalhost:8080 再将 terminal 中的 password 粘贴进 jenkins 初始界面,我们就能到创建用户和安装插件的基面了。 docker ps #记下 container id.
docker exec -it container_id /bin/bash #进入 container 的 bash
vi /var/jenkins_home/config.xml
这个时候 jenkins 默认就不需要用户登录了(生产环境请不要这么玩) 创建任务将官方提供的 repo clone 下来 git clone https://github.com/gilesgas/simple-node-js-react-npm-app-original.git
Build回到 clone 的 repo,在根目录下创建
这个文件的含义是
将提交 push,jenkins 会自动 trigger 一个 task。 Test等 build 跑完之后我们再修改 pipeline {
agent {
docker {
image 'node:6-alpine'
args '-p 3000:3000'
}
}
+ environment {
+ CI = 'true'
+ }
stages {
stage('Build') {
steps {
sh 'npm install'
}
}
+ stage('Test') {
+ steps {
+ sh './jenkins/scripts/test.sh'
+ }
}
}
}
第一个新增的 section 代表将 CI 环境变量设置为 true,这个环境变量在整个 pipeline 中都可见。 这个时候安装 yarn add cross-env --dev - "test": "react-scripts test --env=jsdom",
+ "test": "cross-env CI=true react-scripts test --env=jsdom", 把代码推到远程,这个时候再去 Jenkins 上点击 Delivery终于来到最后部署步骤,仍然修改 Jenkinsfile 为: pipeline {
agent {
docker {
image 'node:6-alpine'
args '-p 3000:3000'
}
}
environment {
CI = 'true'
}
stages {
stage('Build') {
steps {
sh 'npm install'
}
}
stage('Test') {
steps {
sh './jenkins/scripts/test.sh'
}
}
+ stage('Deliver') {
+ steps {
+ sh './jenkins/scripts/deliver.sh'
+ input message: 'Finished using the web site? (Click "Proceed" to continue)'
+ sh './jenkins/scripts/kill.sh'
+ }
+ }
}
} 重复上面的动作,这里需要注意的是 input 那行代码,此代码会在执行完之前的步骤后出现 知识点
参考资料 |
No description provided.
The text was updated successfully, but these errors were encountered: