Skip to content

Instantly share code, notes, and snippets.

@Ijaz0059
Last active February 17, 2022 05:19
Show Gist options
  • Save Ijaz0059/47b0de2b90172396d99b11b6a37c6def to your computer and use it in GitHub Desktop.
Save Ijaz0059/47b0de2b90172396d99b11b6a37c6def to your computer and use it in GitHub Desktop.
reference: https://souravatta.medium.com/create-jenkins-seedjob-using-job-dsl-script-ac337afd9986
https://stackoverflow.com/questions/35898020/job-dsl-to-create-pipeline-type-job#:~:text=First%20you%20need%20to%20install,script%20and%20provide%20following%20script.&text=Or%20you%20can%20create%20your,located%20in%20remote%20git%20repository.
https://plugins.jenkins.io/job-dsl/
Install <"Job-DSL"> Plugin from Manage Plugin in Jenkins
-------------------------------------------------------------
create a Free-Style Job
=========================================================
Go to Configure -> Add Build Steps -> Process Job DSLs
Select <"Use provided DSL Script">
Insert the Script
==========================================================
pipelineJob("WTS") {
definition {
cps {
script('''
pipeline {
agent any
stages {
stage('Clone') {
steps {
git credentialsId: 'Github', url: 'https://github.com/Ijaz0059/welcometoskillrary.git'
}
}
stage('Build') {
steps {
sh "mvn clean install"
}
}
stage('Deploy') {
steps {
deploy adapters: [tomcat8(credentialsId: 'tomcat', path: '', url: 'http://18.207.223.128:8090/')],
contextPath: null, war: '**/*.war' ## installed tomcat in same server
}
}
}
}
'''.stripIndent())
sandbox()
}
}
}
===============================================================================
Apply-> Save -> Build Now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment