GitHub Organization job is missing from list of Jenkins jobs - jenkins

I am following this Jenkins tutorial. After installing Jenkins, I manually add the missing recommended plugins. I then try to create a new Jenkins job. I notice that the GitHub Organization option is missing from the list. I am using version 2.375.1 (latest as of now). Why is this happening? How can I fix it? Is it missing any kind of plugin?

The GitHub Branch Source plugin is responsible for that, and is automatically installed if you selected the defaults when starting Jenkins. This is also highlighted in the Jenkins docs.
However, the job type is no longer GitHub Organization, and is instead called Organization Folder, which "enables Jenkins to monitor an entire GitHub Organization". The functionality is the same.

Related

Jenkins / Gitlab Multibranch Pipeline not ignoring projects archived in Gitlab

We're using Jenkins to orchestrate our builds from GitLab using a Multibranch Pipeline strategy. Recently, something changed somewhere, and now Jenkins is no longer ignoring projects archived in GitLab.
We're using the following stack (not all may be relevant to the problem at hand, and certainly not the complete list of plugins, which would take many pages, if there are other items that I can provide, happy to do so):
Jenkins: 2.263.3
Git Plugin 4.5.1
GitLab Enterprise Edition: 13.7.9-ee
GitLab API Plugin for Jenkins: 1.0.6
GitLab Plugin for Jenkins: 1.5.13
GitLab Branch Source Plugin for Jenkins: 1.5.3
We have our projects organized into groups (with no subgroups) in GitLab, and have used a strategy to archive them when they're no longer needed (instead of deleting them). In Jenkins, we have set up a GitLab Group as an "organization folder", which configures itself to autoscan the GitLab group, searching for projects that have a file named "Jenkinsfile" (configured via project recognizer).
I haven't been able to correlate any recent changes to the behavior I'm seeing, but am still searching. Does anyone have any ideas of where to look to fix this, or is this a known issue?
Thanks!

How can I remove "continuous-integration/jenkins/pr-merge" and "continuous-integration/jenkins/branch" checks from showing on my GitHub pull requests?

I have a plugin installed for Jenkins that breaks down each stage of the run. For that reason I have no need for the extra two displayed checks, is there any way I can hide them?
I was able to solve this issue with installing the following plugin:
https://github.com/jenkinsci/disable-github-multibranch-status-plugin
For a Multibranch Pipeline, if you are using the Github Branch Source plugin, this plugin will give an additional option to disable GitHub reporting.

jenkins + sonar + github integration

Problem: I am setting up jenkins + sonar + github integration for automatic pullrequest static code check through sonar.
My Configuration:
Installed Sonar with github
Installed jenkins
In jenkins post-build action I have the following properties
-Dsonar.github.login=bhuwang
-Dsonar.github.repository=company/repo
-Dsonar.verbose=true
-Dsonar.analysis.mode=preview
-Dsonar.issuesReport.console.enable=true
-Dsonar.forceUpdate=true
-Dsonar.github.login=gitusername
-Dsonar.github.oauth=token
Token was generated from my github account.
In this link I have read that I have to provide the following properties while running sonarqube:
I have added all except sonar.github.pullRequest properties. I don't know how do I get this property value dynamically. Seems like above four properties are must to work properly.
Edit: I have found the way to add property -Dsonar.github.pullRequest=pullrequestNo
And the good news is it is working perfectly fine now with hardcoded pull request no. but I need the dynamic way to get the pull request no.
Does anyone know how to get the pull request no. dynamically inside jenkins.?
I have found that pull request builder will work but no luck at my end. I am not able to use pull request builder environment variables inside sonar properties.
https://issues.jenkins-ci.org/browse/JENKINS-24590
Finally I am able to solve this issue. Here is the detail:
Install Sonar with GitHub plugin.
Install Jenkins with the following plugins
GitHub Pull Request Builder
SonarQube Plugin
GIT plugin
GitHub plugin
Follow this link to setup pull request builder plugin: https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin#GitHubpullrequestbuilderplugin-EnvironmentVariables
Global Jenkins System Setup:
Goto Manage Jenkins -> Configure System
Configure jdk
Install sonarQube Runner
Configure Sonar
Git WebHook Setup
PullRequest Builder Setup
Create Free Style Jenkins job
add github url to GitHub Project section
Setup Source Code Management Section
Setup Build Trigger
Setup Sonar for post build actions
In the additional properties section provide the following sonar properties
-Dsonar.sourceEncoding=UTF-8
-Dsonar.analysis.mode=preview
-Dsonar.github.repository=company/repo
-Dsonar.github.login=gitusername
-Dsonar.github.oauth=oauthtoken
-Dsonar.host.url=sonarhostedurl
-Dsonar.login=admin
-Dsonar.password=pass
-Dsonar.github.pullRequest=${ghprbPullId}
${ghprbPullId}: this will be provided via github pullrequest builder plugin
Note: The job should be triggered through pullrequest builder plugin otherwise ${ghprbPullId} will return blank. If you run the job manually this will not work for that you have to pass this ${ghprbPullId} property as a build parameter. If you want to check the environment parameter available follow this Git environment variables for use in executing Jenkins shell scripts
I hope this helps.
Too long for a comment so I'll have to write it here.
After some research on the web I've found a question on SO from someone a few steps ahead of you in the process of trying to setup a similar system, here. They're trying to get this all working with Maven, I'm not sure if you are also, but either way you can then see the link they've been using to help them with their script:
https://github.com/SonarSource/sonarqube/blob/master/travis.sh
This shows they need to write a script that will retrieve the pull number dynamically for them. I think you may need to follow a similar approach and write a script that will retrieve the number for you, I believe one of the github conf files keeps track of the current pull request number for its own tracking purposes.
Not really as straight forward an answer as you might have been hoping for, but hopefully this is new information that helps you get there.
See my project's implementation Jenkins + SONAR + Github with code at
https://github.com/lqtruong/ci

Gitlab and Jenkins integration novice

What do you put into the system hook URL? I see a lot of examples but they look like JSON scripts to me.
I'm trying to configure gitlab to hook jenkins to create projects when projects are generated in gitlab. I'd also like builds to be run when a merge (pull) request is generated for a repo.
I've followed the steps outlined here for the gitlab hook plugin:
http://doc.gitlab.com/ee/integration/jenkins.html
But it's still not generating builds on push requests. Perhaps i don't have something setup right?
I have also tried and failed to configure Gitlab to integrate with Jenkins by following the instructions at http://doc.gitlab.com/ee/integration/jenkins.html#jenkins-service
For me the reason was that I didn't have Gitlab EE installed. The page specifically states: "The Jenkins project service code is only available in GitLab EE"
I discovered by chance my answer. In gitlab under the project settings you can add the following hook to trigger a build on a pull request or commit.
http://gitlab.example.com/job/example_project/build?token=UserToken.
I believe I saw it in Jenkins.
Now i've installed the gitlab plugin and i've tried the build_commit? hook and some other hooks but i was running into other errors such as asking for repo location when i've provided it. This does the trick though and i'm happy enough for now.

How can i use Jenkins with Atlassian Stash?

I've just setup Jenkins and i have some Repositories in my Stash.
I installed the "Git plugin" in jenkins.
I can now enter the repository url but there is nothing to enter my credentials.
It's possible using
http://username:password#mydomain/xx/yy.git
but that is something i dont want to do.
What else can i do to authenticate?
I am the author of this stash plugin that might help you: https://github.com/palantir/stashbot
Taking selectively from the readme:
To work with Jenkins, you MUST install the following jenkins plugins first.
Jenkins GIT plugin
Post build task
Next, build and install the plugin using the plugin SDK (more details in the readme)
Next, the stash admin goes into the Stashbot Admin page and creates a jenkins server config - here you give it the URL, username/password, etc details of the jenkins server.
Next, for each repository a "Stashbot CI Admin" link shows up for repo admins. From there you can check the "enabled" checkbox and tell it what branches you want build (via a regex) and what command it should run to do the build (optionally verifies and publishes).
After this point, the remainder is completely self-service. Any repo admin can ask for their project to "have CI" by filling out that form, and the jobs will automatically be created in the jenkins server.
Hope that helps.
Set up an SSH key for the user that runs your Jenkins builds and add it to the repository's SSH keys in Stash. See the Stash docs for instructions.
Two things to add to Gareth's answer.
While I agree that using SSH keys are definitely better than hard-coding the username/password, it's worth mentioning that Stash (currently) scales better with HTTP when it comes to CI. If you have quite a few builds we generally recommend using HTTP. We are currently extending our Git cache support to support SSH so this no longer an issue.
Somewhat related, you might be interested in watching and voting for the following feature which will make it easier to create CI specific keys.
Lastly having build icons show up in Stash is surprisingly handy, and you should have a look at the following plugin if you haven't already:
https://github.com/jenkinsci/stashNotifier-plugin
Since version 2.0 of "Git Plugin" for jenkins you should be able to directly add the required credentials for both ssh and username/password (based on credentials plugin).
See changelog of Git plugin: https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-Changelog for details.
For further integration of git and stash regarding pull requests you additionally need the "Stash Webhook for jenkins" add-on in stash and the "Stash Notifier" plugin for jenkins to connect each other.

Resources