Jenkins: Unterschied zwischen den Versionen
Aus Alexander's Wiki
Admin (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „== Pipeline == === Git-Checkout === === Post-Declaration === <syntaxhighlight lang="groovy"> post { always { echo "This block always…“) |
Admin (Diskussion | Beiträge) |
||
Zeile 1: | Zeile 1: | ||
== Pipeline == | == Pipeline == | ||
=== Script-Anfang === | |||
<syntaxhighlight lang="groovy"> | |||
#!groovy | |||
pipeline { | |||
agent { | |||
label 'ec2-fleet' | |||
} | |||
environment { | |||
AWS_CREDS = credentials('AWS Jenkins') | |||
EMAIL_TO = 'me@example.com' | |||
} | |||
options { | |||
buildDiscarder(logRotator(artifactNumToKeepStr: '10', numToKeepStr: '10')) | |||
} | |||
</syntaxhighlight> | |||
=== Git-Checkout === | === Git-Checkout === | ||
<syntaxhighlight lang="groovy"> | |||
stages { | |||
stage("GIT Checkout") { | |||
parallel { | |||
stage('Checkout for Multibranch Pipeline') { | |||
when { | |||
allOf { | |||
expression { env.repositoryNames == null } | |||
} | |||
} | |||
steps { | |||
checkout scm | |||
// is equivalent | |||
// checkout([ | |||
// $class : 'GitSCM', | |||
// branches : scm.branches, | |||
// doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations, | |||
// extensions : scm.extensions, | |||
// userRemoteConfigs : scm.userRemoteConfigs | |||
// ]) | |||
} | |||
} | |||
</syntaxhighlight> | |||
=== Post-Declaration === | === Post-Declaration === |
Aktuelle Version vom 30. September 2022, 11:00 Uhr
Pipeline
Script-Anfang
#!groovy
pipeline {
agent {
label 'ec2-fleet'
}
environment {
AWS_CREDS = credentials('AWS Jenkins')
EMAIL_TO = 'me@example.com'
}
options {
buildDiscarder(logRotator(artifactNumToKeepStr: '10', numToKeepStr: '10'))
}
Git-Checkout
stages {
stage("GIT Checkout") {
parallel {
stage('Checkout for Multibranch Pipeline') {
when {
allOf {
expression { env.repositoryNames == null }
}
}
steps {
checkout scm
// is equivalent
// checkout([
// $class : 'GitSCM',
// branches : scm.branches,
// doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
// extensions : scm.extensions,
// userRemoteConfigs : scm.userRemoteConfigs
// ])
}
}
Post-Declaration
post {
always {
echo "This block always runs."
}
changed {
echo "This block runs when the current status is different than the previous one."
}
fixed {
echo "This block runs when the current status is success and the previous one was failed or unstable."
}
regression {
echo "This block runs when the current status is anything except success but the previous one was successful."
}
unstable {
echo "This block runs if the current status is marked unstable."
}
aborted {
echo "This block runs when the build process is aborted."
}
failure {
echo "This block runs when the build is failed."
}
success {
echo "This block runs when the build is succeeded."
}
unsuccessful {
echo "This block runs when the current status is anything except success."
}
cleanup {
echo "This block always runs after other conditions are evaluated."
}
}