├── .gitignore ├── Readme.md ├── src └── main │ └── java │ └── io │ └── jenkins │ └── plugins │ └── pipeline │ └── Main.java ├── pom.xml └── pipelines ├── multibranch └── Jenkinsfile.yaml └── Jenkinsfile.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | target 3 | *.iml -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | Tutorial Repository 2 | =================== 3 | This repository is created for demonstrating tutorials on Pipeline as Yaml Jenkins Meetup. 4 | 5 | https://www.meetup.com/Jenkins-online-meetup/events/271691294/ -------------------------------------------------------------------------------- /src/main/java/io/jenkins/plugins/pipeline/Main.java: -------------------------------------------------------------------------------- 1 | package io.jenkins.plugins.pipeline; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println("Hello World"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | io.jenkins.plugins 8 | pipeline-as-yaml-tutorial 9 | 1.0-SNAPSHOT 10 | 11 | 12 | -------------------------------------------------------------------------------- /pipelines/multibranch/Jenkinsfile.yaml: -------------------------------------------------------------------------------- 1 | pipeline: 2 | environment: 3 | options: 4 | - disableConcurrentBuilds() 5 | agent: 6 | any: 7 | tools: 8 | maven: default 9 | stages: 10 | - stage: Maven 11 | stages: 12 | - stage: Build 13 | steps: 14 | - sh 'mvn clean compile' 15 | - stage: Test 16 | steps: 17 | script: 18 | - sh "mvn clean test" 19 | - stage: Install 20 | steps: 21 | script: 22 | - withCredentials: "[usernamePassword(credentialsId: 'mycustom-credentials', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]" 23 | script: 24 | - sh "mvn clean install -DskipTest -Dusername=${USERNAME} -Dpassword=${PASSWORD}" 25 | - withEnv: "['API_URL=https://api.ipify.org?format=json']" 26 | script: 27 | - sh "curl ${API_URL}" 28 | - stage: Deploy 29 | when: 30 | - branch 'master' 31 | steps: 32 | script: 33 | - sh 'mkdir deployment' 34 | - dir: "'deployment'" 35 | script: 36 | - sh "cp ../target/*.jar ." 37 | 38 | post: 39 | always: 40 | - cleanWs() -------------------------------------------------------------------------------- /pipelines/Jenkinsfile.yaml: -------------------------------------------------------------------------------- 1 | pipeline: 2 | environment: 3 | parameters: 4 | - "string defaultValue: '3', description: '', name: 'USERS', trim: false" 5 | options: 6 | - disableConcurrentBuilds() 7 | agent: 8 | any: 9 | tools: 10 | maven: default 11 | stages: 12 | - stage: Checkout 13 | steps: 14 | - git 'https://github.com/aytuncbeken/pipeline-as-yaml-tutorials.git' 15 | - stage: Maven 16 | stages: 17 | - stage: Build 18 | steps: 19 | - sh 'mvn clean compile' 20 | - stage: Test 21 | steps: 22 | script: 23 | - sh "mvn clean test -Dusers=${USERS}" 24 | - stage: Install 25 | steps: 26 | script: 27 | - withCredentials: "[usernamePassword(credentialsId: 'mycustom-credentials', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]" 28 | script: 29 | - sh "mvn clean install -DskipTest -Dusername=${USERNAME} -Dpassword=${PASSWORD}" 30 | - withEnv: "['API_URL=https://api.ipify.org?format=json']" 31 | script: 32 | - sh "curl ${API_URL}" 33 | - stage: Deploy 34 | when: 35 | - branch 'master' 36 | steps: 37 | script: 38 | - sh "echo ${deploy}" 39 | - sh 'mkdir deployment' 40 | - dir: "'deployment'" 41 | script: 42 | - sh "cp ../target/*.jar ." 43 | - stage: Smoke Test 44 | parallel: 45 | - stage: Check Main Page 46 | steps: 47 | - sh "curl https://api.ipify.org?format=json" 48 | - stage: Check Other Page 49 | steps: 50 | - sh "curl https://api.ipify.org?format=json" 51 | post: 52 | always: 53 | - cleanWs() --------------------------------------------------------------------------------