Skip to content

Instantly share code, notes, and snippets.

@cccaternberg
Last active November 14, 2017 10:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cccaternberg/3984e4a3d1a84ec6faffbd728ce6c247 to your computer and use it in GitHub Desktop.
Save cccaternberg/3984e4a3d1a84ec6faffbd728ce6c247 to your computer and use it in GitHub Desktop.
Jenkins Days
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Hello from Build'
}
}
stage('Test') {
steps {
echo 'Testing Testing 123'
}
}
stage('Deploy') {
steps {
echo 'Deploy some things'
}
}
}
}
pipeline {
agent {
label 'docker'
}
stages {
stage('Build') {
steps {
echo 'Hello from Build'
}
}
stage('Test') {
steps {
echo 'Testing Testing 123'
}
}
stage('Deploy') {
steps {
echo 'Deploy some things'
}
}
}
}
pipeline {
agent {
label 'docker'
}
stages {
stage('Build') {
steps {
echo 'Hello from Build'
writeFile(file: 'config', text: 'version=1', encoding: 'UTF-8')
stash(name: 'pom-config', includes: 'config')
}
}
stage('Test') {
environment {
configValue = readFile(encoding: 'UTF-8', file: 'config')
}
steps {
echo 'Testing Testing 123'
unstash 'pom-config'
sh 'echo "$configValue"'
}
}
stage('Deploy') {
steps {
echo 'Deploy some things'
}
}
}
}
pipeline {
agent {
label 'docker'
}
parameters {
booleanParam(defaultValue: true, description: '', name: 'userFlag')
}
options {
buildDiscarder(logRotator(numToKeepStr:'1'))
}
stages {
stage('Build') {
steps {
echo 'Hello from Build'
writeFile(file: 'config', text: 'version=1', encoding: 'UTF-8')
stash(name: 'pom-config', includes: 'config')
}
}
stage('Test') {
environment {
configValue = readFile(encoding: 'UTF-8', file: 'config')
}
steps {
echo 'Testing Testing 123'
unstash 'pom-config'
sh 'echo "$configValue"'
}
}
stage('Deploy') {
steps {
echo 'Deploy some things'
input 'Do you want to deploy?'
echo 'deployed'
}
}
}
}
pipeline {
agent {
label 'docker'
}
stages {
stage ("start"){
steps {
sh "echo start"
}
}
stage("distribute") {
steps {
parallel (
"jdk-8" : {
node('maven-jdk-8') {
sleep 15
sh "mvn -version"
}
},
"docker" : {
node('docker') {
sleep 5
sh "docker version"
}
}
)
}
}
stage ("end"){
steps {
sh "echo end"
}
}
}
}
pipeline {
agent none
stages {
stage("Build") {
agent {
label 'docker'
}
steps {
echo "Building"
sh "echo 'testtext' > test.txt"
stash includes: 'test.txt', name: 'my-file'
}
}
stage("Checkpoint") {
agent none
steps {
checkpoint 'Completed Build'
}
}
stage("Deploy") {
agent {
label 'docker'
}
steps {
unstash 'my-file'
sh 'cat test.txt'
}
}
}
}
stage('build') {
echo 'hello from jenkins master'
node ("docker") {
sh 'echo hello from jenkins agent'
}
}
stage('test') {
echo 'test some things'
}
stage('deploy') {
echo 'deploy some things'
}
stage('build') {
node ("docker") {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/beedemo/mobile-deposit-api.git']]])
writeFile encoding: 'UTF-8', file: 'config', text:'version=1'
stash includes: 'pom.xml,config', name: 'pom-config'
}
}
stage('test'){
node ("maven-jdk-8") {
unstash 'pom-config'
configValue = readFile encoding: 'UTF-8', file: 'config'
echo configValue
}
}
stage('deploy') {
input message: 'Do you want to deploy?'
node {
echo 'deployed'
}
}
checkpoint 'testing-complete'
stage('approve') {
mail body: "Approval needed for '${env.JOB_NAME}' at '${env.BUILD_URL}'", subject: "${env.JOB_NAME} Approval", to: "ops@yourcompanyhere.com"
timeout(time: 7, unit: 'DAYS') {
input message: 'Do you want to deploy?', parameters:[string(defaultValue: '', description: 'Provide any comments regarding decision.', name: 'Comments')], submitter: 'admin'
}
}
stage ("maven-tool"){
node {
def mvnHome = tool 'M3'
sh "${mvnHome}/bin/mvn -version"
}
}
stage ("docker-inside"){
node ("docker") {
docker.image('maven:3.3.3-jdk-8').inside() {
sh 'mvn -version'
}
}
}
@vikpande
Copy link

good one. liked the workshop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment