Bamboo api to get the recent build number for a specific branch - api

I'm trying to get the latest build number from a specific branch. I'm able to do with the below api call. It get the build number whether the job is success or failed, but not if its ABORTED. can anyone let me know the api call to get the build number even if thats aborted?
api call - curl https://bamboo.test.com/rest/api/latest/result/AVC-SFADR15?max-results=1

includeAllStates is the paramter you need
Use below command:
curl https://bamboo.test.com/rest/api/latest/result/AVC-SFADR15?max-results=1&includeAllStates

Related

Trigger DAG Run - 403

I am following this tutorial to build a Cloud Function that triggers a DAG run. I have run into a permission issue. Upon the function being triggered and thus trying to run the DAG, I get a permission error message. It reads as follows:
Service account does not have permission to access the IAP-protected application.
I have followed the recommendation in the tutorial to have a service account with the Composer User role. What am I missing?
Note: I am calling Airflow version 2's Stable REST API and my Composer is version 1.
-Diana
I found a perhaps duplicate question here:
Receiving HTTP 401 when accessing Cloud Composer's Airflow Rest API
As Seng Cheong noted in their answer, the reason for this error is that Google Cloud seems to have issues adding service account IDs that are longer than 64 characters to the Airflow list of users. Upon changing my service account ID to one <= 64 characters, I was able to trigger the DAG successfully. If you can't make your service account ID shorter, then Google documentation suggests adding the "numeric user id" corresponding to your service account directly. The steps for how to do so can be found here: https://cloud.google.com/composer/docs/access-airflow-api#access_airflow_rest_api_using_a_service_account
Best of luck friend

Ansible : get playbook result

I am using Ansible to deploy a PHP website into my servers (production, staging, etc), and I would like to get a notification (via skype).
For it I need learn ansible to send post request (with some params) when any ansible task starts or finishes (with result : success/failed or with error description)
Help me please with realization of all this stuff since I have any ideas about it. =(
You have to write your own callback plugin.
Take a look at slack notification plugin.

How to get statistic data from teamcity?

I'd like to get some statistics data from TeamCity. I don't know if It's better to do this using TeamCity REST API or by queering TeamCity Database to get the data I need.
Can someone advice me which one is better ?
FYI: I tried to use TeamCity Restful web services but if I request a project containing a lot of build configs, I get a timeout exception :
iagnostic.web.DiagnosticFilter - Request processing took too long: 192577 ms, request: GET '/app/rest/builds/?locator= ...
TeamCity version: 9.1.1(build 37059)
I finally used REST API. I get failed tests of the last build for each buildConfig.

how to find chef client run successful or not

I want to perform chef operations using api from my own program(java). I would like to know whether my chef client run is successful or not.
What is the best way to find this. Did chef maintains any attribute or store recent chef client run status.
You can get the timestamp of the last successful run from the node data (key is ohai_time), but that's about it for vanilla Chef. More likely what you want is the information for specific runs, which you could get from the Reporting system (part of the Premium add-ons) or by making a custom report/error handler to ship the data to your own system.

How to stop a build in Jenkins via the REST api ?

I have a job in Jenkins. A website of our own triggers builds of this job via the REST api. Sometimes we want to abort the build. Sometimes, it can be before the build is even started. In such cases we have the queueItem # instead of the build #.
How to do so via the REST api ?
If the build has started, by POST on:
http://<Jenkins_URL>/job/<Job_Name>/<Build_Number>/stop
Will stop/cancel the current build.
If the build has not started, you have the queueItem, then POST on:
http://<Jenkins_URL>/queue/cancelItem?id=<queueItem>
This is assuming your Jenkins Server has not been secured, otherwise you need to add BASIC authentication for a user with Cancel privileges.
Actually this question is already answered. So I will add, how to find id=<queueItem> , which I got stuck on finding this solution, which will helpful for others.
So, you can get <queueItem>, by - http://jenkins:8081/queue/api/json
Sample Output will be of json type like this one -
[{"_class":"hudson.model.Cause$RemoteCause","shortDescription":"Started by remote host 172.18.0.2","addr":"172.18.0.2","note":null}]}],"blocked":false,"buildable":false,"id":117,"inQueueSince":16767552,"params":"\nakey\t=AKIQ\nskey=1bP0RuNkr19vGze/bcb4ijDqVr8o\nnameofr=us\noutputtype=json\noid=284102\nadminname=admin","stuck":false,"task"
You have to take "id":117, and parse it to -
queueItem =117.
http://<Jenkins_URL>/queue/cancelItem?id=queueItem
Maybe you want to remotely send a post http request to stop a running build, there is a clue FYI, the jenkins job can stop another job(running build), like any jenkins admin click the X button when job is running.
Http Request Plugins is required by Jenkins ver2.17
Uncheck the Prevent Cross Site Request Forgery exploits option. Manager Jenkins -> Configure Global Security -> Uncheck
Setup Http Request Plugins's authorization. Manager Jenkins -> Configure System -> HTTP Request Basic/Digest Authentication -> add. Make sure the user has the job cancel permission
Job A is running. In job B, add build step as HTTP Request, URL: http://Jenkins_URL/job/Job_A_Name/lastBuild/stop, HTTP mode: POST, Authorization select the user you have just set, then build job B.
Done
If you only need to cancel the active build from a certain job you can use this batch script (windows .bat syntax):
REM #Echo off
CLS
REM CANCEL ACTIVE BUILD
REM PARAMETER 1 ACTIVE JOB NAME
if [%1] == [] GOTO NO_ARGUMENT
SET domain=https://my.jenkins.com/job/
SET path=/lastBuild/stop
SET url=%domain%%1%path%
"\Program Files\Git\mingw64\bin\curl.exe" -X POST %url% --user user:pass"
GOTO THEEND
:NO_ARGUMENT
Echo You need to pass the active jobname to cancel last build execution
:THEEND
Path to your local curl needs to set.