Chuan Chuan Law

DevOps | Software Automation | Continuous Integration | Continuous Delivery

How To Perform SonarQube Upgrade on Ubuntu

SonarQube is used as an integration with Jenkins to enable code quality analysis. Installation is pretty straightforward as discussed in the official documentation. In this blog, I would like to share  some “hipccups” that I encountered during server upgrade scenario. Setup PostgreSQL server This blog has pretty comprehensive notes on this 2. Backup the existing database using […]

Jenkins – Making Data Persistent In Docker Slave

As in Jenkins Docker Slave, every time a job runs, a new Docker container is started and terminated upon job completion. This will mean it will download all the dependencies every time. To avoid this, we will use the Volume function in Docker. As we are using the Docker Plugin, there is a field to […]

How To Set Up Jenkins 2.0 Master & Slaves On Docker

Jenkins 2.0 Master In Docker We can just use the Jenkins Docker official image, or you can just install Jenkins 2.0 normally.  Jenkins Slave In Docker Setup Install Docker Open up TCP port by adding the following in /etc/default/docker DOCKER_OPTS=”-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock” On Jenkins Master, install Docker Plugin on Master->Manage Jenkins->Manage Plugins On Master->Manage Jenkins->Cloud configure […]

Docker – Using Tiller To Overwrite Environment Specific Variables

To use Tiller, in Dockerfile, we specify: ADD deploy/tiller/*.yaml /etc/tiller/ ADD deploy/tiller/environments/dev /etc/tiller/environments/ ADD deploy/tiller/templates/* /etc/tiller/templates/ Tiller folder comprises of the following: environments This is where the yaml for environment specific variables are written: #These are the variables to overwrite service.conf.erb template service.conf.erb: target: /etc/appleapi/application.ini config: environment_name: “prod” #These are the variables to overwrite template.conf.erb template […]

Docker – How To Run A Debian Package In Docker

Below are the major steps on how to run a Debian package in Docker Dockerfile Download your Debian file # Download .deb fileRUN wget $debian_url \ && sudo dpkg -i appleapi.deb \ && apt-get install -f Using Ruby Tiller to overwrite environment specific configs (optional) #Tiller RUN sudo apt-get update && sudo apt-get -y install ruby RUN gem […]

Pact – Writing Consumer Test For OAuth2

OAuth2 uses Faraday to make HTTP requests. The Authorization in the Header is actually encoded using Base64. When we make requests using 3rd party tool such as Postman, this is not a issue. Therefore, your consumer test should look like this: apple_service.given(“the authnz provider is up”). upon_receiving(“a post token”). with(method: :post, path: ‘/token’, headers: {‘Content-Type’ […]

How To Setup Json Log in Logback

In pom.xml, add the dependency <dependency> <groupId>net.logstash.logback</groupId> <artifactId>logstash-logback-encoder</artifactId> <version>4.6</version> </dependency> 2. In logback.xml, add the LogstashEncoder appender  <appender name=”JSON” class=”ch.qos.logback.core.rolling.RollingFileAppender”> //This is the JSON formatter <encoder class=”net.logstash.logback.encoder.LogstashEncoder” /> //This is where the JSON log will be produced <file>${catalina.base}/logs/webapp.log.json</file> //On a daily basis, the JSON logged will be rolled over <rollingPolicy class=”ch.qos.logback.core.rolling.TimeBasedRollingPolicy”> <fileNamePattern>${catalina.base}/logs/webapp.log.json.%d{yyyy-MM-dd}</fileNamePattern> //We only store […]

Pact – How To Set Up Provider In Play Framework

In build.sbt, import the plugin import au.com.dius.pact.provider.sbt._ SbtProviderPlugin.config ++ Seq( providers := Seq( ProviderConfig(name = “Provider”, port=49600, requestFilter = Some(request => request.addHeader(“Authorization”, “Bearer NTY5YjQwNGQtYjFkMi00N2UyLThiODgtYzQzNzBkNzlkMDQ5”) )).hasPactWith(ConsumerConfig(name = “TestConsumer”, pactFile = file(“spec/pacts/test-consumer.json”))) ) ) 2. In a Makefile, have the following task: run-provider: make run-app & \ sleep 60 sbt pactVerify Where run-app is another Makefile task […]

Pact – Asserting The Function To Test from App Level

In your consumer test class, instead of calling the “subject.methodToTest()”, For example: describe MethodToTest{ before do         AppleServiceClient.base_uri ‘localhost:1234’     end   subject { AppleServiceClient.new }   describe “get_an_apple” do     before do         apple_service.given(“an apple exists”).         upon_receiving(“a request for an apple”).         with(method: […]

How To Setup Pact Broker

Setting up Dockerized Pact Broker The easiest and fastest way to do this is via Dockerized Pact Broker. By following Step 1 to Step 4 in this document, you will be able to have a Dockerized Pact Broker linking to a Dockerized PSQL in your localhost within minutes! All you then need is to publish the JSON […]

« Older posts

© 2017 Chuan Chuan Law

Theme by Anders NorenUp ↑