您好,登錄后才能下訂單哦!
一、下載docker鏡像
To use the latest LTS: docker pull jenkins/jenkins:lts
To use the latest weekly: docker pull jenkins/jenkins
二、運行docker鏡像
docker run -d -u 0 -p 8080:8080 -p 50000:50000 -v /data/jenkins_home:/var/jenkins_home jenkins/jenkins:lts
三、系統初始化密碼文件
/data/jenkins_home/secrets/initialAdminPassword
四、python jenkins
pip install python-jenkins
使用文檔:http://python-jenkins.readthedocs.io/en/latest/examples.html#example-1-get-version-of-jenkins
創建任務
import jenkins
server = jenkins.Jenkins('http://localhost:8080', username='admin', password='passwd')
job_xml = """<?xml version='1.0' encoding='UTF-8'?>
<flow-definition plugin='workflow-job@2.17'>
<actions/>
<description>pipeline測試</description>
<keepDependencies>false</keepDependencies>
<properties/>
<definition class='org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition' plugin='workflow-cps@2.45'>
<script>node {
stage('get clone'){
echo 'git clone ......'
}
stage('mvn test'){
echo 'mvn test ......'
}
stage('mvn build'){
echo 'mvn clean install ......'
}
stage('deploy'){
echo 'deploy ......'
}
}</script>
<sandbox>true</sandbox>
</definition>
<triggers/>
<disabled>false</disabled>
</flow-definition>"""
server.create_job('pipeline測試', job_xml)
五、xml轉yaml
pip install jenkins-job-wrecker
https://github.com/ktdreyer/jenkins-job-wrecker
jjwrecker -f path/to/my-job/config.xml -n 'my-job' 文件會生成到當前路徑的:"output"文件夾中
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。