openshift / openshift/origin

[OKD 3.11] Testing GitLab Build Trigger - payload includes 3 commits and triggers build based on wrong commit

Open
#23,799 7 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/usability component/build lifecycle/frozen sig/developer-experience
Dominant language
Go
Stars
8.7k
Forks
4.8k
Avg merge
4d 10h
Merged PRs (30d)
53

Description

Hello you lovely people!

I'm posting in hopes of verifying and/or identifying a bug.

When testing the integration in GitLab to trigger an OpenShift build, the webhook payload sent by GitLab contains an array commits containing the last 3 commits.

OpenShift triggers a build, but clones the oldest commit (which is the last one in the array) and not the newest (meaning it reverts to an older code version)

When instead pushing to the GitLab repository to trigger the webhook, the commit array only contains one entry - the most recent commit - the OpenShift build therefore is OK.

Version

oc v3.11.0+8de5c34
kubernetes v1.10.0+d4cacc0

openshift v3.11.0+1c3e643-87
kubernetes v1.11.0+d4cacc0

Steps To Reproduce

With test from GitLab

  1. Press GitLab build trigger "Test" button
  2. Payload is sent with 3 commits
  3. Build is triggered
  4. Image built with incorrect code

Actual commit to repository

  1. Payload is sent with 1 commit
  2. Build is triggered
  3. Image built with correct code
Current Result

With test - build is potentially initiated with the wrong commit, therefore building the image with outdated code.

Expected Result

When triggering builds when testing the webhook from GitLab the checkout_sha should be used to identify the commit.

Additional Information

JSON Payloads (test and actual commit)

Sensitive information has been redacted

##Payload from test trigger##

{
  "object_kind": "push",
  "event_name": "push",
  "before": "21d9e939eeb4027188eed090463a65297f854480",
  "after": "e011f39148b7c39ec72cb73b5d48a0074d22bb71",
  "ref": "refs/heads/master",
  "checkout_sha": "e011f39148b7c39ec72cb73b5d48a0074d22bb71",
  REDACTED
  },
  "commits": [
    {
      "id": "e011f39148b7c39ec72cb73b5d48a0074d22bb71",
      "message": "REDACTED",
      "timestamp": "2019-09-12T14:28:00Z",
      "url": "https://gitlab.com/REDACTED",
      "author": {
        "name": "REDACTED",
        "email": "REDACTED"
      },
      "added": [],
      "modified": [
        "views/spots/map.jade"
      ],
      "removed": []
    },
    {
      "id": "60a78657b4f808b57e8da21214ba82bb90ab64c9",
      "message": "REDACTED",
      "timestamp": "2019-04-17T21:58:07Z",
      "url": "https://gitlab.com/REDACTED",
      "author": {
        "name": "REDACTED",
        "email": "REDACTED"
      },
      "added": [],
      "modified": [
        "public/spots/map.css",
        "public/spots/map.js",
        "public/stylesheets/style.css",
        "views/spots/map.jade"
      ],
      "removed": []
    },
    {
      "id": "21d9e939eeb4027188eed090463a65297f854480",
      "message": "REDACTED",
      "timestamp": "2019-04-17T21:55:45Z",
      "url": "REDACTED",
      "author": {
        "name": "REDACTED",
        "email": "REDACTED"
      },
      "added": [],
      "modified": [
        "public/spots/map.css",
        "public/spots/map.js",
        "views/spots/map.jade"
      ],
      "removed": []
    }
  ],
  "total_commits_count": 3,
  "push_options": {},
  "repository": {
    "name": "REDACTED",
    "url": "git@gitlab.com:REDACTED",
    "description": null,
    "homepage": "REDACTED",
    "git_http_url": "REDACTED",
    "git_ssh_url": "REDACTED",
    "visibility_level": 0
  }
}

##Payload from actual commit##

{
  "object_kind": "push",
  "event_name": "push",
  "before": "e011f39148b7c39ec72cb73b5d48a0074d22bb71",
  "after": "686e20ccf1d154cd4f29072e802495504950caee",
  "ref": "refs/heads/master",
  "checkout_sha": "686e20ccf1d154cd4f29072e802495504950caee",
  },
  "commits": [
    {
      "id": "686e20ccf1d154cd4f29072e802495504950caee",
      "message": "REDACTED",
      "timestamp": "2019-09-16T14:39:02Z",
      "url": "REDACTED",
      "author": {
        "name": "REDACTED",
        "email": "REDACTED"
      },
      "added": [],
      "modified": [
        "views/spots/map.jade"
      ],
      "removed": []
    }
  ],
  "total_commits_count": 1,
  "push_options": {},
  "repository": {
    "name": "REDACTED",
    "url": "git@gitlab.com:REDACTED",
    "description": null,
    "homepage": "https://gitlab.com/REDACTED",
    "git_http_url": "https://gitlab.com/REDACTED",
    "git_ssh_url": "git@gitlab.com:REDACTED",
    "visibility_level": 0
  }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the two GitLab webhook payloads in the issue as the starting point, then trace the OpenShift GitLab webhook handling and build-trigger checkout path. Compare how checkout_sha and the commits array are interpreted; done means the test-trigger payload builds the checkout_sha commit rather than the oldest listed commit.

Written by the indexing model from the issue text.

Assessment

Tech stack
gitlab, go
Domain
ci-cd, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.