Minibrūža projekts: kontrolieris

Pēdējā gada laikā pavisam lēni lieku kopā ar elektrību kontrolētu alus brūvēšanas katlu. Doma ir pāriet uz 40l brūvēšanu vienā reizē, un to visu darīt izmantojot BIAB metodi (“brūvēt maisā”).

Beidzot pabeidzu temperatūras kontrolieri, ar ko kontrolēt brūvēšanas katlā iemontētos teņus. Plastmasas sadales kastē samontēts pats PID kontrolieris, slēdzis, relejs, 2 kontaktligzdas un PT100 temperatūras sensors.

How to disable the PDF Preview feature in JIRA 7

  • Copy locally and extract Jira bundled plugin jira-fileviewer-plugin-7.2.1.jar located at ./atlassian-jira/WEB-INF/atlassian-bundled-plugins
  • In extracted folder open file-service.js and delete (or wrap in comment) following lines:
if (!featureManager.isFeatureEnabled("jira.fileviewer.disable.pdf")) {
    selectors.document.push("a[file-preview-type=document]");
}
addDocumentSelector: function addDocumentSelector(sel) {
    pushSingleOrArray(selectors.document, sel);
}
  • Remove same lines from minified file-service-min.js.  You can use JS prettify and minify tools to do this.
  • Save files. Put folder content in ZIP. Rename file to jira-fileviewer-plugin-7.2.1.jar, copy to server and restart Jira.

Script to restart JIRA automatically (Jira)

I have modified Atlassian script to support following features:

  • Cleanup for leftover files – .jira-home.lock, catalina.pid
  • catalina.out log backup
  • Check for running process and force kill JIRA if it won’t stop on time
#!/bin/sh -e
# JIRA startup script
# Description: For JIRA 7.2.7

# Define some variables
# Name of app ( JIRA, Confluence, etc )
APP=jira
# Name of the user to run as
USER=root
# Location of application's bin directory
BASE=/u01/jira/Prod_7.2.7
export JIRAHOME=$BASE
# Location of application's home directory
JHOME=/u01/jira/Prod_7.2.7_home
export JIRA_HOME=$JHOME
# Location of Java JDK
export JAVA_HOME=/usr/java/default

case "$1" in
  # Start command
  start)
    echo "Starting $APP"
    lockfile="$JHOME/.jira-home.lock"
    [ -e $lockfile ] && rm $lockfile

    pidfile="$BASE/work/catalina.pid"
    [ -e $pidfile ] && rm $pidfile

    logfile="$BASE/logs/catalina.out"
    [ -e $logfile ] && mv $BASE/logs/catalina.out "$BASE/logs/catalina-`date +%F`.out"

    /bin/su -m $USER -c "cd $BASE/bin && $BASE/bin/start-jira.sh &> /dev/null"
    ;;
  # Stop command
  stop)

    blah=""
    temp=`ps aux|grep java|grep jira|grep -v grep|awk '{print $2}'`
    pidfile="$BASE/work/catalina.pid"

    if [ "$temp" == "$blah" ]
    then
       echo 'JIRA is not running'
       exit 0
    fi

    echo 'Shutting down JIRA'
    /bin/su -m $USER -c "$BASE/bin/stop-jira.sh &> /dev/null"

    echo 'Sleeping 30 seconds, because sleeping is good...'
    sleep 30 

    temp=`ps aux|grep java|grep jira|grep -v grep|awk '{print $2}'`

    echo 'Now checking if JIRA is still running...'

    if [ "$temp" != "$blah" ]
    then
       echo 'Force killing JIRA now...'
       /bin/su -m $USER -c "$BASE/bin/catalina.sh stop -force $num >/dev/null 2>&1"
       echo 'Killed'
       exit 0
    else
       echo 'JIRA is already down'
       exit 0
    fi

    echo "...done"
    exit 0
    ;;
   # Restart command
   restart)
        $0 stop
        sleep 60
        $0 start
        ;;
  *)
    echo "Usage: jira {start|restart|stop}"
    exit 1
    ;;
esac

exit 0

Docker un tā pielietojums programmatūras ražošanas procesu automatizācijai

Atdevu, aizstāvēju bakalaura darbu. Publicēju šeit, varbūt kādam noder.

Nosaukums LV: Docker tehnoloģijas analīze un realizācija programmatūras izstrādes procesa automatizācijai

ENG: Analysis and Implementation of Docker Technology for Automation of Software Development Process

Anotācija:

Bakalaura darba tēma ir “Docker tehnoloģijas analīze un realizācija programmatūras izstrādes procesa automatizācijai”.

Bakalaura darba tēma ir “Docker tehnoloģijas analīze un realizācija programmatūras izstrādes procesa automatizācijai”.Darba analītiskajā daļā ir apskatītas virtuālo mašīnu tehnoloģijas un to iedalījums tipos – uz hipervizoriem bāzēta un uz konteineriem bāzēta virtualizācija. Ir veikts abu tipu salīdzinājums, novērtējot ieguvumus un trūkumus.

Darbā ir veikta sīkāka Docker tehnoloģijas izpēte. Ir apskatīta tās izveides vēsture un attīstība, kā arī uzbūves arhitektūra. Ir izpētīti ar Docker konteineriem saistītie drošības riski, kā arī analizēts veiktspējas pētījums, kurā tos salīdzina ar uz hipevizoriem balstītu virtualizāciju.

Darba praktiskajā daļā ir veikta Docker virtualizācijas prototipa izstrāde. Ir apskatīti programmatūras testēšanas vides izveides, testa būvējumu uzstādīšanas, testa vides atjaunošanas procesi, kā arī veikta šo procesu automatizācija. Ir aprakstīti izstrādātā prototipa ieguvumi, rezultāti un tālākie attīstības virzieni.Darba rezultātā ir sasniegti visi izvirzītie mērķi un dots reāls risinājuma piemērs programmatūras ražošanas procesa izpildes ātrumu uzlabošanai.

Bakalaura darbā ir 51 lappuse, 14 attēli, 7 tabulas, 60 nosaukumu informācijas avoti.

Atslēgvārdi:  docker, konteineri, virtualizācija, automatizācija, devops,  docker, containers, virtualization, automation, devops

Karlis_Rozenbergs_101REB307

Show Custom Field for specific groups, roles in JIRA (Jira)

scriptI have written a Javascript code which allows to hide Custom Field from all users except groups/roles defined in script.

Be aware that this is just a visual way to hide field. It will be possible to see field in HTML source of page.

Installation: paste it in Announcement Banner and set variables based on your environment.

<script type="text/javascript">
  /*	Karlis Rozenbergs, 04.2016

    Script allows to hide custom field for all users except groups/roles defined below. 
    By default project admin and users mentioned in following field are allowed to see hidden field: customfield_10865 (Confirmed by)
  */

  //Sets field to hide
  var hidefield = "#customfield_12345-val";

  //Sets groups which ar allowed to see defined customfield
  var allowedgroups = ['jira-administrators'];

  //Sets projects where to hide customfield. If empty, all projects are selected.
  //example: var projects = ['TEST', 'TEST1'];
  var projects = ['TEST1', 'TEST2', 'TEST3'];

  //Sets issue type where to hide customfield. If empty, all issue types are selected.
  //example: var issuetype = ['19', '3'];
  var issuetype = ['1', '2', '3'];

  //Sets roles which ar allowed to see defined customfield
  var allowedroles = ['Developers', 'Users'];


  //Gets current project key
  issueKey = AJS.$("meta[name='ajs-issue-key']").attr("content")

  var project = getProjectKey(issueKey);

  var flag = 0;
  var flag1 = 0;

  //Check if issue is in defined project
  for (l = 0; l < projects.length; l++){
    if (project == projects[l]) { flag = 1; }
  }

  if (flag == 1) {
    
    var issuety = getIssueType(issueKey);
  
    //Check if issue is in defined issue type
    for (k = 0; k < issuetype.length; k++){
      if (issuety == issuetype[k]) { flag1 = 1; }
    }
    
    if (flag1 == 1) {

      var user = getCurrentUserName();
      var aggrName = getIssueAggr(issueKey);
      var aggrName1 = getIssueAggr1(issueKey);
      var flag2 = 0;
      var flag3 = 0;

      //Gets urls of allowed roles
      var ProjRoles = [];
      for (k = 0; k < allowedroles.length; k++){
        ProjRoles.push(getProjectRoles(project, allowedroles[k]));
      }

      //Gets allowed users
      var ProjectRoleUser = [];
      for (l = 0; l < ProjRoles.length; l++){
        ProjectRoleUser.push.apply(ProjectRoleUser,getProjectRoleUser(ProjRoles[l]));
      }

      var allowedobjects= [];
      allowedobjects.push.apply(allowedobjects, ProjectRoleUser);
      allowedobjects.push.apply(allowedobjects, aggrName);
      allowedobjects.push.apply(allowedobjects, aggrName1);

      //Checks if current user is in array
      for (i = 0; i < allowedobjects.length; i++){
        if (user == allowedobjects[i]) { flag2 = 1; }
      }

      //Checks if current user is in defined groups
      for (j = 0; j < allowedgroups.length; j++){
        if (isUserInGroup(user, allowedgroups[j])){ flag3 = 1; }
      }


      //Checks if all projects and issue types are allowed
      if (projects.length == 0) { flag = 1;}

      //Checks if all projects and issue types are allowed
      if (issuetype.length == 0) { flag1 = 1;}

      //Hides defined field
      if (flag2 == 0 && flag3 == 0 && flag == 1 && flag1 == 1) {
        (function($) {
            AJS.toInit(function(){
            AJS.$(hidefield).parent().hide();
            AJS.$(hidefield).parent().value = "";
            });

            JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
            AJS.$(hidefield).parent().hide();
            AJS.$(hidefield).parent().value = "";
            });
            })(AJS.$);
      }
    }
  }
    
  function getCurrentUserName()
  {
    var user;
     AJS.$.ajax({
      url: "/rest/gadget/1.0/currentUser",
      type: 'get',
      dataType: 'json',
      async: false,
      success: function(data) {
        user = data.username;
      } 
     });
     return user;
  }

  function getGroups(user)
  {
    var groups;
     AJS.$.ajax({
      url: "/rest/api/2/user?username="+user+"&expand=groups",
      type: 'get',
      dataType: 'json',
      async: false,
      success: function(data) {
        groups = data.groups.items;
      } 
     });
     return groups;
  }

  function isUserInGroup(user, group){
    var groups = getGroups(user);
    for (i = 0; i < groups.length; i++){
      if (groups[i].name == group){
        return true;
      }
    }
    return false;
  }

  function getProjectKey(issueKey)
  {
    var projKey;
     AJS.$.ajax({
      url: "/rest/api/2/issue/"+issueKey,
      type: 'get',
      dataType: 'json',
      async: false,
      success: function(data) {
        projKey = data.fields.project.key;
      } 
     });
     return projKey;
  }


  function getIssueAggr(issueKey)
  {
    var aggrName = [];
     AJS.$.ajax({
      url: "/rest/api/2/issue/"+issueKey,
      type: 'get',
      dataType: 'json',
      async: false,
      success: function(data) {
        if (data.fields.customfield_10865) {
          for (var i=0; i < data.fields.customfield_10865.length; i++){
            aggrName.push(data.fields.customfield_10865[i].name);
          }
        }
      } 
     });
     return aggrName;
  }

  function getIssueAggr1(issueKey)
  {
    var aggrName1 = [];
     AJS.$.ajax({
      url: "/rest/api/2/issue/"+issueKey,
      type: 'get',
      dataType: 'json',
      async: false,
      success: function(data) {
        if (data.fields.customfield_10864) {
          for (var i=0; i < data.fields.customfield_10864.length; i++){
            aggrName1.push(data.fields.customfield_10864[i].name);
          }
        }
      } 
     });
     return aggrName1;
  }

  function getIssueType(issueKey)
  {
    var issuety;
     AJS.$.ajax({
      url: "/rest/api/2/issue/"+issueKey,
      type: 'get',
      dataType: 'json',
      async: false,
      success: function(data) {
        issuety = data.fields.issuetype.id;
        
      }
     });
     return issuety;
  }

  function getProjectRoles(project, role)
  {
    var ProjRoles;
     AJS.$.ajax({
      url: "/rest/api/2/project/"+project,
      type: 'get',
      dataType: 'json',
      async: false,
      success: function(data) {
        ProjRoles = data.roles[role];
      } 
     });
     return ProjRoles;
  }

  function getProjectRoleUser(RoleUrl)
  {
    var ProjRolesUser = [];
     AJS.$.ajax({
      url: RoleUrl,
      type: 'get',
      dataType: 'json',
      async: false,
      success: function(data) {
        if (data.actors) {
          for (var i=0; i < data.actors.length; i++){
            ProjRolesUser.push(data.actors[i].name);
          }
        }
      } 
     });
     return ProjRolesUser;
  }

</script>