YouTrack now with view of pull requests in tasks

Hello, Habr!



The YouTrack team from JetBrains is here. We have great news - starting with YouTrack 2020.3, tasks display not only task-related commits, but also pull requests. In today's post, we will tell you what it is, why it is, and how it will help make the development process more efficient and understandable, and also show the rest of the innovations in the latest version of YouTrack.



image



For details, welcome to the post.



What is a pull request?



In a number of development model models, collaborating on a project looks like this: you copy the project from source control, make changes locally, and then send a request to the project owner to approve your changes and include them in the common project code base. Such a request is called a pull request (or a merge request, depending on the version control system).



Roughly speaking, a pull request is a way to tell the repository owner or your team what you have done on a project and suggest that your changes be included in one of the general development branches. The repository owner (or the person who will do your code review) can either accept the changes (merge the pull request) or reject it - for example, if the changes contradict the vision of the author of the project or during the code review process they decided that the code needs to be improved.



In open source projects, there are often requirements for pull requests, without which the pull request will not be accepted: for example, our colleagues from the Kotlin team ask developers to make sure that the description of the pull request contains a link to the corresponding issue in YouTrack, that changes in the pull request are specific to the specified tasks, and that new code is being run, executed correctly, and covered by tests.



Why pull requests in the tracker?



Creating and accepting / rejecting pull requests are as important steps in the lifecycle of a task as changing status or linking the corresponding commit. All these steps show the progress of the task to all interested observers - for example, the community of an open source project or the project manager of the team. For example, if a task was not closed due to the rejection of a certain pull request, this information must be reflected in the history of the task - including for retrospective purposes, when you need to understand why the task has been left open for so long. This mechanism makes the development process more transparent and allows you to track the lifecycle of the issue step by step, without missing important events.



View pull requests in issues



Back to YouTrack, starting with YouTrack 2020.3, developers will be able to see pull requests from GitHub, GitLab, BitBucket, Gogs, and Gitea in tasks next to commits. In order for the pull request, along with its description, the number of updated files and information about the author, to appear in the task, you need to mention the corresponding task in the name of the pull request (everything is exactly the same as with commits).



Further, after accepting or rejecting the pull request, YouTrack will include this event in the activity flow of the task along with the event author and the status of the pull request. It turns out that the task change feed will display the entire life cycle of the pull request - its creation and the final decision (rejection or inclusion in the codebase).



image



Automate it



We love and actively use automation, so we could not pass by the opportunity to use events from the version control system in automation scripts. You can now initiate a YouTrack workflow when you add a pull request or commit. In addition, workflows now have access to properties for commits and pull requests, such as author name, description, or note.



What does it mean? For example, you can automatically change the status of a task based on the status of the pull request, or send a request for code review to a colleague when creating a pull request.



Such a simple script will automatically transfer the task to the Fixed status when merging a pull request and then assign it to the QA lead with a message that the task is ready for testing:



var entities = require('@jetbrains/youtrack-scripting-api/entities');
var QA_LEAD = 'qa_superman';

exports.rule = entities.Issue.onChange({
  title: 'Set_to_fixed_when_pull_request_is_merged_and_notify',
  guard: function(ctx) {
    return ctx.issue.pullRequests.isNotEmpty() && 
      ctx.issue.pullRequests.last().previousState && 
      ctx.issue.pullRequests.last().state.name !== ctx.issue.pullRequests.last().previousState.name &&
      ctx.issue.pullRequests.last().state.name === "MERGED";
  },
  action: function(ctx) {
    var issue = ctx.issue;
    issue.State = ctx.State.Fixed;
    issue.Assignee = entities.User.findByLogin(QA_LEAD);
    issue.addComment("The issue is ready to be tested");
  },
  requirements: {
    State: {
      type: entities.State.fieldType,
      Fixed: {
        name: "Fixed"
      }
    },
  }
});


As before, scripts can be run on a schedule or on a specific event, depending on your process. Details on workflows and how to write them can be found here .



What else is interesting?



Of course, we have not limited ourselves to just looking at pull requests. Among the other innovations is a new time tracking widget for dashboards (dashboards), so that it is more convenient to monitor productivity and not get carried away with overtime in quarantine.



image



For convenient work with the list of tasks, we have added the ability to display only unfinished tasks in one click and sort tasks by the number of comments. The knowledge base got syntax highlighting for code blocks with automatic detection of the programming language, and for Markdown lovers, we made it possible to resize embedded images, videos and other media files in tasks and articles.



There is news for those who use an LDAP server to manage user credentials. YouTrack used to allow you to authenticate using credentials from an LDAP server, and now it has added scheduled synchronization of user groups and attributes to the LDAP server. This will keep credentials and LDAP group membership information up to date - for example, it will help to avoid unauthorized access to data in the tracker if the user is not already a member of a group on your LDAP server, but still gets the corresponding access in the tracker due to latency in synchronization between the LDAP server and YouTrack.



Details of all changes can be found on our website .



And if you're new to YouTrack or just getting started, welcome to our free demo of YouTrack basics.



All Articles