The Jenkins build was successful but when I add the Jenkins build link GitHub Pull Request description. It's showing the the last Jenkins build Link failed.
Any Idea what causes the error?
Related
The idea is that I want to block pull requests on GitHub if a build fails on Jenkins so that potential bad code doesn't get merged
I had originally found a plugin called Pipeline GitHub Notify Step: https://www.jenkins.io/doc/pipeline/steps/pipeline-githubnotify-step/ that uses
githubNotify
but then I found out from this link https://plugins.jenkins.io/pipeline-githubnotify-step/ that we should use the github-checks-plugin instead of the Pipeline GitHub Notify. I don't know if its because its depreciated or they just added similar features to the github-checks-plugin but I decided to just install the GitHub Checks Plugin. Afterwards I opened a PR on GitHub with code I knew would fail the build then ran a test build on Jenkins with the impression that GitHub would block my PR due to the bad build but it didn't I went under settings->branch and enabled Require status checks to pass before merging but it didn't block my PR because of the failed build. In fact it still doesn't even notice the failed build. Maybe I'm missing another plugin or perhaps there was something I forgot to enable.
I have recently started using Jenkins Pipelines and have a multibranch job configured which is happily picking up Jenkinsfile on one of my branches.
I have seen in screenshots on posts\articles that Jenkins can report back to pull requests in GitHub the status of whether the branch has passed\failed checks performed in the pipeline.
I am not seeing any such feedback for my pull request I have opened, I can see in Jenkins it has triggered a pipeline build which has passed.
How can I get the notification to show the pipeline checks have passed in GitHub. Do I need to configure something else?
I found out this was simply down to me using the Git instead of GitHub sources option when configuring the multibranch pipeline job in Jenkins.
The docs for the GitHub Branch Source plugin gave me the clues!
I now get status messages on my pull requests showing whether pipeline checks are pending\failed\passed.
Check out the Github Pull Request Builder Plugin, it should do what you require: https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin
I know there were a lot of conversations to this topic but any of those was helpful to me. So what I'm doing is configuring Jenkins CI to work properly with Github.
We want next:
When someone creates new PR or add commit to existing PR, Github
triggers Jenkins build.
During build is processing we want to see status - pending
Merge button should be disabled till build is completed
After build is completed, we want to see what is the status of that build - successful or failed
Right now, only step 1 works correctly but we can't figure out what is the problem with Jenkins requests to Github!
Also in console output I see error:
ERROR: Build step failed with exception java.lang.IllegalStateException: Can't get remote GH repo for project1 build and don't know what is the problem.
Any help would be really appreciated !
Regards
If you are using GitHub Pull Request Builder , go to trigger setup -> Update commit status during build
In reference with the post
jenkins + sonar + github integration
What setting is required in sonarqube? Does Sonar and Jenkins reside on the same box? How will Sonarqube be able to communicate with github? I am able to get the pull request triggering the Jenkins Job which is calling the sonar analysis, but the sonar comments are not getting added back to github. I am able to add the Jenkins build status but not the sonar analysis . Can someone point to the right direction
SonarQube don't need to communicate with GitHub.
Jenkins have a plugin "Git-Plugin" used to connect with it, you only have to paste the repository url there.
Jenkins have a plugin "SonarQube Plugin" used to call sonarQube, this will return a status after sonnar analysis.
Then you can create another task in Jenkins to makes changes in GitHub according to the status.
Almost breaking my head over this for last few days but the github plugin for sonarqube (v 5.3) just does not seem to work.
I have my java app code in github, and have configured Jenkins to run mvn sonar:sonar goal on pull request.
The maven settings are:
clean site sonar:sonar
-Dsonar.analysis.mode=preview
-Dsonar.github.oauth=<OAUTH_TOKEN>
-Dsonar.github.repository=<ORG>/<REPO>
-Dsonar.github.pullRequest=${ghprbPullId}
-Dsonar.github.endpoint=<ENT_GITHUB_API_BASE__URI>
For sonar.analysis.mode, I tried 'issues' too
Now I perform foll:
make change to a fork (introduce a violation as per configured quality gate)
commit and push to fork repo
Create a pull request
run the jenkins job using above configuration
The analysis is successful, and the plugin always reports that all checks have passed and changes can be merged. I am just not able to understand why the github plugin in sonar is not able to show violation occured and checks have failed.
Now if I merge the pull request and run sonar analysis in publish mode on the master repo, it says quality gate failed and I am able to see this in SonarQube dashboard for the project with the statement that Quality gate has failed
What am I doing wrong here? My guess is the github plugin not able to compare the changes in the pull request with that in the master repo and hence not able to report the violation. How do I fix that?
Update:
If at the end, I merge the pull request to master repo and re-run the sonar analysis on the original pull request (the one that got merged), it does report the violation as comments in the Pull Request conversation. (But what is the point if sonar is going to report the violations after the pull request is merged???)