Could someone please elaborate on how to use jenkins apiToken for build through rest api.
I want to use user based authentication for Jenkins build.
So I have that apiToken with me but when I am trying to build a job I am getting forbidden exception.
I have followed the below url for build a job.
https://wiki.jenkins-ci.org/display/JENKINS/Authenticating+scripted+clients
There is a project called Python Jenkins that provides the wrapper around the Jenkins REST API. I believe you may find a sample of using the authenticated build invocation there. You may find it here
Related
I am trying to trigger a build in Jenkins directly from Xray. I have been successfully able to create a trigger in jira and has provided the webhook url and other information needed to run the build. But on triggering the build from any Test Plan, I am getting the following error:
Error publishing web request. Response HTTP status:503
ERROR: The requested URL could not be retrieved.
When i'm hitting the same webhook url in any browser, then the build is getting triggered in jenkins, hence it seems there's no issue with the provided webhook url.
One thing to note is that our Xray is in Jira cloud whereas the Jenkins is running behind a VPN. Can anyone help me in resolving the above issue?
If your Xray on Jira Cloud is trying to acess Jenkins, the Jenkins server needs to have a public URL. If you have it behind the firewall then it's not possible for Xray or any other tool to trigger it directly.
You can call the Jenkins URL from your browser because you are probably with your vpn connected.
The possible workaround would be to use a tool such as ngrok, as mentioned in the docs, to make a tunnel, but beware with the security implications of exposing your Jenkins url to the world.
For reference, Xray cloud provides documentation/examples showcasing how to take advantage of Jira Cloud automation capabilities to trigger jobs, for example in Jenkins.
I want to use the AWS Parameter Store Build Wrapper Jenkins plugin in my build.
https://plugins.jenkins.io/aws-parameter-store/
Above is the link to that plugin. The issue is I didn't find any proper source on how to use that plugin in the jenkinsfile.
When I installed that plugin to my local Jenkins, I couldn't see how to configure that plugin in any jenkins build configuration page as well.
If anyone can shed some light on this issue, that would be great.
My ultimate goal is to access some things from the AWS Parameter store. If there's any other way that I can achieve this, I'm more than happy to use that way instead of this plugin as well.
I have an automated Jenkins workflow that runs and tests a java project. I need to get all the data and results that are outputted by Jenkins into Report Portal (RP).
Initially, I was under the impression that you have to install the ReportPortal.io Jenkins plugin to be able to configure Jenkins to communicate with RP.
However, it appears that the plugin will eventually be deprecated.
According to one of the RP devs, there are APIs that can be used, but investigating them on our RP server does not give very clear instructions on what every API does or if it is what is required to get test data from Jenkins to RP.
How then do I get Jenkins to send all generated data to RP?
I am very familiar with Jenkins, but I am extremely new to Report Portal.
ReportPortal is intended for test execution results collection, not for jenkins logs gathering.
In two words, you need to find reporting agent at their github organization which depends on your testing framework (e.g. junit, testng, jbehave) and integrate it into your project.
Here is example for TestNG framework:
https://github.com/reportportal/example-java-TestNG/
I would like to ask is there any way to query run time build steps by using Jenkins pipeline REST API? I refer to this link https://github.com/jenkinsci/pipeline-stage-view-plugin/tree/master/rest-api and it seems like I can't get a run time build steps command line that I configure for Jenkins pipeline job.
Any suggestions?
It seems there is no possibility to get this information via the REST API. I found a solution somewhere.
With
http://Serverurl/job/jobname/config.xml
you can download the config file and parse the XML. Doing it with PowerShell and it's working fine.
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