Wednesday, 17 February 2021

"Could not perform submodule update" after jenkins git update

 

This is the error I'm getting after updating the git version on my jenkins server:


 > git.exe config --get submodule.module.url # timeout=10
hudson.plugins.git.GitException: Command "git.exe config --get submodule.my-module.url" returned status code 1:
...
Caused: java.io.IOException: Could not perform submodule update
...
Finished: FAILURE



My solution was opening the .gitmodules file (a hidden file, found in the repo root) and adding "'.git" to the end of the url.

e.g.:
[submodule "my-module"]
path = my-module
url = git@bitbucket.org:name/my-module.git

Friday, 31 January 2020

pkgbuild basics - Creating a basic pkg installer on OSX


pkguild is a command-line tool used to create installers, there are easier tools for creating installers such as Packages which uses a graphical user interface.

The way pkgbuild works is that you create a folder structure that acts as the root directory of the target machine, then you move the files for the installer into this fake root folder with the desired folder structure. 
When you run the pkgbuild command you tell it what the root folder is and pkbuild essentially trims off that part of the file path to figure out where to install your files.
The result will be an installer (.pkg file) that will install your files and look something like this:
Image of an installer dialog for example project myapp

In this example I've created a directory called "instroot" in my documents. 
I want "myApp" to be installed at /Applications/myApp so I've copied it to the new folder:
~/Documents/instroot/Applications/MyApp

I also want some text files to be installed at /Library/Application Support/myApp so I've copied them into the new folder too:
~/Documents/instroot/Library/Application Support/myApp/myAppFile1.txt





once all the files for the installer are in the correct place, we just need to call this command:

pkgbuild --root --identifier --version packagename

root: the install root
identifier: an ID for your installer (used only by the operating system and can be anything you want but so try to make it meaningful and unique)
version: the version of your project
packagename: the name for the output installer, the name is also used in the installer dialog

for my example project the command is:

pkgbuild --root ~/Documents/instroot --identifier com.myapp.test --version 1.0 myapp.pkg


We can also use the pkgutil --payload-files command to list the installer files and sanity check the contents.

Now we have an installer called myapp.pkg! Double clicking it will start the installer.





Friday, 19 July 2019

Chuck DirectSound error fix


I'm learning dsp and following a tutorial that uses chuck, I install it, try it, and it falls over instantly with this error:

[chuck]: (DirectSound) error (Generic error) creating input buffer (Default Device)!



Solution:
  1. Go to Start Settings Privacy Settings → Microphone
  2. Turn on "Allow apps to access your microphone"
Now you'll never see this error again!

Microphone settings window shows "Allow apps to access your microphone" turned on.

Tuesday, 2 July 2019

Fix for Jenkins on Mac getting stuck on overnight builds




Every night my dutiful Jenkins build servers build their jobs and every morning I come in to find that a job on OSX has gotten stuck on 'git fetch' all night. The job's console output looks something like this:

[EnvInject] - Loading node environment variables.
Building in workspace /Users/me/Projects/MyProject
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Deferred wipeout is used...
[WS-CLEANUP] Done
using credential xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Cloning the remote Git repository
Cloning repository ssh://myname@website.org/repo.git
 > /usr/local/bin/git init /Users/me/Projects/MyProject# timeout=10
Fetching upstream changes from ssh://myname@website.org/repo.git
 > /usr/local/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials 
 > /usr/local/bin/git fetch --tags --progress ssh://myname@website.org/repo.git +refs/heads/*:refs/remotes/origin/*

Sometimes it starts again while you're looking at it, as if embarrassed to be caught slacking off all night.


Resolution:

This is because I turn off the display in the evening and the OSX build server server decides to go into sleep mode. Here's how to turn that feature off:


  1. Go the the Apple menu, select System Preferences then Energy Saver
  2. Check the box that says "Prevent computer from sleeping automatically when the display is off"

Monday, 20 May 2019

Building visual studio solutions on Jenkins


These are instructions on how to set up and use the MSBuild plugin for jenkins.

Adding MSBuild settings


  1. Go to the jenkins Global Tool Configuration and scroll to find the MSBuild section.
  2. Click "MSBuild Installations..." then "Add MSBuild", now you should see 3 fields to fill in.
  3. Name: Your identifier for these settings, this can be whatever you like but I suggest describing the settings e.g. "vs2019 Release settings"
  4. Path to MSBuild: The path to the Visual Studio compiler.
    Gotcha: In my experience to use the visual studio 2015 compiler I had to include the compiler in the path otherwise the plugin complains about not finding the compiler. Jenkins shows a warning when you do this but it works.
    • For Visual Studio 2015 use MSBuild 14 at:
      C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe
    • For Visual Studio 2017 use MSBuild 15 at:
      C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin
    • For Visual Studio 2019 use MSBuild 16 at:
      C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin
  5. Default parameters: Write here what parameters you wish to give the compiler.
    e.g.:
    -t:Clean,Build -p:Configuration="Release" -p:Platform="x64"
    MSBuild 16 uses hyphens for parameters but MSBuild 14 and 15 use a forward slash instead "/t:Clean,Build /p:Configuration="Release" /p:Platform="x64""
    If you're unsure open a command prompt and run MSBuild.exe --help or MSBuild.exe /help
  6. Click Save


Adding MSBuild to a job


  1. Go to the job configuration and scroll to find the Build section 
  2. Click Add build step and choose "Build a Visual Studio project or solution using MSBuild"
  3. In the MSBuild Version list select the setting you saved earlier.
  4. In the MSBuild Build File enter the path for the solution
    e.g. "
    $WORKSPACE\Builds\VisualStudio2019\MyProject.sln"
    (Conviently, you can use the jenkins environment variables here)
  5. Optional Additional parameters may be added to Command Line Arguments text box.
  6. Click Save



Monday, 18 February 2019

Script to remove all local git branches that have been merged


This is a bash script that removes all local git branches if:
- they have been merged
- they are not called develop
- they are not called master

It lists the branches and prompts me to confirm the list before the deleting starts.

deleting my local branches using the script

The script:

function remove_branches {
  echo "Removing all merged local branches!!!"
  for k in $(git branch --merged  | sed /\*/d); do 
    if [ -z $(echo $k | grep -i 'master\|develop') ]; then
      git branch -D $k
    fi
  done
exit
}


# Print branches to be deleted
for k in $(git branch --merged | sed /\*/d); do 
  if [ -z $(echo $k | grep -i 'master\|develop') ]; then
      echo $k
  fi
done


# Prompt user to delete branches
while true; do
read -p "Do you wish to remove these branches?" yn
case $yn in
[Yy]* ) remove_branches;;
[Nn]* ) echo "okay."; exit;;
* ) echo "Please answer yes or no."
esac
done

Friday, 1 February 2019

Bash command batch for renaming files without prefix


This line renames all files in a directory to remove the front of their names up to and including the first underscore character.
e.g.:
1242_file.txt
1209_another_file.txt
99_red balloons.wav

~becomes~

file.txt
another_file.txt
red balloons.wav


for i in *; do mv "$i" "`echo "$i" | sed 's/^[^_]*_//'`"; done

  Azure Trusted Signing Signtool Error SignTool Error: An unexpected internal error has occurred. Error information: "Error: SignerSign...