Tag: Jenkins
http://{JENKNS_HOST}/safeRestart
This page simply catalogues the many clever variations of Jenkins created by members of the Jenkins community.
- 今後2年から3年は Java 8とJava 11 両方を主軸に開発する - コミュニティーとしてはJava 8と直ちに決別するような急激な変化は望んでいない
http://<jenkins host>/api/json
$ curl -X POST -u kyanny:xxxxxxxx http://jenkins.example.com/JOB_NAME/build
CSRF Protection If your Jenkins uses the "Prevent Cross Site Request Forgery exploits" security option (which it should), when you make a POST request, you have to send a CSRF protection token as an HTTP request header.
How do I enable CSRF protection? curl -u "admin:admin" 'http://localhost:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)'
Ruby Client libraries for communicating with Jenkins Remote Access API
$ java -jar jenkins.war --httpPort=9000 --ajp13Port=9001 --prefix=/jenkins
javaArgs="-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8"
細かいカスタマイズをする場合はシェルの方が扱いやすい
jenkins.xml の <arguments>...</arguments> の中の末尾に --sessionTimeout=1440 (1440 分) と追記して Jenkins サービスを再起動
<Location /jenkins> ProxyPass http://localhost:8080/jenkins ProxyPassReverse http://localhost:8080/jenkins </Location>
wget http://127.0.0.1/jenkins/job/ProjectFoo/build?token=xxxx
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "default-src 'self'; img-src 'self'; style-src 'self';") System.getProperty("hudson.model.DirectoryBrowserSupport.CSP") <string>-Dhudson.model.DirectoryBrowserSupport.CSP="default-src 'self'; img-src 'self'; style-src 'self';"</string>
「Test LDAP settings」ボタンをクリックすると、設定内容が正しいか確認することができる。画面キャプチャでは、uid=kazukiを使って接続テストした後の状態になっている。
This plugin provides yet another way of authenticating users using LDAP.
これはLDAP仕様の一部ではありません。これは、Jenkins LDAPプラグインによって提供される拡張機能
見つけたのが、Jenkins公式で開発されている warnings-ng-plugin 。 プラグインの ng はNext Generationなので、今後はこっちを開発していく方針っぽい。 このプラグインは、静的解析ツールが出した警告や問題を収集して視覚化してくれる。
MavenのProxy設定を記述するsettings.xmlのパス /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/"Jenkins上から入力したMaven名"/conf/settings.xml
src_path=/Users/foo/Sites dst_archive=Sites_$BUILD_ID.zip ditto -v -c -k --keepParent $src_path $dst_archive find . -type f -name "Sites_*" -mtime +8 -exec rm -f {} \;
src_path=/Users/foo/svn for svnrep in $src_path/* do if [ -f $svnrep/format ]; then svnadmin dump $svnrep | gzip > svn_${svnrep##*/}_$BUILD_ID.svn.gz else echo ' -Not svn repository: '$svnrep fi done find . -type f -name svn_*.svn.gz -mtime +7 -exec rm -f {} \;
# source folder path for backup src_path=/foo/data/trac rm -rf ./trac for tracrep in $src_path/* do if [ -f $tracrep/VERSION ]; then echo ' -Trac repository: '$tracrep /opt/local/bin/trac-admin-2.6 $tracrep hotcopy trac/${tracrep##*/} else echo ' -Not trac repository: '$tracrep fi done # archive zip -r trac_$BUILD_ID.zip trac # move the archives mv trac_*.zip /foo/backup/
PowerShellからリモートビルドを行うには,PowerShell3.0で導入されたInvoke-WebRequestコマンドレットを使うのが簡単です.
ここでは、JenkinsからPowerShellで複数のマシンをコントロールする際にハマりやすいところを中心にメモしておきます。
現状のJenkinsfileは2通り書き方があって、pipelineがルートになっている場合はDeclarative Pipelineという。この場合は、Groovyスクリプトを直接書くことができず、Groovyを書きたければscriptディレクティブを使う必要がある。この記事では主にこちらを扱う。
本記事は scripted pipeline の書き方です。
オプション-x:シェルスクリプト内で実際に実行されたコマンドを表示する オプション-e:0でない終了コードを返した時点でスクリプトがexitする
エラーが起きたらそこで中断されてステータスコードも非0が返却
logFilename=${JENKINS_HOME}/${JOB_URL:${#JENKINS_URL}} logFilename=${logFilename//job\//jobs\/}builds/${BUILD_NUMBER}/log grep "**Failure**" ${logFilename} ; exitCode=$? [[ $exitCode -ne 1 ]] && exit 1