Jenkins Pipeline高级用法-ShareLibrary
?
1.Github配置
1.1 上傳jenkinsfile到github
https://github.com/zeyangli/ShareLibrary-jenkins.git?
2.Jenkins配置
2.1 添加gitlab憑據(jù)
憑據(jù)管理-->憑據(jù)-->系統(tǒng) -->添加憑據(jù)
?
2.2 ShareLibrary配置
系統(tǒng)管理-->系統(tǒng)設置-->Global Pipeline librarys
2.3 安裝插件?
saltstack ansicolor?
?
3.發(fā)布配置
3.1 master安裝salt-master salt-api
yum -y install salt salt-master salt-apivim /etc/salt/master #添加以下內(nèi)容 salt 2015.5.10
rest_cherrypy:
port: 9000
disable_ssl: True
external_auth:
pam:
saltapi:
- .*
- '@wheel'
- '@runner
file_roots:
base:
- /srv/salt
?
service salt-master start?
service salt-apo start?
useradd saltapi
passwd saltapi? #123456
3.2 應用服務器部署salt-minion
yum -y install salt-minion echo "master: 10.10.1.1" > /etc/salt/minion3.2 測試
salt-key -L salt-key -a xxxxxxx salt xxx test.pingcurl http://127.0.0.1:9000/login -d username='saltapi' -d password='123456' -d eauth='pam'
{"return": [{"perms": [".*", "@wheel", "@runner"], "start": 1552134573.2227211, "token": "fa089bbd2c641a3136b2fb3bf305ab5111c54343", "expire": 1552177773.2227211, "user": "saltapi", "eauth": "pam"}]}[root@VM_7_14_centos auth]#
?
?
FAQ
1.[更新Git版本]centos6 默認yum裝的git 版本1.7.1 太低了導致出錯。
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker wget https://github.com/git/git/archive/v2.3.0.zip unzip v2.3.0.zip cd git-2.3.0 make prefix=/usr/local/git all vim /etc/profile export PATH=/usr/local/git/bin:$PATH source /etc/profile?
2.[重新安裝Git,項目構建出錯]
Started by user admin java.io.IOException: error=2, No such file or directoryat java.lang.UNIXProcess.forkAndExec(Native Method)at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)at java.lang.ProcessImpl.start(ProcessImpl.java:134)at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) Caused: java.io.IOException: Cannot run program "git" (in directory "/var/lib/jenkins/caches/git-c25d623df84deea801370f6c265e18c9"): error=2, No such file or directoryat java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)at hudson.Proc$LocalProc.<init>(Proc.java:249)at hudson.Proc$LocalProc.<init>(Proc.java:218)at hudson.Launcher$LocalLauncher.launch(Launcher.java:936)at hudson.Launcher$ProcStarter.start(Launcher.java:455)at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2038) Caused: hudson.plugins.git.GitException: Error performing command: git init /var/lib/jenkins/caches/git-c25d623df84deea801370f6c265e18c9at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2049)at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2010)at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2006)at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1638)at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:811) Caused: hudson.plugins.git.GitException: Could not init /var/lib/jenkins/caches/git-c25d623df84deea801370f6c265e18c9at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:813)at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.init(CliGitAPIImpl.java:286)at hudson.plugins.git.GitAPI.init(GitAPI.java:217)at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:324)at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:198)at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:174)at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:108)at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:67)at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:293)at hudson.model.ResourceController.execute(ResourceController.java:97)at hudson.model.Executor.run(Executor.java:429) Finished: FAILURE解決方法: 系統(tǒng)設置,全局工具設置,更改git的位置。
?
3.沒有安裝saltstack插件
java.lang.NoSuchMethodError: No such DSL method 'salt' found among steps?
轉載于:https://www.cnblogs.com/mascot1/p/10502768.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的Jenkins Pipeline高级用法-ShareLibrary的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Windows系统IntelliJ ID
- 下一篇: NumPy 数学函数