Merge pull request #1709 from Felixnoo/update-go-pipeline
Update Doc: Build and Deploy a Go Project
|
|
@ -36,7 +36,7 @@ You need to create credentials in KubeSphere for the access token created so tha
|
|||
|
||||
1. Log in to the web console of KubeSphere as `project-regular`. Go to your DevOps project and click **Create** in **Credentials**.
|
||||
|
||||

|
||||

|
||||
|
||||
2. In the dialog that appears, set a **Credential ID**, which will be used later in the Jenkinsfile, and select **Account Credentials** for **Type**. Enter your Docker Hub account name for **Username** and the access token just created for **Token/Password**. When you finish, click **OK**.
|
||||
|
||||
|
|
@ -58,21 +58,21 @@ With the above credentials ready, you can create a pipeline using an example Jen
|
|||
|
||||
1. To create a pipeline, click **Create** on the **Pipelines** page.
|
||||
|
||||

|
||||

|
||||
|
||||
2. Set a name in the pop-up window and click **Next** directly.
|
||||
|
||||

|
||||

|
||||
|
||||
3. In this tutorial, you can use default values for all the fields. In **Advanced Settings**, click **Create** directly.
|
||||
|
||||

|
||||

|
||||
|
||||
## Edit the Jenkinsfile
|
||||
|
||||
1. In the pipeline list, click this pipeline to go to its detail page. Click **Edit Jenkinsfile** to define a Jenkinsfile and your pipeline runs based on it.
|
||||
|
||||

|
||||

|
||||
|
||||
2. Copy and paste all the content below to the pop-up window as an example Jenkinsfile for your pipeline. You must replace the value of `DOCKERHUB_USERNAME`, `DOCKERHUB_CREDENTIAL`, `KUBECONFIG_CREDENTIAL_ID`, and `PROJECT_NAME` with yours. When you finish, click **OK**.
|
||||
|
||||
|
|
@ -83,22 +83,22 @@ With the above credentials ready, you can create a pipeline using an example Jen
|
|||
label 'maven'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
environment {
|
||||
// the address of your harbor registry
|
||||
// the address of your Docker Hub registry
|
||||
REGISTRY = 'docker.io'
|
||||
// your docker hub username
|
||||
DOCKERHUB_USERNAME = 'yuswift'
|
||||
// docker image name
|
||||
// your Docker Hub username
|
||||
DOCKERHUB_USERNAME = 'Docker Hub Username'
|
||||
// Docker image name
|
||||
APP_NAME = 'devops-go-sample'
|
||||
// ‘dockerhubid’ is the credential id you created in KubeSphere for docker access token
|
||||
// ‘dockerhubid’ is the credentials ID you created in KubeSphere with Docker Hub Access Token
|
||||
DOCKERHUB_CREDENTIAL = credentials('dockerhubid')
|
||||
//the kubeconfig credential id you created in KubeSphere
|
||||
// the kubeconfig credentials ID you created in KubeSphere
|
||||
KUBECONFIG_CREDENTIAL_ID = 'go'
|
||||
// the name of the project you created in KubeSphere, not the DevOps project name
|
||||
PROJECT_NAME = 'devops-go'
|
||||
}
|
||||
|
||||
|
||||
stages {
|
||||
stage('docker login') {
|
||||
steps{
|
||||
|
|
@ -107,7 +107,7 @@ With the above credentials ready, you can create a pipeline using an example Jen
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stage('build & push') {
|
||||
steps {
|
||||
container ('maven') {
|
||||
|
|
@ -138,18 +138,18 @@ If your pipeline runs successfully, images will be pushed to Docker Hub. If you
|
|||
|
||||
1. After you finish the Jenkinsfile, you can see graphical panels display on the dashboard. Click **Run** to run the pipeline.
|
||||
|
||||

|
||||

|
||||
|
||||
2. In **Activity**, you can see the status of the pipeline. It may take a while before it successfully runs.
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
## Verify Results
|
||||
|
||||
1. A **Deployment** will be created in the project specified in the Jenkinsfile if the pipeline runs successfully.
|
||||
|
||||

|
||||

|
||||
|
||||
2. Check whether the image is pushed to Docker Hub as shown below:
|
||||
|
||||
|
|
|
|||
|
|
@ -36,11 +36,11 @@ weight: 11410
|
|||
|
||||
1. 以 `project-regular` 身份登录 KubeSphere Web 控制台,转到您的 DevOps 工程,在**凭证**页面点击**创建**。
|
||||
|
||||

|
||||

|
||||
|
||||
2. 在弹出对话框中,设置**凭证 ID**,稍后会用于 Jenkinsfile 中,**类型**选择**帐户凭证**。**用户名**输入您的 Docker Hub 帐户名称,**token / 密码**中输入刚刚创建的访问令牌。操作完成后,点击**确定**。
|
||||
|
||||

|
||||

|
||||
|
||||
{{< notice tip >}}
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ weight: 11410
|
|||
|
||||
1. 在流水线列表中,点击该流水线进入其详情页面。点击**编辑 Jenkinsfile** 定义一个 Jenkinsfile,流水线会基于它来运行。
|
||||
|
||||

|
||||

|
||||
|
||||
2. 将以下所有内容复制并粘贴到弹出窗口中,用作流水线的示例 Jenkinsfile。您必须将 `DOCKERHUB_USERNAME`、`DOCKERHUB_CREDENTIAL`、`KUBECONFIG_CREDENTIAL_ID` 和 `PROJECT_NAME` 的值替换成您自己的值。操作完成后,点击**确定**。
|
||||
|
||||
|
|
@ -83,22 +83,22 @@ weight: 11410
|
|||
label 'maven'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
environment {
|
||||
// the address of your harbor registry
|
||||
// 您 Docker Hub 仓库的地址
|
||||
REGISTRY = 'docker.io'
|
||||
// your docker hub username
|
||||
DOCKERHUB_USERNAME = 'yuswift'
|
||||
// docker image name
|
||||
// 您的 Docker Hub 用户名
|
||||
DOCKERHUB_USERNAME = 'Docker Hub Username'
|
||||
// Docker 镜像名称
|
||||
APP_NAME = 'devops-go-sample'
|
||||
// ‘dockerhubid’ is the credential id you created in KubeSphere for docker access token
|
||||
// ‘dockerhubid’ 是您在 KubeSphere 用 Docker Hub 访问令牌创建的凭证 ID
|
||||
DOCKERHUB_CREDENTIAL = credentials('dockerhubid')
|
||||
//the kubeconfig credential id you created in KubeSphere
|
||||
// 您在 KubeSphere 创建的 kubeconfig 凭证 ID
|
||||
KUBECONFIG_CREDENTIAL_ID = 'go'
|
||||
// the name of the project you created in KubeSphere, not the DevOps project name
|
||||
// 您在 KubeSphere 创建的项目名称,不是 DevOps 工程名称
|
||||
PROJECT_NAME = 'devops-go'
|
||||
}
|
||||
|
||||
|
||||
stages {
|
||||
stage('docker login') {
|
||||
steps{
|
||||
|
|
@ -107,7 +107,7 @@ weight: 11410
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stage('build & push') {
|
||||
steps {
|
||||
container ('maven') {
|
||||
|
|
@ -138,18 +138,18 @@ weight: 11410
|
|||
|
||||
1. Jenkinsfile 设置完成后,您可以在仪表板上查看图形面板。点击**运行**来运行流水线。
|
||||
|
||||

|
||||

|
||||
|
||||
2. 在**活动**选项卡中,您可以查看流水线的状态。稍等片刻,流水线便会成功运行。
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
## 验证结果
|
||||
|
||||
1. 如果流水线成功运行,则会在 Jenkinsfile 中指定的项目中创建一个**部署 (Deployment)**。
|
||||
|
||||

|
||||

|
||||
|
||||
2. 查看镜像是否已推送至 Docker Hub,如下所示:
|
||||
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 93 KiB |
|
After Width: | Height: | Size: 600 KiB |
|
Before Width: | Height: | Size: 84 KiB |
|
After Width: | Height: | Size: 462 KiB |
|
Before Width: | Height: | Size: 85 KiB |
|
After Width: | Height: | Size: 198 KiB |
|
Before Width: | Height: | Size: 84 KiB |
|
After Width: | Height: | Size: 562 KiB |
|
Before Width: | Height: | Size: 83 KiB |
|
After Width: | Height: | Size: 197 KiB |
|
Before Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 747 KiB |
|
Before Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 131 KiB |
|
Before Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 602 KiB |
|
Before Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 560 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 568 KiB |
|
Before Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 543 KiB |
|
Before Width: | Height: | Size: 124 KiB |
|
After Width: | Height: | Size: 330 KiB |
|
Before Width: | Height: | Size: 71 KiB |
|
After Width: | Height: | Size: 576 KiB |