Create Jira Issues From The Command Line

You can use the command line to create Jira tickets. In the below one-liner, we’re going to bring in some standard json and create a ticket. We’ll use curl and use -u to define a username and password, then -X to define a POST and –data to define the contents of the post, wrapped in the single quotes below. Then -H defines the content type as json and a URL to your Jira rest endpoint, “Issues” in the below code:

curl -D- -u krypted:MySuperSecretPassword -X POST --data '{"fields":{"project":{"key": “DOG”},”summary": “Make my feature better.”,”description": “Going to make everything better ever ever ever by doing things and by things I mean allll the things“,”customfield_001”:”Testing testing”,”issuetype": {"name": “Story”}{“time tracking”:{originalEstimate”: “2d 4h”}}}’ -H "Content-Type: application/json" https://krypted.atlassian.net/rest/api/2/issue/

You can swap out the json here with input to a script, or a file. That json can look prettier than it looks in the above single line:

{
 "fields":{
   "project":
   {
    "key": “DOG”
   },
   ”summary": “Make my feature better.”,
   ”description": “Going to make everything better ever ever ever by doing things and by things I mean allll the things“,
   ”customfield_001”:”Testing testing”,
   ”issuetype": {
    "name": “Story”
   }
   {
    “time tracking”:{
    originalEstimate”: “2d 4h”
   }
  }
}

As you can see, we’re creating an issue in the DOG project (which could also say CAT or whatever was generated when you created the project you’re putting this issue into). We’re then adding a “summary” and “description” as I don’t think you can really create one without that information. Then we’re adding information for a custom field our organization created and finally an estimate for how long the task should take, with those being very much optional.

So any other fields you have available can also be created as well, just add them to the correct part of the json with the correct label and inputs to accept.

Updated My Apple Admin Conferences Page

I’ve been keeping a list of Apple Admin conferences for a few years now. I probably should have versioned it and kept each iteration, but… no need to pollute the interwebs with more outdated stuffs than I already have. So here’s the link for the latest version, updated with all the event dates announced thus far: http://krypted.com/community/macadmin-conferences/

Hope to see you at some!

Define docstrings in Python

Bryson mentioned Docstrings in the latest episode of the MacAdmins Podcast. But how do you use them? Documentation strings (or docstrings for short) are an easy way to document Python objects (classes, functions, methods, and modules in-line with your code. Docstrings are created using three double-quotes in the first statement of the definition and are meant to describe in a human readable way what the object does.

Let’s look at an example for hello_krypted:

def hello_krypted():
"""This simply echos Hello Krypted.

But there's so much potential to do more!
"""

Docstrings can then be accessed using the __doc__ attribute on objects (e.g. via print):

>>> print hello_krypted.__doc__
This simply echos Hello Krypted.

But you can say hello in person!

For more on docstrings, check out the official docs at https://www.python.org/dev/peps/pep-0257/

20 Constants In Software Development

My latest Huffington Post article, called 20 Constants In Software Development is up. It starts out like this:

There are so many things I wish people had told me when I was in school, or earlier in my career. Things that aren’t variable between organizations you work with, or even teams you work in. So I thought I’d jot a few down of these for software development teams (if only to prove that no, despite what product managers say, you aren’t crazy). So here goes:

  1. A project will never have enough people to build all the features you want. Period.
  2. Less features means fewer defects.
  3. As a software project nears completion the amount of work remaining rises in proportion to how many hacks and shortcuts you took.
Read more…

Check Your Bash Scripts For Syntax

There’s a great site out there called spellcheck.net that will check your bash scripts to verify that they are syntactically correct and offer some tips on fixing issues you may encounter. In the example below, I single quoted at the end of a quoted string, and… error screen-shot-2016-12-14-at-9-44-00-am Hat tip to Daniel MacLaughlin for posting this site.

Configure Xcode Server On macOS Server 5.2

Apple developers in growing development teams invariably need a continuous integration system. This automates the build, analysis, and testing solution for software development using Xcode. macOS Server has an Xcode service, capable of integrating your developer account with git, providing many of the options required to build a continuous integration system. Before you configure the Xcode service that can take committed code and then test and build your software, you’ll need an Apple developer account. The Xcode service then links git to a developer account and runs automations, referred to as bots, in Xcode. Therefore, you’ll also need to have Xcode installed on the computer running the Xcode service. Bots are then managed and reported on using a web app that the Server app runs. Once the pre-requisites are met, open the Server app and click on the Xcode service. screen-shot-2016-09-25-at-11-50-35-pm Click on the Choose Xcode button. screen-shot-2016-09-25-at-11-50-54-pm When prompted, browse to the version of Xcode you have installed on the server. Screen Shot 2015-09-24 at 10.11.46 PM Configure the user account to use for the service. screen-shot-2016-09-25-at-11-52-00-pm The service will then require you to login. Do so when prompted. screen-shot-2016-09-25-at-11-53-30-pm This enables the user account, which you will then need to login as. screen-shot-2016-09-25-at-11-54-24-pm You’ll see a new user environment. Use fast user switching to then switch back to your other account. Xcode will require access to the Accessibility framework to run unit tests. Click on Request Access to provide the rights to Xcode to do so. Once access has been granted to Xcode, you’ll see the version indicated in the Build Using field. screen-shot-2016-09-25-at-11-59-59-pm Next, click on Add Team, in order to identify the correct team from your Apple Developer account that will have access to the Xcode service. screen-shot-2016-09-26-at-12-00-28-am When prompted, select the team from your Apple Developer account that you wish to provide access to the server, note that you need to be a team agent or an administrator of the developer organization. screen-shot-2016-09-26-at-12-02-15-am Click on the Repositories tab. Here, you will define repositories for your Xcode projects. Click on the Repository Access button to define what protocols git should be accessible via. screen-shot-2016-09-26-at-12-02-45-am At the Repository Access screen, select HTTPS or SSH. Click OK. screen-shot-2016-09-26-at-12-04-11-am Click the Edit Repository Creators button. At the Repository Access screen, add any groups of users that should have access to create new git repositories. Once all of the appropriate users or groups have been added, click on OK. screen-shot-2016-09-26-at-12-04-30-am   Select your repository again, and click on the HTTPS Access button to provide access via HTTPS. Once saved, double-click on the repository again to see the uri for each type of access. And that’s it. screen-shot-2016-09-26-at-12-05-21-am Next, you’ll want to add a repository to the Xcode app. To do so, open Xcode and then use the Source Control menu to select Check Out. From there, you’ll get a Check Out screen. Screen Shot 2015-09-25 at 7.04.42 PM At the Check Out screen, enter the uniform the repository screen, shown in the previous step of this article and click on the Next button. Next, you’ll need to create bots to automate your build process.

opendiff

There is a little tool in OS X called opendiff. This command can be used to bring up a quick and dirty graphical view of changes in a file. For example, if you run opendiff followed by two file names, you’ll see what’s different in the two files and what’s the same: opendiff test test1 The result then looks as follows. Screen Shot 2016-08-26 at 1.03.16 PM Note that in the above screenshot, a and b are in white lines and the others are grey, as those are consistent in the two files and the c has been removed and replaced with the four lines on the left. In larger files, this is pretty useful as it provides quick insight into what is different between two files, like what changed in a script between two different versions.

Scripting Around Dropping Network Connections In OS X

Dropping network connections can be incredibly frustrating. And finding the source can be a challenge. Over the years, I’ve found a number of troubleshooting methods, but the intermittent drop can be the worse to troubleshoot around. When this happens, I’ve occasionally resorted to scripting around failures, and dumping information into a log file to find the issue. For example, you may find that when a network connection fails, you have a very strong signal somewhere, or that you have a very weak signal on all networks. I’ve found there are three pretty simple commands to test joining/unjoining, and using networks (beyond the standard pings or port scans on hosts). The first is the airport command, along with –disassociate. This just unjoins all networks: sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport --disassociate The second is a quick scan. Here, I’ve grep’d out the network I’m after (aka SSIDofNetwork – a very likely wireless network name), but when looking for environmental issues, you might choose to parse this into a csv and output all networks: sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -s | grep SSIDofNetwork Finally, you can join a network. You might have to escape out special characters in a password and it’s never wise to put a password into a script, etc. But, quick and dirty, this will join that SSIDofNetwork network: sudo networksetup -setairportnetwork en0 "SSIDofNetwork" mysecretpassword Anyway, loop it, invoke it however you invoke it, etc. Hope this helps someone, and if you have other tricks you’ve found helpful, feel free to throw them in the ‘ole comments!
How Users Feel About Intermittent Networking Issues