- add each job via scm to Jenkins (named as job1 and job2 -> job1.Jenkinsfile has 'job2' defined as jobname
- enable 'GitHub hook trigger for GITScm polling' on job1
- set pipeline repo of job1 to match only releases (= tags/*):
Pipeline.Definition.SCM.Git.Repositories.Refspec:'+refs/tags/v*':'refs/remotes/origin/tags/v*'
Pipeline.Definition.SCM.Git.BranchesToBuild.BranchSpecifier:**/tags/v**
Last active
January 12, 2021 10:57
-
-
Save fty4/1f3fa8cd5f3f54c131efb5abe297bfb0 to your computer and use it in GitHub Desktop.
Trigger other Jenkinsjob when new Tag available
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent any | |
stages { | |
stage('Beispiel') { | |
steps { | |
script { | |
GIT_TAG = sh ( | |
# will grep latest branch with versioning pattern (like v1.0, v22.44.66) | |
script: 'git tag --contains HEAD | egrep "v(\\d+\\.?){0,3}" | head -n1', | |
returnStdout: true | |
).trim() | |
} | |
} | |
} | |
} | |
post { | |
always { | |
build job: 'job2', | |
parameters: [[$class: 'StringParameterValue', name: 'passed_param', value: String.valueOf(GIT_TAG)]] | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent any | |
parameters{ | |
string( | |
name: 'passed_param', | |
defaultValue: 'TESTING', | |
description: 'The target environment', | |
) | |
} | |
stages { | |
stage('Example') { | |
steps { | |
echo params.passed_param | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment