Skip to content

Instantly share code, notes, and snippets.

pipeline {
agent any
stages {
stage('usernamePassword') {
steps {
script {
withCredentials([
usernamePassword(credentialsId: 'gitlab',
usernameVariable: 'username',
@baumato
baumato / Jenkinsfile
Created April 4, 2019 15:38
Jenkinsfile: Use environment to read credentials
pipeline {
environment {
ARTIFACTORY_TOKEN = credentials('Artifactory_Jenkins_Token')
}
//...
}
@baumato
baumato / Jenkinsfile
Created April 4, 2019 15:37
Jenkinsfile: Useful options
pipeline {
agent { label 'agent' }
options {
disableConcurrentBuilds()
skipStagesAfterUnstable()
timestamps()
buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '15'))
}
@baumato
baumato / Jenkinsfile
Created April 4, 2019 15:34
Jenkinsfile: Load groovy library
//In Jenkinsfile:
def gitlab() {
return load("jenkins/library/gitlab.groovy")
}
//In jenkinks/library/gitlab.groovy:
def veryGoodMethods() {
// ...
@baumato
baumato / EnvironmentalEntityManagerFactory.java
Last active December 21, 2020 09:47
When working with eclipseLink as JPA provider then the EnvironmentalEntityManagerFactory allows to use environment variables in the persistence.xml. This factory should be used instead of Persistence.createEntityManagerFactory.
package com.hlag.fis.test.persistence;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;