SA-cim_vladiator icon indicating copy to clipboard operation
SA-cim_vladiator copied to clipboard

Add simple build script

Open lowell80 opened this issue 4 years ago • 3 comments

  • Add build script that creates a new temporary folder and builds a .tgz file with the needed content and nothing else. This avoids 2 common pitfalls: (1) Github tarball downloads end with an app name SA-cim_vladiator-master, and (2) it avoids hidden files (.gitignore); both are rejected by AppInspect.
  • Add some simple command line steps for a typical git clone / build / splunk install app workflow
  • Updated .gitignore to block build related artifacts.

lowell80 avatar Apr 09 '20 01:04 lowell80

Hi @lowell80 Thank you for the contribution, instead of going this route, what are your thoughts to providing a snippet in utilizing Splunk native functionality for Splunk app packaging? I am referring to the ./splunk package app <name> functionality, see https://docs.splunk.com/Documentation/Splunk/latest/Admin/CLIadmincommands

Ie

splunk@ip-172-31-23-197:~$ /opt/splunk/bin/splunk package app SA-cim_vladiator
App 'SA-cim_vladiator' is packaged.
Package location: /opt/splunk/etc/system/static/app-packages/SA-cim_vladiator.spl
splunk@ip-172-31-23-197:~$

This has several advantages:

  • Works on windows
  • Less custom code to maintain
  • Will merge in /local/ changes
  • Creates a more traditional .spl file vs .tar.gz

Thoughts?

hire-vladimir avatar May 11 '20 14:05 hire-vladimir

I apologize for the delay. I missed the notification.

Doesn't splunk package only work for already installed apps? It seems like that leads to a kind of a chicken-and-egg problem. So you have to first install it without a package to make the package. Also, you'd have to parse the output for the Package location: string to find and copy the path. This also requires authenticating to a running Splunk instance. For an app developer that's not a big deal, but for someone who just wants to install the latest stable release that's a big pain.

I think it's also helpful to point out 2 different use cases for a build script: (1) Building an official release, and (2) making a convenient package command for end-users or app developers to use, if they chose.

I have a few Splunk apps/TAs like this, so what I typically do is setup a build or release script that gets kicked off automatically by Travis CI when a new git tag (release) is created. The CI tool then checks out the code, builds a clean tarball (with whatever prefered extension - .spl/tgz/...) to the GitHub releases page. This way users can directly download that package and install it without having to do anything with git or scripts. In cases where I self-host the app in GitHub, I just make the release page available. For apps I host on Splunkbase directly, I just download the tarball from github release page myself, and re-upload it to Splunkbase. Which is still quicker than me doing it myself, and it's guaranteed not to accidentally capture some local/private file I left laying in my git folder.

I'll also point out that if you have git installed on Windows, then you likely already have a Bash for Windows, which should work well enough for this shell script (though I haven't confirmed it myself recently.)

lowell80 avatar May 30 '20 01:05 lowell80

FYI, I found this script helpful. I couldn't get "splunk package" to work, although admittedly I didn't try super hard

elliotkendall avatar Jun 29 '21 16:06 elliotkendall