Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Jenkinsfile lint 

Miyata Jumpei (@miyajan)
Jul 07, 2017
10 Jenkins
⾃⼰紹介
• 宮⽥ 淳平 (@miyajan)
• Cybozu
• ⽣産性向上チーム(⼀⼈)
• 社内で12のJenkinsを管理してます
Declarative Pipeline 😆
pipeline {
agent any
stage("Test") {
steps {
echo "test"
}
}
}
よーし、試すぞー
Y^Y^Y^Y^Y
構⽂間違えた…
Jenkinsfile
•
• Groovy …
• push
Linter
• https://jenkins.io/doc/book/pipeline/
development/#linter
• SSH curl
# JENKINS_SSHD_PORT=[sshd port on master]
# JENKINS_HOSTNAME=[Jenkins master hostname]
$ ssh -p $JENKINS_SSHD_PORT $JENKIN...
# Assuming "anonymous read access" has been enabled on
your Jenkins instance.
# JENKINS_URL=[root URL of Jenkins master]
#...
(^o^)
jflint
• npm
• https://www.npmjs.com/package/jflint
• curl REST API
$ npm install jflint -g
Install
{
  "jenkinsUrl": “http://your-jenkins.example.com”
}
.jflintrc
$ jflint Jenkinsfile
Errors encountered validating Jenkinsfile:
WorkflowScript: 4: Undefined section "stage" @ line 4,
col...
•
• git pre-commit hook
• Declarative Pipeline linter
• jflint
Upcoming SlideShare
Loading in …5
×

Jenkinsfileのlintで救える命がある

2,149 views

Published on

https://www.meetup.com/ja-JP/Tokyo-Jenkins-Area-Meetup/events/240833004/
『第10回 Jenkins勉強会』の発表資料です。
Jenkinsfileのlintと自作npmパッケージ "jflint" について話しました。
https://www.npmjs.com/package/jflint

Published in: Technology
  • Be the first to comment

Jenkinsfileのlintで救える命がある

  1. 1. Jenkinsfile lint 
 Miyata Jumpei (@miyajan) Jul 07, 2017 10 Jenkins
  2. 2. ⾃⼰紹介 • 宮⽥ 淳平 (@miyajan) • Cybozu • ⽣産性向上チーム(⼀⼈) • 社内で12のJenkinsを管理してます
  3. 3. Declarative Pipeline 😆
  4. 4. pipeline { agent any stage("Test") { steps { echo "test" } } } よーし、試すぞー
  5. 5. Y^Y^Y^Y^Y
  6. 6. 構⽂間違えた…
  7. 7. Jenkinsfile • • Groovy … • push
  8. 8. Linter • https://jenkins.io/doc/book/pipeline/ development/#linter • SSH curl
  9. 9. # JENKINS_SSHD_PORT=[sshd port on master] # JENKINS_HOSTNAME=[Jenkins master hostname] $ ssh -p $JENKINS_SSHD_PORT $JENKINS_HOSTNAME declarative-linter < Jenkinsfile SSH
  10. 10. # Assuming "anonymous read access" has been enabled on your Jenkins instance. # JENKINS_URL=[root URL of Jenkins master] # JENKINS_CRUMB is needed if your Jenkins master has CRSF protection enabled as it should $ JENKINS_CRUMB=`curl "$JENKINS_URL/crumbIssuer/api/xml? xpath=concat(//crumbRequestField,":",//crumb)"` curl -X POST -H $JENKINS_CRUMB -F "jenkinsfile=<Jenkinsfile" $JENKINS_URL/pipeline-model- converter/validate curl
  11. 11. (^o^)
  12. 12. jflint • npm • https://www.npmjs.com/package/jflint • curl REST API
  13. 13. $ npm install jflint -g Install
  14. 14. {   "jenkinsUrl": “http://your-jenkins.example.com” } .jflintrc
  15. 15. $ jflint Jenkinsfile Errors encountered validating Jenkinsfile: WorkflowScript: 4: Undefined section "stage" @ line 4, column 5. stage("Test") { ^ WorkflowScript: 1: Missing required section "stages" @ line 1, column 1. pipeline { ^ Usage
  16. 16. • • git pre-commit hook
  17. 17. • Declarative Pipeline linter • jflint

×