当前位置: 首页 > 文档资料 > 技术文档 Cookbook >

SCM Web Hooks

优质
小牛编辑
137浏览
2023-12-01

In this recipe we will demonstrate the deployment of a very simple application via a GitHub Web Hook trigger.

Create a project

$ oc new-project scm-web-hooks --display-name="Test WebHooks"

Create new application

We will use the forked repository from the previous recipe.

$ oc new-app -S --image-stream=php
Image streams (oc new-app --image-stream=<image-stream> [--code=<source>])
-----
php
  Project: openshift
  Tags:    5.6, 7.0, latest

$ oc new-app --image-stream=php --code=https://github.com/jbosschina/bluegreen.git --name=scm-web-hooks
--> Found image 79f7d44 (8 weeks old) in image stream "openshift/php" under tag "7.0" for "php"

    Apache 2.4 with PHP 7.0
    -----------------------
    Platform for building and running PHP 7.0 applications

    Tags: builder, php, php70, rh-php70

    * The source repository appears to match: php
    * A source build using source code from https://github.com/jbosschina/bluegreen.git will be created
      * The resulting image will be pushed to image stream "scm-web-hooks:latest"
      * Use 'start-build' to trigger a new build
    * This image will be deployed in deployment config "scm-web-hooks"
    * Port 8080/tcp will be load balanced by service "scm-web-hooks"
      * Other containers can access this service through the hostname "scm-web-hooks"

--> Creating resources ...
    imagestream "scm-web-hooks" created
    buildconfig "scm-web-hooks" created
    deploymentconfig "scm-web-hooks" created
    service "scm-web-hooks" created
--> Success
    Build scheduled, use 'oc logs -f bc/scm-web-hooks' to track its progress.
    Run 'oc status' to view your app.

Look at some of the created resources

  • Build configuration

$ oc get bc
  • Deployment configuration

$ oc get dc
  • Show created service

$ oc get service
  • Show replication controller

$ oc get rc
  • Show route

$ oc get route

Notice that there is no route created yet for this application.

  • Show the builds in progress (Running)

$ oc get builds
NAME              TYPE      STATUS    POD
scm-web-hooks-1   Source    Running   scm-web-hooks-1-build
  • Monitor the build

$ oc logs build/scm-web-hooks-1

The build should finish similar to:

Pushing image 172.30.160.227:5000/scm-web-hooks-admin/scm-web-hooks:latest ...
Pushed 0/5 layers, 2% complete
Pushed 1/5 layers, 22% complete
Pushed 2/5 layers, 44% complete
Pushed 3/5 layers, 70% complete
Pushed 3/5 layers, 100% complete
Pushed 4/5 layers, 100% complete
Pushed 5/5 layers, 100% complete
Push successful

Create a route

$ oc expose service scm-web-hooks
route "scm-web-hooks" exposed

Test the application

Use scm-web-hooks-scm-web-hooks.apps.example.com to access the app, you should see

blue_deployment

Navigate to the OpenShift Web console and login.

  • Navigate to the OpenShift Web console and login.

  • Select your Test WebHooks project, and click Builds and then Builds.

  • Click onto the build name from the list. You should have just one in this case.

  • Click Configuration tab to get list of Triggers for the GitHub link.

  • Copy the GitHub webhook URL. You will need this URL for next step.

github_show_url

Configure GitHub repository Web Hook

  • Login to your GitHub account.

  • Navigate to the forked repository you used to create the application.

  • Click on Settings.

  • Click on Webhooks.

  • Click on the Add webhook button.

  • Add the recently copied Web Hook URL from OpenShift.

  • Change the Content-type as "application/json"

  • Click on the Disable SSL Verification button.

  • Confirm by adding the Add Webhook button in green at the bottom of the page.

Redeploy the application

  • Edit in your GitHub account the image.php file.

  • One of the lines in line 9 or 10 should be commented out. Make a change so that the line that was previously commented out becomes active and pound the other one.

  • Commit the file.

Monitor new deployment process

  • After saving/committing the image.php file with the small change, you’ll notice in the OpenShift Web Console that a new build process has been automatically triggered. You didn’t have to start a build yourself.

  • Monitor the build process using:

$ oc get builds

$ oc logs builds/scm-web-hooks-2
Cloning "https://github.com/jbosschina/bluegreen.git" ...
	Commit:	4969a28fd786392b20750987d9b5aa026e9cc63f (update image color)
	Author:	kylin <kylinsoong.1214@gmail.com>
	Date:	Sun Jul 16 18:46:08 2017 +0800
---> Installing application source...
Pushing image 172.30.160.227:5000/scm-web-hooks/scm-web-hooks:latest ...
Pushed 4/5 layers, 81% complete
Pushed 5/5 layers, 100% complete
Push successful

最后更新:

类似资料

  • 认证(Authentication) 身份验证是大多数现有应用程序的重要组成部分。有许多不同的方法、策略和方法来处理用户授权。我们最终决定使用什幺取决于特定的应用程序要求,并且与它们的需求密切相关。 passport 是目前最流行的 node.js 认证库,为社区所熟知,并相继应用于许多生产应用中。将此工具与 Nest 框架集成起来非常简单。为了演示,我们将设置 passport-http-bea

  • 下面是一个 XML 技术的列表。 XHTML (可扩展 HTML) 更严格更纯净的基于 XML 的 HTML 版本。 XML DOM (XML 文档对象模型) 访问和操作 XML 的标准文档模型。 XSL (可扩展样式表语言) XSL 包含三个部分: XSLT (XSL 转换) - 把 XML 转换为其他格式,比如 HTML XSL-FO (XSL 格式化对象)- 用于格式化 XML 文档的语言

  • AJAX不能独立工作。 它与其他技术结合使用来创建交互式网页。 JavaScript 松散类型的脚本语言。 在页面中发生事件时调用JavaScript函数。 整个AJAX操作的胶水。 DOM 用于访问和操作结构化文档的API。 表示XML和HTML文档的结构。 CSS 允许将演示样式与内容明确分开,并可通过JavaScript以编程方式进行更改 XMLHttpRequest 与服务器执行异步交互的

  • 可能因为是线下面,再加上公司内部信息流通比较快,一天内的上下午就面完了! 我个人还是对公司的业务非常感兴趣的!所以提前看过好几篇公司业务相关的文章 面试官人很nice,我俩基本上是我一答他一回应,所以我在这里重点挑自己印象里答得不好的地方写写。 技术面 堆和栈的区别?堆是怎么样的数据结构? 数组和链表的具体区别呢?优缺点?存取效率? 原型链?可以先答概念,在用Object和Array来解释各个指向

  • 用例是黑盒测试的功能测试,用于根据系统的使用从系统的开始到结束识别测试用例。通过使用这种技术,测试团队创建了一个测试场景,可以从头到尾根据每个功能的功能运行整个软件。 在这种情况下,有一个测试人员代表用户逐个使用系统的功能。在这种情况下,有一个演员代表用户使用软件系统的功能。 这描述了软件应用程序的逐步功能,可以通过一个例子来理解,假设存在在线资金转移的软件应用程序。转账的各个步骤如下: 用户登录

  • 主要内容:动态分区的缺点,需要分页动态分区的缺点 动态分区的主要缺点是外部碎片。 尽管这可以通过压缩来消除,但正如我们前面所讨论的那样,压缩使得系统效率低下。 我们需要找一种替代机制,以更优化的方式加载分区中的进程。 让我们讨论一个称为分页的动态灵活机制。 需要分页 让我们考虑一个大小为2 MB的进程P1和分为三个分区的主内存。 在三个分区中,两个分区是每个大小为1 MB的空洞。 P1需要在主存中加载2 MB空间。 我们有两个1M