Thursday, April 27, 2017

Death by Jenkins - Really difficult bits to find out about Declarative Pipeline DSL (Part 1)

I haven't written in a long while, but I've been working with Jenkins for the past 4 weeks (yes, I've been working for over 2 years now! no, I am not a build engineer), and I found it so excruciatingly painful to find answers about Jenkins Pipeline syntax on the Internet, that I thought I needed to update my blog and save others from a similar fate x)

Some context:

I've been working on converting our myriad of Jenkins jobs into the new Jenkins Pipeline job.
Jenkins Pipeline, if you don't already know what it is, is a new way of setting up CI. Every time you push code, it goes through different stages (Build, Unit Test, Integration Test, etc) so that by the end of the pipeline, if it all passes, you should be super confident about the code you committed, that it can be released automatically.


Commit => Build => Test => Deploy



It had been on my mind for a while that our Jenkins jobs were getting out of hand and we needed to migrate to using the DSL. Once you have two sets of 10 jobs, it starts to become unmanageable...

But wasn't sure if I should use a Pipeline or standard DSL linked to a job. In the end, I decided to go for the Pipeline because Jenkinsfile scanning using github enterprise and workspace management came with existing Pipeline plugins and it would tidy up all the jobs we had into one job per branch. I still don't know if this was the correct decision because I find that having only one job makes it more difficult to look through workspaces because the pipeline UI is a bit clunky.
Anyway, I'm rambling, let's get to the code.

The most annoying thing I could not find on the web was to re-assign/reset a global variable set in the environment block.


Here is a simple boolean environment variable:


Now I want to change this value when the Step succeeds within a try-catch block:


This doesn't even error but if I do an echo isSuccess before and after, I get false both times.

So after hours of Googling, I finally found out you need to override the environment variable. 
But how? 
The documentation merely says the below, and I couldn't find any examples anywhere!

So I after a few trial and error, I finally got it. The correct syntax is:
But this didn't work either. Now I was getting a type mismatch. Because when you defined isSuccess = false in the environment, it was kindly casting it to a string "false"!

Soooooo:


Finally, it was setting the correct value and now in my next stage, I could check if(isSuccess=="true")

Maybe you can properly define a boolean variable using: def  isSuccess = true

but I didn't have the patience to try this out so let me know if you try and it works!

After all of this, turns out I didn't want a try catch and so I didn't need to set a global variable but hey at least I know something now and I've shared it here so I hope this is helpful to someone out there, so my efforts weren't for nothing! 

Part 2 coming up with my finding about:
- loaded groovy script method cannot have the same name
- @NonCPS doesn't let you load scripts - problem with using .each

Monday, February 10, 2014

First SpriteKit Game

My first game using Sprite Kit!!
It's based on a tutorial by  Ray Wenderlich on http://www.raywenderlich.com/ 
Graphics were done by me on a simple paint tool so its not great haha but the concept is to shoot vegetables at kids who are running away! 
Still working on it to add levels and different vegetables as well as a boy character. 




Sunday, February 9, 2014

Get your code on!

So thursday evening, I went to an event, "Get your code on", organised by a group called Ladies who Code. It was at Mozilla office in London and they had a very nice office, despite the fact that it was a little small, but then again, it is in central london, in a very nice location so not surprised or complaining :)
There was a presentation by a Senior Engineer at Mozilla (http://soledadpenades.com) about an online gif chat website that she and her friend had created for fun and how it had suddenly become a success within a community and grown beyond their control thanks to many contributors adding to their open source website. (https://chat.meatspac.es)

Then we ordered some pizza started working on projects and getting to know other ladies ;)
I was fortunate to meet very nice people and had a lot of fun so I would definitely go to their event again!


And now I'm working on my own project to create games. I was talking to a couple of developers this weekend and they told me that C++ wasn't necessarily the language they used for games programming and certainly not the only language I should focus on. They told me to look at JS, ObjectiveC for mobile, if not Unity and C#.
So I just found a very nice tutorial for ObjectiveC iOS SpriteKit Tutorial so I wanted to share that with you :)
http://www.raywenderlich.com/42699/spritekit-tutorial-for-beginners
Thanks to the guy who wrote this tutorial, Ray Wenderlich, I am now going to modify it and try to make my own version :)

Have a nice sunday!

Monday, February 3, 2014

Finished our App!

So last week was our deadline for the HTML5 game app that my group and I were creating as our coursework.
I made a demo video so check it out ;)
I fear I sound like a bit of a bore but it took me all day to script what I was going to say in the video, practice the game so I don't get it wrong AND not stutter or say 'uhh'! haha


I made the video using audio and screen recording on Quicktime Player (Mac), then I put the audio and video together using iMovie.

The game is actually pretty fun! I'll let you know when it goes on the app stores!!

Now I'm focusing on applying for jobs, and my new second term modules.

In the end, I decided to take Software Engineering, Algorithmics, Functional Programming and Business Analytics.

Functional Programming is really fun. We are using a functional programming language called Miranda and I am loving it. Although, admittedly, it is getting more and more complex as the introductory weeks have gone by. But the way functional programming works is so cool! It's so logical it feels good! haha #supernerd

Business Analytics is less interesting for me because I feel that I know a lot about it already from my bachelor's degree. But the interesting thing about this course is that they teach you how to use the popular Statistical Analysis Software developed by SAS. People from SAS have come in to teach us and we've got a coursework to actually work on industry data.

I also just made my first six website to increase my online visibility and show that I am interested in game development.
Since when am I interested in games? Well, very recently. I've never been a big gamer but I am addicted to mobile games and so I went to this talk by a Games Industry Graduate Recruiter, Aardvark Swift at my university's career service event. It got me thinking how cool it would be if I could be a part of creating mobile games like Candy Crush and Plants vs Zombies!
So I spoke to the guy who gave the talk and I've been teaching myself C++ so I can develop games and build an online portfolio so games companies can see how I am interested.
I even entered a competition last week called Search for a Star, where I had to take an exam about C++. I doubt I got through to the next round because I just started learning C++ last monday, but it was really good experience and motivated me to crash learn C++.
Here are some websites I found really helpful:
https://www.wibit.net //The guys doing the videos are hilarious. Keeps you awake (y)
http://www.cplusplustutor.com
http://msdn.microsoft.com/en-us/library/ms228358(v=vs.90).aspx //For those who learnt Java first
http://pages.cs.wisc.edu/~hasti/cs368/JavaTutorial/NOTES/Java_vs.html#arrays //For those who learnt Java first
http://www.cplusplus.com/ //Ofcourse

Anyway, back to work! Hope you all had a nice weekend and have a nice week (y)

Monday, January 6, 2014

Happy New Year!!

Wishing everyone all the best in this coming year!
I, for one, need all the luck to graduate AND find employment that can get me a Tier 2 Work Visa to stay in the UK.

Why I want to work in the UK?
Well, it's true that I can speak Japanese and French as well, so I could go back to France or Japan to work without having to worry about a Visa.
But since my main language is English, I want to work in English.
I am most comfortable and at my best when working in English.

Which leaves me with England or the US.
I'd prefer to stay in the UK because it's much closer to my family and because I love Europe.

It's a funny story actually, because in my second year of university, there was a class about the EU and the professor asked the European students whether they felt European or French/Italian/etc.
Almost everyone answered that they did not feel European but of their own nationality. But I said that since I've grown up in France/England and go often to Italy, I felt European rather than Japanese! haha.

I think it'll be a busy year but I shall power through to get the job that I want!

Friday, December 13, 2013

HTML5 Local Storage Database - SOLVED!!

So as I was saying in my last post, I was stuck trying to figure out why my code to create a table in a html5 local storage database.
Well yesterday, I managed to work it out! It turns out it was pretty simple (of course, these things always turn out to be super simple and you feel stupid for being so stuck on it haha).
I based my code on this example I found here: http://www.redrobotzoo.com/posts/html5-local-storage-and-local-databases-tutorial/
I scoured google to find a straightforward example, which was so painful! Like this one, http://www.html5rocks.com/en/tutorials/webdatabase/todo/, is terrible. It says "Simple Todo List" so you think ooh yay! but gosh it was so difficult to understand what each part and variable was for!
And my biggest problem was that every time I copied the code and modified it to test it, the database would stop working.
Anyway, after hours of headache and re-starting, I managed to figure out what was what, thanks to redrobotzoo's detailed commenting and use of jquery for simplification.
But the problem I still had with redrobotzoo's code was that the database was being created but not the table. My code for "CREATE TABLE IF NOT EXISTS" wasn't creating a table!
Turns out, I just needed to put it all in one line where redrobotzoo concatenated the line for some reason.
eg:
This didn't work:
tx.executeSql('CREATE TABLE IF NOT EXISTS test ('
                           + 'personId INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,'
                           + 'personName VARCHAR(255),'
                           + ');',[],nullData,errorHandler);
But this did:
tx.executeSql('CREATE TABLE IF NOT EXISTS local_ranking(nameId INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,username VARCHAR(255))'
,[],nullData,errorHandler);

I am so happy now that it works! Now our app has a local ranking table :D

Wednesday, December 11, 2013

CS Unveiled Event and Testing on Android tablet

Monday was our department's event called CS Unveiled, where they explained to guests about the programs and facilities at our department.
My team and I were also there to present what our project was so far.
Here's a picture of us :)

As you can see, I am holding a tablet device..... with our app on it!!!!

Our professor gave each team an android tablet to carry our testing on different devices and so I used Phonegap, a great tool for porting web-based applications into different platforms including iOS, Android, Windows, Blackberry...

Phonegap Build is very efficient and easy to use. I just had to zip the folder containing all our html/javascript/css/image files and upload it onto Phonegap Build and it builds your app for different platforms xD

Here are some tips for the minor problems I encountered:
- don't use hydration for simple testing purposes (our app wouldn't load properly with hydration)
- make sure your index.html is in the main folder that you zip and not in a folder within that folder e.g. we had our index.html in a folder called html with all the other html files. It's better to have an index.html that links to a main.html in the html folder. (http://community.phonegap.com/nitobi/topics/app_dies_on_startup_connection_to_the_server_was_unsuccessful)

Now I'm working on creating a local storage database on html5 but it's really difficult... I don't know why but I keep getting an error that the database doesn't exist even though I have "CREATE TABLE IF NOT EXISTS" in my code! :(

Anyway, here are the more close up pictures of our app on the tablet :)



Hehe, it feels so precious when you've put in so much effort! My babyyyyyy haha Can't wait to see it completed :)