Integration of Jenkins Job result in Gitlab - jenkins

I'm currently improving the integration of Jenkins that we have in Gitlab CE 10.6.0.
For now, we had a webhook that trigger a pipeline in Jenkins. The job was executing fine, but in Gitlab we had only a pipeline shown has pending until it eventually failed, because no runner were installed.
I managed to improve the groovy script on Jenkins side to have the status shown in gitlab as well, as in the picture here :
My problem now is that the parent job is still shown has pending, and still not running. I have not installed Gitlab Runner on my server (mostly because I'm not the administrator of it) and I don't think that could be an option.
Any idea on how I could have only the Jenkins part shown, and not the internal Gitlab part of the pipeline ?

After more research, it appears that I had a gitlab-ci.yml file in my project that someone had comitted months ago but no one was using anymore...
So The solution was just to delete it to have the pipeline with only Jenkins steps

Related

How to decouple Jenkins CI and gitlab CI pipelines?

I've only been working with Jenkins so far. We have configured a Multibranch Pipeline job to automatically build and test software. The tasks are written in Groovy and stored as Jenkinsfile in the root directory of our git repository.
Recently, we have decided to add another mechanism to automatically generate documentation. The generation of documentation (but this could be any other task) has been realized using GitLab CI.
Both pipelines are practically independent - and both are triggered by a git commit/push. What I do not understand is: why and how is the Jenkins pipeline execution associated with the GitLab CI pipeline? In the following screenshot a new column "External" appears - representing the Jenkins pipeline job.
That's not really a big issue. But as both pipelines should be independent - the results of the runs should not influence each other. However, it seems that when the Jenkins job fails, i.e. "External", the GitLab CI pipeline also fails:
Is there a way to better decouple those pipelines, i.e. let them fail or succeed individually?
This is because the Gitlab Branch Source Plugin automatically notify Gitlab about then Jenkins pipeline status. This allow you to see the result of a build directly in Gitlab. If you want to have only the result of the Gitlab CI pipeline in Gitlab, you can disable this feature :
Additional Traits:
These traits can be selected by selecting Add in
the Behaviours section.
[...]
Skip pipeline status notifications - Disable notifying GitLab server
about the pipeline status.
[...]
So in yout Gitlab group, just go the Configure > Projects > Gitlab Group > Add and select Skip pipeline status notifications.
why and how is the Jenkins pipeline execution associated with the GitLab CI pipeline? In the following screenshot a new column "External" appears - representing the Jenkins pipeline job.
In general, "External" statuses are created using the commit build status API -- Jenkins uses this API to report the Jenkins pipeline build status to GitLab CI.
This external status for Jenkins appears in your GitLab pipeline because you have configured your Jenkins server/project to report build statuses to GitLab or you have setup a webhook integration with Jenkins in GitLab (note these may be set at the group level or by an administrator, not necessarily the project level)
To remove this from your pipeline, you should disable any existing integration configurations and setup your Jenkins project independently of any GitLab integration. e.g. using git polling to trigger jenkins builds and remove any updateGitlabCommitStatus calls in your groovy scripts / build stages.

Jenkins job - no options found under pipeline section

I have started learning Jenkins recently.
I installed docker on a server which I created on AWS server and using docker I have installed Jenkins.
I wanted to test a Hello pipeline stage by creating new item, but when I go to the pipeline tab I cant see any options like pipeline script or pipeline script from SCM . I have installed git plugin and pipeline plugin also seems to be installed successfully. I am not able to continue my study further. I will be really thankful if someone can help me here.
In reality the pipeline plugin is not just one plugin but a bunch of 6 to 8 plugins. So you may want to install all the pipeline related items in your available plugins section of Manage Jenkins. Once this is done, a reboot of Jenkins is required for the changes to take effect. Here are some of them:
https://plugins.jenkins.io/build-pipeline-plugin/
https://www.jenkins.io/doc/pipeline/steps/pipeline-build-step/
https://plugins.jenkins.io/pipeline-stage-view/

Can Jenkins used with python project?

I'm developing a web application using python django. I want a CI service which can automatically pull the latest code from my github and run some test then deploy. I'm not familiar with CI, after searching for a while I found Jenkins seems to be a good solution. Can Jenkins be used for this?
Jenkins can be used with any project.
Regarding pulling the latest code, add the Jenkins GitHub plugin in order to be able to check "Build when a change is pushed to GitHub" under "Build Triggers".
That will launch your job on any new pushed commit on the GitHub repo.
From there, a Jenkins job can execute any command that you would do in command-line, provided the agent on which said job will be scheduled and executed has the necessary tools in its PATH (here python)
An alternative (which does not involved Jenkins) is to setup a webhook and a listener on your server which will detect a "push event" sent by said webhook.

Jenkins Pipeline using Openshift

I am trying to create a Jenkins pipeline on Openshift, that automatically runs a Jenkins service when we start the pipeline build. I referred few templates online and created a Jenkins pod and a pipeline. But whenever I try to run the pipeline, It shows build status as "not started.
Later, I created a standalone Jenkins service in Openshift, created a Jenkins file in open shift and tried executing it. I encountered authentication issues while connecting with Openshift from Jenkins.
Can anyone guide me, if I am missing something or any other working templates for a pipeline?
Thanks
It’s because of permissions
Jenkins runs with Jenkins user and openshift doesn’t know how to connect to it
Create a new service account in openshift jenkins

Bitbucket | Trigger Build on Pull request [duplicate]

This question already has answers here:
How to trigger jenkins build upon bitbucket pull request merged
(2 answers)
Closed 5 years ago.
I have a Jenkins job which I want to trigger when I evaluate a pull request on Bitbucket. The Jenkins job is correctly configured (by the looks of it) with the 'Poll SCM' option checked.
I have setup the 'Bitbucket Server Webhook to Jenkins' as follows. When I click on 'Trigger Jenkins' as part of the configuration check, it works well. Corresponding logs on the Jenkins server show up properly.
Now, when I receive a pull request, I would want to trigger the same Jenkins job. However, which I click on the 'Trigger Build' option, nothing happens. The Jenkins job is not triggered. I dont see correspnding logs on the Jenkins server. No logs on the bitbucket server as well.
Where am I going wrong?
I am using an 'Atlassian Bitbucket v4.7.1' evaluation installation and a Jenkins 1.651 installation.
Just tried bitbucket 4.13 with webhook to jenkins for bitbucket 3.0.1 plugin. Follow the instruction on the plugin site, you need to install the git plugin on the jenkins side, enable git checkout and make sure it works, and enable polling of scm. The jenkins version used is pulled from docker hub with tag jenkins/jenkins:lts.
If the above does not work for you, from my reading you can have a few options as of today Nov 12 of 2017:
Use the generic post webhooks plugin that supports pull request trigger. And from jenkins pick it up with the generic webhooks plugin, then maybe do a secondary trigger from jenkins.
Upgrade the bitbucket server and webhooks to jenkins plugin. The server 4.13 does not work well with later webhooks to jenkins plugin. A paid version of the plugin probably is your best choice.
Or try bamboo that comes with the "plan banches" feature.

Resources