drinkits

Autors: drinkits (1. lapa no 10)

Update Jira issues from MS Excel spreadsheet using Powershell script (updated: 13.05.2019.)

I have created Powershell script which allows to set values in Jira issues using data from MS Excel spreadsheet.

Script is based on following Powershell modules:

Usage:

  1. Set Jira server address in “update_issues.ps1” file.
  2. Update data in “data_for_issues.xlsx”
  3. Set custom field configuration according to your needs in “update_issues.ps1”
  4. Launch “update_issues.bat”, enter your Jira credentials and wait for script to complete.
  5. Log file is created next to “update_issues.ps1” file.

Download (updated: 13.05.2019.): update_issues_PS_script_V2.zip

update_issues.ps1 (updated: 13.05.2019.):

$ErrorActionPreference="SilentlyContinue"
Stop-Transcript | out-null
$ErrorActionPreference = "Continue"
Start-Transcript -path .\script\update_issues.log -append

Import-Module .\script\JiraPS
Import-Module .\script\PSExcel

####### Define some variables below ########

#Excel data file
$path = ".\data_for_issues.xlsx"

#Jira adresss
Set-JiraConfigServer -Server "https://jira-server.com"

############################################

$issues = new-object System.Collections.ArrayList

foreach ($field in (Import-XLSX -Path $path -RowStart 1))
 
{
    $issues.add($field) | out-null
}

$issuesfull = @()

foreach ($issue in $issues | Where { $_.key -and $_.key.Trim() })
{
    $i++
    $issuesfull += ($issue.key)
}

Write-Host "Pieteikumi: " $issuesfull  -ForegroundColor yellow
Write-Host "Dati tiks rakstīti" $i "pieteikumos. Tiklīdz ievadīsies lietotāja datus, tā sāksies datu rakstīšana." -ForegroundColor green
Write-Host "--------------------------------------" -ForegroundColor green

$cred = Get-Credential

foreach ($issue in $issues | Where { $_.key -and $_.key.Trim() })
{
    write-host "`n"
    $a++
    Write-Host "Izpildes statuss: " $a "/" $i -ForegroundColor gray
    Write-Host "Raksta datus pieteikumā: " $issue.key -ForegroundColor green
    Write-Host "Investīciju gads: " $issue.ig
    Write-Host "Projekta uzsākšanas gads: " $issue.pug
    Write-Host "Ranga datums: " $issue.rd.ToString('yyyy-MM-dd')
    Write-Host "Ranga vieta: " $issue.vr

## Custom field configuration

    $fields = @{
        customfield_11758 = @{
            value = [string]$issue.ig
        }
        customfield_12031 = @{
            value = [string]$issue.pug
        }
        customfield_24240 = $issue.rd.ToString('yyyy-MM-dd')
        customfield_24241 = [int]$issue.vr
    }

    Try
    {
        Set-JiraIssue -Issue $issue.key -Fields $fields -Credential $cred
        Write-Host "Dati ierakstīti pieteikumā: " $issue.key -ForegroundColor green
    }
    Catch
    {
        $ErrorMessage = $_.Exception.Message
        $FailedItem = $_.Exception.ItemName
        Write-Host "Error: $ErrorMessage" -ForegroundColor red
    }
    
}

Write-Host -NoNewLine "Datu rakstīšana pieteikumos beigusies. Nospiediet jebkuru taustiņu, lai izietu..." -ForegroundColor yellow
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
Stop-Transcript

Minibrūža projekts: katls

Turpinot minbrūža projektu ir kopā salikts arī katls. Tajā iemontēti 2x2kw teni, temperatūras sensors un krāns. Temperatūras noturēšanai katls apšūts ar siltumizolējošu materiālu. Tilpuma atzīmes iegravēju izmantojot šo metodi.

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

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
Olderposts

Copyright © 2019 drinkits

Izstrādājis Anders NorénUz augšu ↑