标签: github-webhook

当另一个存储库创建新版本时触发 GitHub 操作

我正在尝试构建一个 GitHub 工作流,该工作流将在另一个存储库创建新版本时触发。

在文档中,有一段:on.event_name.typeswhere event_namewill be release

问题是:有没有办法引用release另一个存储库的事件?

github github-webhook github-actions

32
推荐指数
2
解决办法
7237
查看次数

Jenkins 简单管道不是由 github 推送触发的

在此处输入图像描述我使用以下脚本创建了一个名为“pipelinejob”的 jenkins 管道作业:

pipeline {
    agent any

    stages {

        stage ('Setup'){
            steps{
                //echo "${BRANCH_NAME}"
                echo "${env.BRANCH_NAME}"
                //echo "${GIT_BRANCH}"
                echo "${env.GIT_BRANCH}"
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

1)在General下,我选择了“GitHub项目”,并在表格中插入了我公司的github:

https://github.mycompany.com/MYPROJECTNAME/MY_REPOSITORY_NAME/

2)在构建触发器下,我已经检查了“GitHub hook trigger for GITScm polling

3) 我创建了一个名为“simplejob”的简单作业,其配置与 1) 和 2) 相同

4) 在我公司的 Github 中,我创建了一个类似“jenkins_url/jenkins/github-webhook/”的 webhook

5)我在“MY_REPOSITORY_NAME”中的“mybranch”中进行了更改

6)我的简单作业“simplejob”被触发并成功构建

7)我的管道作业“pipelinejob”没有被触发

8) 在 Jenkins 日志中,我看到以下内容:

Sep 12, 2019 2:42:45 PM INFO org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber$1 run
Poked simplejob
Run Code Online (Sandbox Code Playgroud)

没有关于我的“pipelinejob”。

您能否为我指出下一步要检查的正确方向?

PS我已经成功地手动执行了我的“pipelinejob”

github jenkins jenkins-pipeline github-webhook

7
推荐指数
2
解决办法
4147
查看次数

如何在 React 中使用 API webhook 来接收通知

这是我第一次使用 Webhooks,我想知道是否可以从 Webhooks 订阅接收通知。我正在为我的项目使用 create-react-app,并希望使用 github 的 Webhooks 订阅在每次提交到我的 github 存储库时发送警报。我将如何处理这个项目以及我需要做什么来测试我的 Webhooks 订阅?

webhooks reactjs github-webhook

7
推荐指数
1
解决办法
6841
查看次数

GitHub webhook 无法在 VPN 内连接到 Jenkins?

我正在使用 Jenkins 和 GitHub Enterprise 设置持续集成。

\n

到目前为止,我已经能够轻松创建 Jenkins 项目并定期运行作业。

\n
    \n
  • Jenkins 使用 SSH 公钥/私钥来验证和克隆 GitHub 存储库。
  • \n
  • Jenkins 在我公司 VPN 网络内的 Linux 服务器上运行。
  • \n
\n

我的下一步是配置 Jenkins/GitHub,以便每个git pushGitHub 都会触发 Jenkins 构建作业。我已在 GitHub 上设置了提交后 Webhook,并GitHub hook trigger for GITScm polling在我的 Jenkins 项目中启用了该复选框。

\n

但是,GitHub 无法连接到 Jenkins。

\n

这是日志:

\n
We couldn\xe2\x80\x99t deliver this payload: failed to connect\n\n{\n  "zen": "Design for failure.",\n  "hook_id": 287451636,\n  "hook": {\n    "type": "Repository",\n    "id": 287451636,\n    "name": "web",\n    "active": true,\n    "events": [\n …
Run Code Online (Sandbox Code Playgroud)

continuous-integration github jenkins github-webhook

7
推荐指数
1
解决办法
2656
查看次数

AWS CloudFormation CodePipeline:无法从GitHub获取存储库的内容

我正在尝试使用CodePipeline和GitHub设置AWS CloudFormation配置。

我在自己的示例项目和教程中都失败了:使用AWS CloudFormation创建GitHub Pipeline

创建了所有资源,但是在CodePipeline中,我在初始“源”阶段不断收到以下错误。

Could not fetch the contents of the repository from GitHub.

见下图:

带有Github的CodePipeline失败,显示为“无法从Github提取存储库的内容。”

请注意,这不是权限错误。到目前为止,这是Google尚不存在的其他功能。

如果我停止使用CloudFormation并通过控制台创建CodePipeline,则可以将GitHub配置为可以工作,但是出于我的目的,我需要使用CloudFormation。需要坚持使用模板。

这是从教程复制的CloudFormation模板中的模板:

Parameters:
  BranchName:
    Description: GitHub branch name
    Type: String
    Default: master
  RepositoryName:
    Description: GitHub repository name
    Type: String
    Default: test
  GitHubOwner:
    Type: String
  GitHubSecret:
    Type: String
    NoEcho: true
  GitHubOAuthToken:
    Type: String
    NoEcho: true
  ApplicationName:
    Description: CodeDeploy application name
    Type: String
    Default: DemoApplication
  BetaFleet:
    Description: Fleet configured in CodeDeploy
    Type: String
    Default: DemoFleet
Resources:
  CodePipelineArtifactStoreBucket:
    Type: "AWS::S3::Bucket"
  CodePipelineArtifactStoreBucketPolicy:
    Type: "AWS::S3::BucketPolicy" …
Run Code Online (Sandbox Code Playgroud)

github aws-cloudformation aws-codepipeline github-webhook

6
推荐指数
1
解决办法
360
查看次数

使用 AWS API Gateway 的 Github Webhooks 密钥

我正在尝试让 Github Webhook 启动我拥有的 AWS Lambda。我能弄清楚如何做到这一点的最好方法是使用 AWS API Gateway,问题是安全性。

Github Webhooks 只会通过 POST 调用发送一个秘密。

我找不到任何方法让 AWS API Gateway 验证此签名。或者我可以在哪里添加此功能。

我假设我可以编写一个AWS Lambda Authorizer。但这是很多不同地方的代码,开始看到需要serverless框架。

我不知道在 AWS 中有更简单的设置吗?

github amazon-web-services git-webhooks github-webhook

5
推荐指数
1
解决办法
2184
查看次数

如何在 Python 3 中验证来自 GitHub webhook 的有效负载?

我已经通过 Github webhooks 在服务器上实现了 Flask 应用程序的自动部署,但我无法将手册中指定的 Ruby 脚本改编 Python 3 来验证 POST 请求。我试过这个:

from flask import Flask, request
from hmac import HMAC, compare_digest
from hashlib import sha1

app = Flask(__name__)

def verify_signature(req):
     received_sign = req.headers.get('X-Hub-Signature').split('sha1=')[-1].strip()
     secret = 'my_secret_string'.encode()
     expected_sign = HMAC(key=secret, msg=req.data, digestmod=sha1).hexdigest()
     return compare_digest(received_sign, expected_sign)

@app.route('/webhook', methods=['POST', 'GET'])
def webhook():
    if request.method == 'POST':
        if verify_signature(request):
            do_smth()
            return 'Successfully', 200
        return 'Forbidden', 403
    return 'Not allowed', 405
Run Code Online (Sandbox Code Playgroud)

我还尝试了来自secrets包的sha1(...).hexdigest()和compare_digest()的其他变体,但收到的签名总是不同。

我做错了什么?

request sha python-3.x github-webhook

5
推荐指数
1
解决办法
1932
查看次数

谷歌云功能完成状态:“连接错误”

我有一个由 Github webhook 调用的 HTTP 云函数(Python 3.7),当事件类型不是拉取请求时,它通常(但不总是)退出并出现连接错误。当它没有进入 if 块时,它总是干净地退出。

这是函数:

def my_func(request):
    event = request.headers.get("X-GitHub-Event", "unknown")
    if event != "pull_request":
        print("This is not a pull request")
        return "This is not a pull request", 200
    return "OK", 200
Run Code Online (Sandbox Code Playgroud)

在日志中它显示为:

"This is not a pull request"
"Function execution took 11 ms, finished with status: 'connection error'" 
Run Code Online (Sandbox Code Playgroud)

在 Github 端,响应是 HTTP/500 错误,消息为“错误:无法处理请求”。

我已将其重新部署为不同项目中的新功能,并且发生了同样的事情。对于同一事件,有时一个函数会返回 200,而另一个函数会返回 500。知道这里发生了什么吗?谢谢 :)

python-3.x google-cloud-platform google-cloud-functions github-webhook

5
推荐指数
1
解决办法
1653
查看次数

如何在 Jenkins 声明式管道中获取 Github Webhook 有效负载数据?

我有一个使用 Github webhooks 触发的 Jenkins 声明性管道。

Jenkins 作业可以在拉取请求或合并时触发。

我希望每次都运行 3 个步骤(构建和测试)中的 2 个 - 合并和 PR。

我希望最后一步 Deploy 仅在合并到“开发”分支时触发。

为此,我相信我需要访问触发作业的 github webhook 有效负载(包括其正文和请求标头)。如何从声明性管道访问这些数据?

这是我想要的要点:

pipeline {

    agent any

    stages {
        stage ('Build') {
            steps {
                sh 'build.sh'
            }
        }

        stage ('Test') {
            steps {
                sh 'test.sh'
            }
        }

        stage ('Deploy to QA') {
            when {
                branch 'development'
                // AND the github webhook header "X-GitHub-Event" == "pull_request"
                // AND the github webhook json payload body.merged == true
            }
            steps {
                sh …
Run Code Online (Sandbox Code Playgroud)

github webhooks jenkins jenkins-declarative-pipeline github-webhook

5
推荐指数
0
解决办法
305
查看次数

当并发构建为 1 时,CodeBuild 项目不会排队

我们使用 AWS CodeBuild 和 GitHub Webhook 来触发构建过程。当为以 Jira 票证前缀(即 )开头的分支创建 PR 时oscs-278,我们使用 Terraform 构建一个新环境。当我们提交 PR 时,它会触发构建过程来更新该环境。

这一流程对我们来说效果很好,特别是自 2021 年 2 月起,AWS CodeBuild 允许您将并发构建设置为 1。这对我们来说很重要,因为我们一次应该只进行一个部署,其余的应该排队。

但是,我们当前的构建过程最多需要 15 分钟,如果我们在此时间范围内提交到分支,则如果另一个构建正在进行中,则该项目不会排队。

这可能是 GitHub Webhooks 的问题,还是与 AWS CodeBuild 有关的问题。

来自AWS文档:

队列中的最大构建数是并发构建限制的五倍。

所以理论上,队列中应该有 5 个(最多)

aws-codebuild github-webhook

5
推荐指数
1
解决办法
3045
查看次数