Created
April 6, 2017 05:25
-
-
Save jaohaohsuan/d3fa1c2a9b0ba3790baca62bd1a34ab7 to your computer and use it in GitHub Desktop.
jenkins pipeline pod & docker run hybrid
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
| podTemplate( | |
| label: 'stored2', | |
| containers: [ | |
| containerTemplate(name: 'jnlp', image: 'henryrao/jnlp-slave', args: '${computer.jnlpmac} ${computer.name}', alwaysPullImage: true), | |
| containerTemplate(name: 'elastic', image: 'docker.elastic.co/elasticsearch/elasticsearch:5.2.2', ttyEnabled: true, | |
| command: '/usr/share/elasticsearch/bin/elasticsearch -Ehttp.host=0.0.0.0 -Etransport.host=127.0.0.1 -Expack.security.enabled=false', | |
| envVars: [ | |
| containerEnvVar(key: 'ES_JAVA_OPTS', value: '-Des.cgroups.hierarchy.override=/') | |
| ]) | |
| ], | |
| volumes: [ | |
| hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock') | |
| ]) { | |
| node('stored2') { | |
| ansiColor('xterm') { | |
| stage('init env') { | |
| docker.image('docker.elastic.co/elasticsearch/elasticsearch:5.3.0') | |
| .inside('-e "xpack.security.enabled=false" -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1"') { | |
| parallel init: { | |
| sh 'su -m -c \'cd /usr/share/elasticsearch && bin/es-docker\' elasticsearch &' | |
| }, | |
| verify: { | |
| timeout(time: 30, unit: 'SECONDS') { | |
| waitUntil { | |
| def r = sh script: "curl -XGET http://localhost:9200?pretty", returnStatus: true | |
| return (r == 0) | |
| } | |
| } | |
| },failFast: true | |
| } | |
| } | |
| stage('inside pod') { | |
| timeout(time: 30, unit: 'SECONDS') { | |
| waitUntil { | |
| def r = sh script: "curl -XGET http://127.0.0.1:9200?pretty", returnStatus: true | |
| return (r == 0) | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
elasticsearch 5x 需要配置