OpenShift 4 - DevSecOps Workshop (12) - 用CodeReady Workspace编辑提交应用代码

27 篇文章 0 订阅
5 篇文章 0 订阅

OpenShift 4.x HOL教程汇总
说明:本文已经在OpenShift 4.8环境中验证

OpenShift 4 - DevSecOps Workshop 系列视频

本节将在CodeReady中更改应用代码,在将代码推送到Gitea后确认自动触发Pipeline运行。

  1. 用浏览器打开devsecops项目中名为“codeready”的Route地址,然后登录codeready,可以看到下图界面。
    在这里插入图片描述
  2. 打开“java-eap-maven-user1”的Wrokspace,完成后界面如下图:
    在这里插入图片描述
  3. 打开“openshift-tasks/src/test/java/org/jboss/as/quickstarts/tasksrs/service/UserResourceTest.java”文件。
    在这里插入图片描述
  4. 将“getUsersSortedByTask()”方法前面的“@Ignore”注释掉,codeready会自动保存文件内容。然后将左侧窗口切换到“Source Control: Git”。因为当前文件内容已经更新了,因此在“CHANGES”区域显示“1”。在“CHANGES”上方的输入框中填入一些信息,再点击上方“对勾(Commit)”。
    在这里插入图片描述
  5. 在弹出窗口选择“Always”。
    在这里插入图片描述
  6. 点击“…”图标,然后在弹出菜单中点击Push。
    在这里插入图片描述
    在上方输入框中先输入git的用户名“user1”,然后回车;再输入密码和回车。这样修改后的代码就推送到Gitea上了。
    在这里插入图片描述
  7. 也可在窗口右侧打开“My Workspac:Workspace”,然后打开“Plugins”中“theia-xxxx”里面的“New terminal”。
    在这里插入图片描述
    然后在窗口中执行“git push”,然后在提供Gitea的用户名和密码。
    在这里插入图片描述
  8. 确认Gitea中的代码已经更改。
    在这里插入图片描述
  9. 查看“user1-cicd”项目中的“dev-tekton-tasks-triggered-xxxxx”管道运行,确认运行失败,这是由于前面注释掉的内容导致编译错误。
    在这里插入图片描述
  10. 可以在OpenShift控制台上查看“dev-tekton-tasks-triggered-xxxxx”管道运行的日志,或运行以下命令查看管道运行的日志,其中显示了“BUILD FAILURE”。
$ tkn pipelinerun logs --last -f -n ${CICD}
。。。
[test-app : mvn-goals]
[test-app : mvn-goals] -------------------------------------------------------
[test-app : mvn-goals]  T E S T S
[test-app : mvn-goals] -------------------------------------------------------
[code-analysis : mvn-goals] [INFO]
[code-analysis : mvn-goals] [INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ jboss-tasks-rs ---
[code-analysis : mvn-goals]
[code-analysis : mvn-goals] -------------------------------------------------------
[code-analysis : mvn-goals]  T E S T S
[code-analysis : mvn-goals] -------------------------------------------------------
[test-app : mvn-goals] Running org.jboss.as.quickstarts.tasksrs.service.TaskResourceTest
[test-app : mvn-goals] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.089 sec - in org.jboss.as.quickstarts.tasksrs.service.TaskResourceTest
[test-app : mvn-goals] Running org.jboss.as.quickstarts.tasksrs.service.UserResourceTest
[test-app : mvn-goals] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec <<< FAILURE! - in org.jboss.as.quickstarts.tasksrs.service.UserResourceTest
[test-app : mvn-goals] getUsersSortedByTask(org.jboss.as.quickstarts.tasksrs.service.UserResourceTest)  Time elapsed: 0.001 sec  <<< FAILURE!
[test-app : mvn-goals] org.junit.ComparisonFailure: expected:<user[2]> but was:<user[1]>
[test-app : mvn-goals]  at org.jboss.as.quickstarts.tasksrs.service.UserResourceTest.getUsersSortedByTask(UserResourceTest.java:53)
[test-app : mvn-goals]
[test-app : mvn-goals] Results :
[test-app : mvn-goals]
[test-app : mvn-goals] Failed tests:
[test-app : mvn-goals]   UserResourceTest.getUsersSortedByTask:53 expected:<user[2]> but was:<user[1]>
[test-app : mvn-goals]
[test-app : mvn-goals] Tests run: 4, Failures: 1, Errors: 0, Skipped: 0
[test-app : mvn-goals]
[test-app : mvn-goals] [INFO] ------------------------------------------------------------------------
[test-app : mvn-goals] [INFO] BUILD FAILURE
[test-app : mvn-goals] [INFO] ------------------------------------------------------------------------
[test-app : mvn-goals] [INFO] Total time: 52.645 s
[test-app : mvn-goals] [INFO] Finished at: 2021-08-19T14:33:32Z
[code-analysis : mvn-goals] Running org.jboss.as.quickstarts.tasksrs.service.TaskResourceTest
[code-analysis : mvn-goals] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.3 sec - in org.jboss.as.quickstarts.tasksrs.service.TaskResourceTest
[code-analysis : mvn-goals] Running org.jboss.as.quickstarts.tasksrs.service.UserResourceTest
[test-app : mvn-goals] [INFO] Final Memory: 28M/900M
[test-app : mvn-goals] [INFO] ------------------------------------------------------------------------
[test-app : mvn-goals] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project jboss-tasks-rs: There are test failures.
[test-app : mvn-goals] [ERROR]
[test-app : mvn-goals] [ERROR] Please refer to /workspace/source/target/surefire-reports for the individual test results.
[test-app : mvn-goals] [ERROR] -> [Help 1]
[test-app : mvn-goals] [ERROR]
[test-app : mvn-goals] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[test-app : mvn-goals] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[test-app : mvn-goals] [ERROR]
[test-app : mvn-goals] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[test-app : mvn-goals] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[code-analysis : mvn-goals] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec <<< FAILURE! - in org.jboss.as.quickstarts.tasksrs.service.UserResourceTest
[code-analysis : mvn-goals] getUsersSortedByTask(org.jboss.as.quickstarts.tasksrs.service.UserResourceTest)  Time elapsed: 0.001 sec  <<< FAILURE!
[code-analysis : mvn-goals] org.junit.ComparisonFailure: expected:<user[2]> but was:<user[1]>
[code-analysis : mvn-goals]     at org.jboss.as.quickstarts.tasksrs.service.UserResourceTest.getUsersSortedByTask(UserResourceTest.java:53)
[code-analysis : mvn-goals]
[code-analysis : mvn-goals] Results :
[code-analysis : mvn-goals]
[code-analysis : mvn-goals] Failed tests:
[code-analysis : mvn-goals]   UserResourceTest.getUsersSortedByTask:53 expected:<user[2]> but was:<user[1]>
[code-analysis : mvn-goals]
[code-analysis : mvn-goals] Tests run: 4, Failures: 1, Errors: 0, Skipped: 0
[code-analysis : mvn-goals]
[code-analysis : mvn-goals] [INFO]
[code-analysis : mvn-goals] [INFO] ------------------------------------------------------------------------
[code-analysis : mvn-goals] [INFO] Skipping JBoss EAP - Tasks JAX-RS App
[code-analysis : mvn-goals] [INFO] This project has been banned from the build due to previous failures.
[code-analysis : mvn-goals] [INFO] ------------------------------------------------------------------------
[code-analysis : mvn-goals] [INFO] ------------------------------------------------------------------------
[code-analysis : mvn-goals] [INFO] BUILD FAILURE
[code-analysis : mvn-goals] [INFO] ------------------------------------------------------------------------
[code-analysis : mvn-goals] [INFO] Total time: 55.578 s
[code-analysis : mvn-goals] [INFO] Finished at: 2021-08-19T14:33:37Z
。。。
  1. 重新在CodeReady中将代码改回来,再将代码push到Gitea,最后确认触发的管道运行能够成功完成运行。
$ tkn pipelinerun logs --last -f -n ${CICD}
。。。
[deploy-to-dev : deploy-app-from-image] Create new app from image stream in user1-dev1 project
[deploy-to-dev : deploy-app-from-image] deploymentconfig.apps.openshift.io/tekton-tasks configured
[deploy-to-dev : deploy-app-from-image] service/tekton-tasks configured
[deploy-to-dev : deploy-app-from-image] Setting manual triggers on deployment tekton-tasks
[deploy-to-dev : deploy-app-from-image] deploymentconfig.apps.openshift.io/tekton-tasks triggers updated
[deploy-to-dev : deploy-app-from-image] NAME           HOST/PORT                                                               PATH   SERVICES       PORT       TERMINATION   WILDCARD
[deploy-to-dev : deploy-app-from-image] tekton-tasks   tekton-tasks-user1-dev1.apps.cluster-39c8.39c8.sandbox139.opentlc.com          tekton-tasks   8080-tcp                 None
 
[deploy-to-dev : announce-success] Successfully build application tekton-tasks
[deploy-to-dev : announce-success] After testing the app, run the deploy-app-to-stage pipeline with 08487b4 as the app_version parameter
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值