jx: Fails to query last commit status on repo

Summary

Jenkins fails to query the status of the PRs in gitlab v11.1.4 so, it can’t complete a simple promote pipeline. Webhooks are created correctly, manually added access to all and notify everything to the webhook (just in case).

Steps to reproduce the behavior

jx create git gitlab https://mygitlab.onpremise.local jx create git token myname jx import $my_very_simple_python_proyect

Jx version

The output of jx version is:

NAME               VERSION
jx                 1.3.391
jenkins x platform 0.0.2755
Kubernetes cluster v1.10.3-eks
kubectl            v1.12.0
helm client        v2.10.0+g9ad53aa
helm server        v2.10.0+g9ad53aa
git                git version 2.7.4

Kubernetes cluster

EKS cluster, created with terraform using the eks module.

Operating system / Environment

Tested on Ubuntu and Fedora

Expected behavior

Jenkins is able to understand that the PR is created, merge it and finish the pipeline successfully deploying code in the next environment.

Actual behavior

The PR is created in the next environment repo, but jenkins keeps showing: Failed to query the Pull Request last commit status for https://mygitlab.onpremise.local/myname/environment-jx-sta/merge_requests/1 ref...

If I merge it manually it starts showing:

Merge commit has not yet any statuses on repo myname/environment-jx-sta merge sha ... ```

The code is actually deployed to the staging environment, but looks like the pipeline can't check it and times out.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

Having the same issue

I added --no-wait=true --no-poll=true to my jx promote command and the automatic merge works as expected.

Hi, I have the same issue. When I manually post the following to gitlab api the Jenkins job is completed: curl --request POST --header "PRIVATE-TOKEN: **my-gitlab-api-token**" "http://**my-gitlab-host**/api/v4/projects/**my-project-id**/statuses/**sha-of-the-merge**?state=success"

merge status: success for URL with target: description: Merge status checks all passed so the promotion worked!

Maybe the post should be added in the promote.go as an extra step for Gitlab provider.

Btw, Jenkins X is really amazing

@dimmel82 @erSitzt thank you both.

I changed the Jenkinsfile of environment-heroalpine-staging to the following:

pipeline {
  options {
    disableConcurrentBuilds()
    // Add a  gitlab connection in Jenkins > Manage Jenkins > Configure System > Gitlab and name it 'jx-gitlab'
    gitLabConnection('jx-gitlab')
  }
  agent {
    label "jenkins-maven"
  }
  environment {
    DEPLOY_NAMESPACE = "jx-staging"
  }
  stages {
    stage('Validate Environment') {
      steps {
        container('maven') {
          dir('env') {
            sh 'jx step helm build'
          }
        }
      }
    }
    stage('Update Environment') {
      when {
        branch 'master'
      }
      steps {
        container('maven') {
          dir('env') {
            sh 'jx step helm apply'
          }
        }
      }
    }
  }
  post {
    failure {
      updateGitlabCommitStatus name: "build${env.BUILD_NUMBER}", state: 'failed'
    }
    success {
      updateGitlabCommitStatus name: "build${env.BUILD_NUMBER}", state: 'success'
    }
  }
}

At first it didn’t work, because i omitted the gitLabConnection(‘jx-gitlab’) line (i simply overlooked it). Then it was stuck at:

Merge commit has not yet any statuses on repo myorganisation/environment-heroalpine-staging merge sha 83ad752608ff2ee4ac8da59f36ce1504ec1e01a9

I then did the following POST request:

curl --request POST --header "PRIVATE-TOKEN: XXXX" "https://my.git.example.com/api/v4/projects/42/statuses/83ad752608ff2ee4ac8da59f36ce1504ec1e01a9?state=success" | jq
{
  "id": 893,
  "sha": "83ad752608ff2ee4ac8da59f36ce1504ec1e01a9",
  "ref": "master",
  "status": "success",
  "name": "default",
  "target_url": null,
  "description": null,
  "created_at": "2019-04-09T15:28:08.961Z",
  "started_at": null,
  "finished_at": "2019-04-09T15:28:08.960Z",
  "allow_failure": false,
  "coverage": null,
  "author": {
    "id": 46,
    "name": "My name",
    "username": "myusername",
    "state": "active",
    "avatar_url": "https://my.git.example.com/uploads/-/system/user/avatar/46/avatar.png",
    "web_url": "https://my.git.example.com/myusername"
  }
}

Then the pipeline went on with

merge status: success for URL with target: description: Merge status checks all passed so the promotion worked!

and ends successfully.

I am using jenkins-x version 0.0.3734 with gitlab. In the build pipeline i use a pod with jx version retrieved from https://github.com/jenkins-x/jx/releases/download/v1.3.1096/jx-linux-amd64.tar.gz

With the added gitLabConnection, the above pipeline succeeds even without the POST request. Thanks!

I have the same issue with github, but after 15-20 tries it does complete.

Having this problem now… Any progress? @dimmel82 's curl suggestion got it past where it was stuck, but now it’s stuck here:

Pull Request http://foo/jcarreira/environment-jx-staging/merge_requests/3 is merged at sha 1d01672712987676d3f10a68e6f27671e89c7c3b

Merge commit has not yet any statuses on repo jcarreira/environment-jx-staging merge sha 1d01672712987676d3f10a68e6f27671e89c7c3b

I think it’s because the build pipeline for jx-staging is stuck here:

jx step helm build

No $CHART_REPOSITORY defined so using the default value of: http://jenkins-x-chartmuseum:8080

Adding missing Helm repo: jenkins-x http://chartmuseum.jenkins-x.io

Successfully added Helm repository jenkins-x.

Adding missing Helm repo: releases http://jenkins-x-chartmuseum:8080

Successfully added Helm repository releases.