Skip to content

Commit

Permalink
Refine the readme file
Browse files Browse the repository at this point in the history
Signed-off-by: PeiHongbing1223 <peihongbing1223@gmail.com>
  • Loading branch information
PeiHongbing1223 committed Feb 25, 2021
1 parent 5ca304e commit cf94241
Showing 1 changed file with 4 additions and 43 deletions.
47 changes: 4 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,6 @@ Jenkinsfile in SCM 意为将 Jenkinsfile 文件本身作为源代码管理 (Sour

考虑到初学者可能对Jenkins文件不熟悉,对此文件进行介绍,方便您理解我们的流水线做了什么.

``` yaml
pipeline {
agent {
node {
label 'maven' // 定义流水线的代理为 maven,kubesphere内置了四个默认代理,在目前版本当中我们内置了 4 种类型的 podTemplate,base、 // nodejs、maven、go,并且在 Pod 中提供了隔离的 Docker 环境。具体参见官方文档
}
}

parameters {
string(name:'TAG_NAME',defaultValue: '',description:'') //定义 流水线描述
}
environment { //定义流水线环境变量
DOCKER_CREDENTIAL_ID = 'dockerhub-id'
GITHUB_CREDENTIAL_ID = 'github-id'
KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig'
REGISTRY = 'docker.io'
DOCKERHUB_NAMESPACE = 'docker_username'
GITHUB_ACCOUNT = 'kubesphere'
APP_NAME = 'devops-java-sample'
}
```

**[Jenkins Agent 说明]( https://v2-1.docs.kubesphere.io/docs/zh-CN/devops/jenkins-agent/)**

* **第一步**检出代码
Expand All @@ -71,24 +49,7 @@ Jenkinsfile in SCM 意为将 Jenkinsfile 文件本身作为源代码管理 (Sour
}
```

* **第三步** 执行单元测试

```yaml
stage('push latest'){
when{
branch 'master'
}
steps{
container ('maven') {
sh 'docker tag $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:latest '
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:latest '
}
}
}

```

* **第四步** 编译并推送
* **第三步** 编译并推送

```yaml
stage ('build & push') {
Expand All @@ -105,7 +66,7 @@ Jenkinsfile in SCM 意为将 Jenkinsfile 文件本身作为源代码管理 (Sour
}
```

* **第五步** 推送至docker hub latest版本
* **第四步** 推送至docker hub latest版本

```yaml
stage('push latest'){
Expand All @@ -122,7 +83,7 @@ Jenkinsfile in SCM 意为将 Jenkinsfile 文件本身作为源代码管理 (Sour

```

* **第六步** 弹出审核确认,是否部署到开发环境
* **第五步** 弹出审核确认,是否部署到开发环境

```yaml
stage('deploy to dev') {
Expand Down Expand Up @@ -156,7 +117,7 @@ Jenkinsfile in SCM 意为将 Jenkinsfile 文件本身作为源代码管理 (Sour
}
```

* **第七步** 部署到生产环境
* **第六步** 部署到生产环境

```yaml
stage('deploy to production') {
Expand Down

0 comments on commit cf94241

Please sign in to comment.