Jx: Fails to query last commit status on repo

Created on 8 Oct 2018  路  18Comments  路  Source: jenkins-x/jx

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:
Pull Request https://mygitlab.onpremise.local/myname/environment-jx-sta/merge_requests/1 is merged at sha ... 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.

aregit aregitlab kinbug lifecyclrotten prioritimportant-longterm

Most helpful comment

Having the same issue

All 18 comments

Having the same issue

/kind git
/kind gitlab

/priority backlog

/area git
/area gitlab

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

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.

Where and when is the commit status set when using GitHub ?

For anyone interested, I'm using the following additional setup in the pipelines of environments (e.g. environment-jx-staging pipeline) to bypass the issue until the Jx-Gitlab integration is fully implemented:

pipeline {
  options {
    disableConcurrentBuilds()
    #Add a gitlab connection in the Jenkins configuration and use it here
    gitLabConnection('<gitlab connection id>')
  }
....
  post {
    failure {
      updateGitlabCommitStatus name: "build${env.BUILD_NUMBER}", state: 'failed'
    }
    success {
      updateGitlabCommitStatus name: "build${env.BUILD_NUMBER}", state: 'success'
    }
  }
}

The only issue is that the "promote-" branch is not automatically deleted from the environment's git repo.

@dimmel82 thanks its working :)

i hope this issue and #3339 get fixed soon :)

@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!

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

This worked for me.

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

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

Thanks, --no-wait=true --no-poll=true work with me.

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Provide feedback via https://jenkins-x.io/community.
/lifecycle stale

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.
Provide feedback via https://jenkins-x.io/community.
/lifecycle rotten

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.
Provide feedback via https://jenkins-x.io/community.
/close

@jenkins-x-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.
Provide feedback via https://jenkins-x.io/community.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the jenkins-x/lighthouse repository.

Was this page helpful?
0 / 5 - 0 ratings