Forked from Ijaz0059/JenkinsFile-Job DSL jenkins pipeline
Created
February 17, 2022 05:19
-
-
Save Kumar-Govind1998/d5f4408cdc2b79132a9043caac23c8f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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