miałem ten sam problem. Używam potoków. Rozwiązałem ten problem, implementując shared library.
Kod biblioteki to:
// vars/ciSkip.groovy
def call(Map args) {
if (args.action == 'check') {
return check()
}
if (args.action == 'postProcess') {
return postProcess()
}
error 'ciSkip has been called without valid arguments'
}
def check() {
env.CI_SKIP = "false"
result = sh (script: "git log -1 | grep '.*\\[ci skip\\].*'", returnStatus: true)
if (result == 0) {
env.CI_SKIP = "true"
error "'[ci skip]' found in git commit message. Aborting."
}
}
def postProcess() {
if (env.CI_SKIP == "true") {
currentBuild.result = 'NOT_BUILT'
}
}
Następnie w moim Jenkinsfile:
pipeline {
stages {
stage('prepare') { steps { ciSkip action: 'check' } }
// other stages here ...
}
post { always { ciSkip action: 'postProcess' } }
}
Jak widać, kompilacja oznaczona jako NOT_BUILT
. Możesz go zmienić na ABORTED
, ale nie można go ustawić na SUCCESS
, ponieważ a build result can only get worse
spróbuj sh "git log -1" i grep odpowiedni tekst. – Amityo
@Amityo: Dziękuję za pomoc. Potrzebuję jeszcze jednej kwerendy ... jak zapobiec jenkins budować w Jennfile, jeśli wiadomość zawiera zawartość [ci pominąć]? –