2021's Plans, Jenkins plugin and Emacs
Welcome
How are you? I hope 2021 starts at least such good as for me. Even without the New Year Party.
Maybe you noticed that I deleted the cookbook
section, and it’s all about splitting topics. It’s
a tech blog, the rest of my hobbies need separated space. I hope you like this idea. After a few words
let’s begin.
2021 Plans
10 months of writing, 12 posts I can say that I really like this. Maybe it’s time-consuming and not such great as OpenSource contributions, but it’s on my own rules. I can write when I have time, I can write about everything still. No cookies, no Google Analyst, no opinion about my work here - from my perspective it’s a very comfortable situation.
So what’s the plan? I have two points here:
short TIL/oneliners
Sometimes I need to find some commands. Sometimes bash/zsh history is not enough. While Christmas break I played a bit with my RassberyPI. I need o update a lot of packages, also I forgot passwords, etc. My 3b spend in the drawer more than a year. I don’t use an external keyboard, my router is hard to reach, no screens with HDMI port. I need a headless setup. There are tons of tutorials, but I like my own way to achieve that. Too short for the regular article, but still worth saving. Check the below tutorial.
Download an img Raspberry Pi OS Lite
Insert SD card
Check disk name
lsblk
Unzip image and flash to SD card
cd ~/Downloads unzip 2020-12-02-raspios-buster-armhf-lite.zip
Flash SD card
sudo dd bs=4M if=2020-12-02-raspios-buster-armhf-lite.img of=/dev/mmcblk0 conv=fsync
Mount the boot partition
sudo mount -t vfat /dev/mmcblk0p1 /mnt/sd
Create files
sudo touch /mnt/sd/ssh sudo touch /mnt/sd/wpa_supplicant.conf
# /mnt/sd/wpa_supplicant.conf country=PL ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="Wifaldi" psk="Wimp-Slogan1-Buck7kin" }
Umonut disk
sudo umount /mnt/sd
ssh connection
- user: pi
- password: raspberry
ssh [email protected] ssh-copy-id -i ~/.ssh/id_rsa [email protected]
update packages and reboot
sudo apt-get update -y sudo apt-get upgrade -y sudo reboot
Start a video curses
It sounds great, but I suppose it’s not such easy. I like sharing my knowledge, maybe videos will be better that long step-by-step articles? The free course about Jenkins, a few words about Ansible, short Linux course. Also, that will be a great free teaching opportunity for me. But I will see, that’s just an idea now.
Jenkins plugins
As you know, or not Jenkins is one of the most popular build servers at this moment. In short, words are like Java. It’s quite old, heavy, not-pretty. A lot of people are thinking that is dead. That’s not true, a lot of people try to improve a lot of aspects of Jenkins. It’s faster, container-ready, popular, so developers, testers, and admins, have some a least minimal experience with Jenkins. However in my opinion the biggest advantage of Jenkins is flexibility. There are hundreds of plugins, for almost everything. You can do whatever you want in Jenkins, and mostly it’s possible. That is why a lot of companies use Jenkins even if there is a GitLab, GitHub Action, CircleCi/Travis. Flexibility and a great community, maybe that’s why Java still alive. As proof, I’m started writing my own plugin for Jenkins DSL.
Intro
I get a task. Get changed files between the revision of the current branch and process it. Nothing complex. Sure, but we some limitations.
currentBuild.changeSets
is what you’re looking for. Unless you trigger the same job from different branches. Then Jenkins sees only changes
between Jenkins jobs execution. So the easiest solution is shell execution of git diff
.
tmpFiles = sh(script: "git diff remotes/origin/${BRANCH}^ remotes/origin/${BRANCH} --name-only", returnStdout: true).trim().split('\n')
def changedFiles = []
tmpFiles.each {
changedFiles.add(it)
}
After that, you get a nice list of the changed file path in the workspace. Great. But what If you want to avoid imperative shell’s command.
Solution
Make your own Jenkins plugin. Where to start? Here. That’s a step-by-step Jenkins developer guide. tl;dr?
mvn -U archetype:generate -Dfilter="io.jenkins.archetypes:"
# Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 4
# Choose a number: 8: 8
# Define value for property 'artifactId': demo
# Define value for property 'version' 1.0-SNAPSHOT: : <just enter>
# Y: : y
mv demo demo-plugin
cd demo-plugin
mvn verify
mvn hpi:run
Now you have a working Jenkins instance in DEVELOPMENT mode. You can do everything, that you can do with Java.
Important tips?
If you want to add new button - check this file demo/src/main/resources/io/jenkins/plugins/sample/HelloWorldBuilder/config.jelly
You can check my plugin, it’s under development. It was a great experience to play with this system. Unfetrunetly I still need to learn a lot about that. I have no idea how to take my plugin object and use it in another plugin. I will continue this project in my free time.
Emacs
I started using Doom Emacs two months ago. Now I’m using it for almost everything. Emacs become my IDE, TODO list,
budget tracker, UML helper, and notes taker. Magit is so awesome, but Org-mode - Org-mode is a game-changer. So if you have some time,
I encourage you to take at least a try.
Also, this YouTube channel could be useful here: ->
System Crafters
UML Model with planuml-mode |
Emacs while writing this article |
Magit - best textbased git client ever |
Ladger mode - budget tracker |
Org mode - one to rule them all |