I have a jenkins Job that do two steps.
1) Get source code from GIT
2) Run the source code analisys using SONAR-RUNNER
The Job works fine and I'd like to copy/create a similar Job.
I tried to create a new Job using the command: curl -s --data-binary #config.xml -H "Content-Type: application/xml" -X POST http://localhost:8080/createItem?name=SONAR-NEW
It does create a new Job, however the SONAR-RUNNER part is empty and if I ran the build it doesn't make the SONAR part. The funny thing is that if I check the config.xml generated the SONAR-RUNNER configuration part is there.
The same thing happens if I try to copy the JOB, I tried it using:
1) jenkins-cli, or
2) curl --data "name=NEWJOBNAME&mode=copy&from=SONAR" -X POST http://localhost:8080/createItem
If I have a different build step, for example a "Execute SHell", I am able to copy/create the JOB.
So my question is how can I create or copy a JOB that as a build step using "Execute SonarQube Scanner"
Related
I am hitting the curl command which starts the jenkins job, but i also wanted to get the running logs of build is is possible with the help of curl command.
Take a look at
Jenkins REST API to get job and job console log
and
https://serverfault.com/questions/888176/how-to-trigger-jenkins-job-via-curl-command-remotely
Generally, you have to start job get handler and periodically call API
The environment BUILD_URL represents the current build url, thus you can get the current build log as following in job post action
curl -u 'jenkins_user:jenkins_pwd' -k "${BUILD_URL}consoleText"
We are currently using Bamboo in our company but need Jenkins for a specific task the Bamboo machine is not capable of. Is it possible to set up a Jenkins build job and trigger it remotely out of Bamboo, so not everybody has to figure out the new interface?
You can run Jenkins jobs remotely, even jobs that require parameters, by means of the REST API, find more information in the documentation here.
You can add a Bamboo task in your job to run a shell script that actually consumes the Jenkins API in that case you might need curl to be installed (in case of using a python script you can use requests, etc)
Example: To just run a Jenkins job that does not requires any params:
curl -X POST --user USER:TOKEN JENKINS_URL/job/JOBNAME/build
Example: To run a Jenkins job that requires params:
curl -X POST JENKINS_URL/job/JOB_NAME/build \
--user USER:TOKEN \
--data-urlencode json='{"parameter": [{"name":"id", "value":"123"}, {"name":"verbosity", "value":"high"}]}'
I have a requirement where i need to trigger the build jobs remotely using curl command. I am unable to pass the branch/tag name as a parameter to trigger the build.
I used the below command :
& $CURLEXE -k -X POST $dst_job_url --user username:token --data-urlencode json='{"parameters": [{"name":"branch","branch":"branches"}]}'
If i run the above command it was triggers the build for the trunk ( default ).
You omitted the URL, so it's hard to be certain. Jenkins has two urls for building: "build" and "buildWithParameters". If you're not using buildWithParameters, switching to it will probably help.
See:
How to trigger Jenkins builds remotely and to pass parameters
I am working with Ant and using jenkins to make builds.
SO, I am using jenkins and build.xml for a job. But I want to call another job in my build.xml to call another job in a different jenkins.
How can I do that?
Thanks.
Using curl you can trigger a remote jenkins job :
curl -X POST http://${user}:${password}#${jenkins_url}/job/${job_name}/build
Have a look at this https://support.cloudbees.com/hc/en-us/articles/218889337-How-to-build-a-job-using-the-REST-API-and-cURL-
Now, to execute this curl from ant/build.xml, use exec task of ant.
I've managed to create a CircleCI build that triggers a subsequent build using their API using curl. I've added this to my circle.yml:
test:
override:
- mvn test -s settings.xml
- mvn deploy -Prun-its -s settings.xml
- curl -v -X POST https://circleci.com/api/v1/project/alexec/docker-maven-plugin/tree/master?circle-token=$CIRCLE_TOKEN
How do I trigger only if all of the previous steps are green?
I think you should do this in the deployment section: Since this is - by definition - only run if everything is fine, this should do the trick.
See their documentation on deployment for details. There it says:
These commands are triggered only after a successful (green) build.
You should have a requires variable in your job that you want to run only if the previous job has run. So you give the requires variable a value of the job name that you want to succeed first before the jobs resume running.
See this example: https://circleci.com/docs/2.0/configuration-reference/