がありますgithubのプラグインとジェンキンスマルチブランチパイプラインと
properties([[$class: 'jenkins.model.BuildDiscarderProperty', strategy:
[$class: 'LogRotator', numToKeepStr: '50', artifactNumToKeepStr: '20']
]])
自身の使用の例:私Sonatypeネクサスで
#!groovy
node {
try {
properties([
[
$class: 'jenkins.model.BuildDiscarderProperty',
strategy: [
$class: 'LogRotator',
numToKeepStr: '10'
]
],
[
$class: 'GithubProjectProperty',
displayName: '',
projectUrlStr: 'https://github.com/xxxxxxx/xxxxx-xxxx/'
]
])
env.JAVA_HOME = tool 'JDK8'
def mvnHome = tool 'Maven'
stage 'Clean Workspace'
deleteDir()
stage 'Git Checkout Source'
checkout scm
stage 'Build Maven Module'
sh "${mvnHome}/bin/mvn clean install -DskipTests=true -DskipITs=true -U"
stage 'Unit Test Maven Module'
sh "${mvnHome}/bin/mvn test -DskipTests=false -DskipITs=true"
stage 'Integration Test Maven Module'
sh "${mvnHome}/bin/mvn verify -DskipTests=true -DskipITs=false"
stage 'Nexus Deploy Artifact'
sh "${mvnHome}/bin/mvn deploy:deploy -Pnexus-deploy"
stage 'Trigger Job xxxxxx-xxxxxx /master'
build job: 'xxxxxx-xxxxxx/master', propagate: false, wait: false
stage 'Send Success Email'
mail from: '[email protected]',
to: '[email protected]',
subject: "[JENKINS] ${env.JOB_NAME} - Build # ${env.BUILD_NUMBER} - [SUCCESS]!",
body: "${env.JOB_NAME} - Build # ${env.BUILD_NUMBER} - SUCCESS!"
}
catch (Exception ex) {
mail from: '[email protected]',
to: '[email protected]',
subject: "FAILURE - [JENKINS] ${env.JOB_NAME} - Build # ${env.BUILD_NUMBER} - [FAILURE]!",
body: "${env.JOB_NAME} - Build # ${env.BUILD_NUMBER} - FAILURE (${ex.message})!"
throw ex
}
}
、私はクリーンアップするタスクを作成しました人工物。
私は 'Artifactory'を使用していませんが、内部のタスクを作成してクリアできると思います。
は手動でも、あなたがこの例に従うことができ、Mavenの使用の場合には、削除することができます。
How do you deal with maven-3 timestamped snapshots efficiently?
私は、私はあなたを助け願っています。
'' 3,4 'が '' doNotDiscardBuilds:["3"、 "4"] 'の意味するところを尋ねるかもしれません。 – uncletall
これはJenkinsの#3と#4という番号のビルドは破棄されないことを意味します。これはmaxBuildsに追加されないので、maxBuildsを10に設定すると、ビルド#3、#4、および最新の8が保持されます。 – rasebo