Skip to content

Instantly share code, notes, and snippets.

@LenarBad
LenarBad / Jenkins build periodically examples.md
Last active June 1, 2018 19:22
Jenkins build periodically

Build every hour:
H * * * *

Build every 20 minutes:
H/20 * * * *

Build every 20 minutes 2am to 11pm:
H/20 5-23 * * *

Build every 20 minutes, work time/days (8am-6pm, MON-FRI) only:
H/20 8-18 * * 1-5

Build every hour MON-WED and FRI only:
H * * * 1-3,5

@LenarBad
LenarBad / Choose Source for Default Value.groovy
Last active May 18, 2018 14:15
Jenkins dynamic Extended Choice Parameter with service call (Groovy Script)
// host will be passed in the groovy bindings for extended choice plugin.
def getVersion = { host, path ->
try {
def version = new groovy.json.JsonSlurper().parse(new URL("https://${host}${path}")).version
return version
} catch(Exception e) {
return null
}
}
@LenarBad
LenarBad / JUnitWithSpringBootExampleIT.java
Last active May 14, 2018 20:31
Spring Boot + JUnit minimal required code
package io.lenar.examples.junitspringboot.tests;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@LenarBad
LenarBad / Spring Boot + TestNG - BaseIT.java
Last active May 7, 2018 22:19
BaseIT class for Spring Booot and TestNG tests
package io.lenar.examples.spring.start;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest(classes = TestNGWithSpringApplication.class)
public class BaseIT extends AbstractTestNGSpringContextTests {
// Common methods, variables and constants
String script = "arguments[0].innerHTML='" + StringEscapeUtils.escapeEcmaScript(innerHtml) + "'";
((JavascriptExecutor) driver).executeScript(script, webElement);
@LenarBad
LenarBad / Selenium WebDriver open local file.java
Created April 27, 2018 19:48
Selenium WebDriver - open a local html file. The file should be placed in the resources folder
String path = this.getClass().getResource("/my-local-form-page.html").getPath();
driver.get("file://" + path);
driver.findElement(By.id("button")).click();
@LenarBad
LenarBad / Exclude Tomcat from Spring Boot in Maven.xml
Created December 22, 2017 22:21
How to exclude Tomcat from Spring Boot in Maven
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
@LenarBad
LenarBad / Spring Boot + TestNG pom.xml
Last active April 10, 2018 15:12
Spring Boot + TestNG minimal Maven dependencies.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.lenar.examples.spring</groupId>
<artifactId>start</artifactId>
<version>1.0-SNAPSHOT</version>
@LenarBad
LenarBad / mount.sh
Created March 5, 2018 22:39
How to mount a VirtualBox shared folder
sudo mount -t vboxsf hostfolder guestFolder
@LenarBad
LenarBad / ServiceClientExampleIT
Last active March 2, 2018 22:03
Service Client - Usage in Tests
@SpringBootTest(classes = TestNGWithSpringApplication.class)
public class BookServiceClientExampleIT extends AbstractTestNGSpringContextTests {
@Autowired
BookServiceClient client;
@Test
public void createUpdateDeleteScenarioTest() throws IOException {
Book createdBook = client.createBook(new Book("Title", "Author")).dto();
String id = createdBook.getId();