score:1
you may trace successful and failed jenkins builds from git commits to associated ca agilecentral (rally) artifacts by using git connector and jenkins plugin as long as both point to the same repository, and a commit in git mentions formattedid of related artifact.
here is a java example based on rally api toolkit for java. regardless of the choice of toolkit, language, etc. it is the underlying ws api object model that provides access to this data. i limited build query by creationdate. among other fields on build object i fetch changesets collection. each element of that collection is a reference to a changeset object. git connector creates changesets objects in ca agile central(rally). each changeset object has artfacts collection field and changes collection field. each element of artifacts collection is a reference to rally artifact, e.g. user story, defect. by fetching pathandfilename on each change object you get the associated source file. now we can trace a failed build to a specific commit, file, and user story.
this is a screenshot from the console output created by java code below. eventually you may want to present data it a more visually appealing way. this example only shows that builds and commits can be traced to user stories or defects via ws api.
separate requests are often needed to hydrate collections in ws api. since build and cangesets data can be large, binding those queries by some criteria, e.g. creationdate will make it faster.
public class getbuilddata {
public static void main(string[] args) throws exception {
string host = "https://rally1.rallydev.com";
string apikey = "_abc123";
string applicationname = "nickm:getbuilddata";
string workspaceref = "/workspace/12345";
string projectref = "/project/1346";
rallyrestapi restapi = null;
try {
string datestring = "2016-05-12";
restapi = new rallyrestapi(new uri(host),apikey);
restapi.setapplicationname(applicationname);
queryrequest buildrequest = new queryrequest("build");
buildrequest.setfetch(new fetch("status,message,start,uri,changesets"));
buildrequest.setqueryfilter(new queryfilter("creationdate", ">", datestring));
buildrequest.setworkspace(workspaceref);
buildrequest.setproject(projectref);
queryresponse buildresponse = restapi.query(buildrequest);
for (int i=0; i<buildresponse.gettotalresultcount();i++){
jsonobject buildobj = buildresponse.getresults().get(i).getasjsonobject();
system.out.println("build status: " + buildobj.get("status") +
"\n build message: " + buildobj.get("message") +
"\n build start: " + buildobj.get("start") +
"\n build uri: " + buildobj.get("uri"));
jsonobject changesetscollection = buildobj.get("changesets").getasjsonobject();
queryrequest changesetsrequest = new queryrequest(changesetscollection);
changesetsrequest.setfetch(new fetch("artifacts","changes", "revision"));
changesetsrequest.setlimit(1000);
queryresponse changesetsresponse = restapi.query(changesetsrequest);
for (int j=0; j<changesetsresponse.gettotalresultcount();j++) {
jsonobject changesetobj = changesetsresponse.getresults().get(j).getasjsonobject();
system.out.println("\nchangeset revision: " + changesetobj.get("revision"));
jsonobject artifactscollection = changesetobj.get("artifacts").getasjsonobject();
queryrequest artifactsrequest = new queryrequest(artifactscollection);
artifactsrequest.setfetch(new fetch("formattedid"));
queryresponse artifactsresponse = restapi.query(artifactsrequest);
for (int k=0; k<artifactsresponse.gettotalresultcount();k++) {
jsonobject artifactobj = artifactsresponse.getresults().get(k).getasjsonobject();
system.out.println("\nartifact formattedid: " + artifactobj.get("formattedid"));
}
jsonobject changescollection = changesetobj.get("changes").getasjsonobject();
queryrequest changesrequest = new queryrequest(changescollection);
changesrequest.setworkspace(workspaceref);
changesrequest.setproject(projectref);
changesrequest.setfetch(new fetch("pathandfilename"));
queryresponse changesresponse = restapi.query(changesrequest);
for (int l=0; l<changesresponse.gettotalresultcount();l++) {
jsonobject changeobj = changesresponse.getresults().get(l).getasjsonobject();
system.out.println("change pathandfilename: " + changeobj.get("pathandfilename"));
}
}
system.out.println("--------------------------------");
}
} finally {
if (restapi != null) {
restapi.close();
}
}
}
}
if you want to display build data inside agile central (rally) appsdk2.1 javascript app can be deployed in a custom page. here is quick example to start with:
<!doctype html>
<html>
<head>
<title>builds by date</title>
<script type="text/javascript" src="/apps/2.1/sdk.js"></script>
<script type="text/javascript">
rally.onready(function () {
ext.define('customapp', {
extend: 'rally.app.app',
componentcls: 'app',
launch: function() {
this.add({
xtype: 'component',
itemid: 'datepick',
html: 'pick a date:',
width: 100,
margin: 10
},
{
xtype: 'rallydatepicker',
showtoday: false,
contentel: ext.componentquery.query('#datepick')[0],
margin: 10,
handler: function(picker, date) {
this.getbuilds(date);
},
scope:this
},
{
xtype: 'container',
itemid: 'gridcontainer'
});
},
getbuilds:function(date){
var formatteddate = rally.util.datetime.formatwithdefault(date, this.getcontext());
ext.componentquery.query('#datepick')[0].update((formatteddate) + '<br /> selected');
if (this.down('rallygrid')) {
ext.componentquery.query('#gridcontainer')[0].remove(ext.componentquery.query('#buildsgrid')[0], true);
}
this.down('#gridcontainer').add({
xtype: 'rallygrid',
itemid: 'buildsgrid',
columncfgs: [
'status',
'message',
'start',
'uri',
'changesets'
],
storeconfig: {
model: 'build',
filters:[
{
property: 'creationdate',
operator: '>=',
value: rally.util.datetime.toisostring(date,true)
}
]
}
});
}
});
rally.launchapp('customapp', {
name:"builds by date",
parentrepos:""
});
});
</script>
<style type="text/css">
.app {
/* add app styles here */
}
</style>
</head>
<body>
</body>
</html>
score:1
if you append /api/json?pretty=true
to the end of your job's url in jenkins you can see a json output of the job itself, which can lead you to the latest build number. further, that will lead you to the url of the most recent build, which (again appending /api/json?pretty=true
) can lead you to a json list of changesets (and corresponding commit messages).
you might not even need to tap into rally! :-)
you can consume that json from your spring application using json marshaling and the resttemplate
spring class.
Source: stackoverflow.com
Related Query
- How can I retrieve a list of changes for my Java web app?
- How can I deploy a java web app to heroku?
- How to go about creating a user authentication system for a Java web app on AWS Elastic Beanstalk?
- Push notification for Java web app
- How can I Optimize Spring Framework usage for Google App Engine Applications
- How can I run common code for most requests in my Spring MVC Web App?
- How can I set correct Last-Modified header value for Spring Web Service that is cached using Spring Cache?
- How do I use a custom authentication mechanism for a Java web application with Spring Security?
- Stripes for Java Web Dev, is it worth learning ? Is it easier ? how it compared to Struts?
- How to do continous deployment for Java web applications with free software
- How do I create a folder In Bluemix for Java Web Application?
- How can you register a converter to convert between a String and a List of specific types in Spring Web MVC?
- How to retrieve ip address of the source system from http request from web app developed with java?
- How to retrieve List <String> from HttpResponse object in Java
- How can I have list of all users logged in my web application
- A "Portlet-Like" java technolgy for a Web app
- How can i custom filter for 302 Status Code in spring mvc java and response.redirect to custom page?
- Can't retrieve data when using IP address as URL for my web app
- How can I retrieve the list of object associated as field into an entity class?
- How to retrieve web application root path in Java
- How can I store java List using hibernate and spring mvc4?
- How keep track of user`s last activity in a web app in java and spring mvc and MongoDB
- How to restrict a user after 3 consecutive unsuccessful attempts for login in Java Web App?
- How Do I Scan for Annotation in Spring Web App Using Reflections Library (or other)
- How to create a Spring Interceptor for Spring RESTful web services
- Is there a templating language similar to Razor for Java Spring web applications?
- Best way for a Spring MVC web app to detect a brute force attack?
- Moving from ASP.Net to Java for web development
- How to integrate Apache Spark with Spring MVC web application for interactive user sessions
- How a jar can propagate a vulnerability in a web application where it is used?
More Query from same tag
- Spring MVC - how to redirect to login if not logged in
- Spring Data REST endpoint disappears (hibernate conflict)
- How do you create multiple Spring @RestControllers each with their own thread pool?
- Encrypting Joda Date combined with username as a single variable
- byte[] from input file in spring mvc
- How to return an html file using Spring MVC controller
- Spring 3 MVC:Neither BindingResult nor plain target object for bean name available as request attribute
- Migrating from JSP to Freemarker
- Fortify Scan issue (XSS) Cross site scripting Reflected - method sends unvalidated data to webbrowser
- Spring MVC dispatcher servlet.xml error
- How use Angularjs expression in spring MVC?
- Using ResponseEntity Spring MVC
- Spring MockMvc redirect not working
- Avoid Jackson serialize Mybatis lazyload object in SpringMVC
- Software architecture: How to Abstract the Portlet API
- reference a .css file with thymeleaf in spring mvc
- Issue with Date type (OBJECT or NUMBER)
- HikariPool-1 - dataSource or dataSourceClassName or jdbcUrl is required
- Shoud the Spring request mapping logic map to a handler method based upon the value of servletPath?
- Unable to send data from controller to javascript
- Recover username and password with spring security
- Spring security: Restricting form interactivity using roles
- Ensuring that two Request Mapping variables match in Spring MVC
- Spring MVC Validation error
- Mock the response of a webservice using Spring 3.2 and Mockito
- building multiple indexes with hibernate search
- Doing pre-checks before calling controller in spring MVC
- Creating asynchronous events in spring
- Angularjs, Spring MVC and @ModelAttribute = null values
- Json multiparameters by using spring mvc and jackson