Mais conteúdo relacionado Semelhante a Jenkins 2.0 最新事情 〜Make Jenkins Great Again〜 (20) Mais de Jumpei Miyata (18) Jenkins 2.0 最新事情 〜Make Jenkins Great Again〜1. Jenkins 2.0
Make Jenkins Great Again!
Miyata Jumpei (@miyajan)
Mar 18, 2017
Productivity Engineering - Forkwell Meetup #4
2. ⾃⼰紹介
• 宮⽥ 淳平 (@miyajan)
• Cybozu
• ⽣産性向上チーム
• Jenkinsおじさん
10. $ docker run -p 8080:8080 jenkins:2.32.3
# http://localhost:8080
Try Jenkins 2.0
33. node(‘has-docker’) {
try {
checkout scm
stage(‘Build’) {
sh ‘mvn clean install’
}
stage(‘Archive’) {
( )
}
if (currentBuild.result == 'SUCCESS') {
mail to:"me@example.com", subject:"SUCCESS", body: "passed."
}
}
catch (exc) {
mail to:"me@example.com", subject:"FAILURE", body: "failed."
}
finally {
deleteDir()
}
}
35. pipeline {
agent label:’has-docker’, dockerfile: true
stages {
stage("Build") {
steps {
sh 'mvn clean install'
}
}
stage("Archive"){
( )
}
}
post {
always {
deleteDir()
}
success {
mail to:"me@example.com", subject:"SUCCESS", body: "passed."
}
failure {
mail to:"me@example.com", subject:"FAILURE", body: "failed."
}
}
}
36. Lint
•
• curl ssh lint
• https://github.com/jenkinsci/pipeline-model-
definition-plugin/wiki/Validating-(or-linting)-a-
Declarative-Jenkinsfile-from-the-command-line
• npm
• https://www.npmjs.com/package/jflint
38. Lint from CLI
• curl ssh lint
• https://github.com/jenkinsci/pipeline-model-
definition-plugin/wiki/Validating-(or-linting)-a-
Declarative-Jenkinsfile-from-the-command-line
• npm
• https://www.npmjs.com/package/jflint
41. Build in Container
// simple
agent {
docker “ubuntu:16.04”
}
// specify label & args
agent {
docker {
image “ubuntu:16.04”
label “docker-nodes”
args “-v /tmp:/tmp -p 8000:8000”
}
}
43. Credentials
environment {
// type: secret text
// SECRET_TEXT is defined
SECRET_TEXT = credentials(‘SECRET_TEXT')
// type: username and password
// SECRET_AUTH_USR and SECRET_AUTH_PSW are defined
SECRET_AUTH = credentials('SECRET_AUTH')
}
48. Stash
stage("Archive") {
agent {
docker “java:8”
}
steps {
sh “gradle jar”
stash name: “jar”, includes: “build/libs/*.jar”
}
}
stage(“Deployment”) {
agent {
docker …
}
steps {
unstash “jar”
// jar
}
}