I have a multibranchpipeline job but I don't want to run the code in the Jenkinsfile in the repo. Instead I want to run a short pipeline script defined in the dsl script. What I have in my mind looks like this
multibranchPipelineJob('my-multibranch-pipeline') {
displayName('My Multi-Branch Pipeline')
description('Multi-Branch Pipeline con Workflow Pipeline Project Factory')
branchSources {
git {
id('my-git-source')
remote('.git')
credentialsId('my-git-credentials')
includes('*')
}
}
factory {
pipelineFactory {
script("""
pipeline {
agent any
stages {
stage('Checkout') {
steps {
echo 'hello world'
}
}
}
}
""")
}
}
}
pipelineFactory don't exist, it's just to show you what i want to do. My question is, how can I actually implement this? I can also use scripts in my shared library if there is chance to do so.
I have a multibranchpipeline job but I don't want to run the code in the Jenkinsfile in the repo. Instead I want to run a short pipeline script defined in the dsl script. What I have in my mind looks like this
multibranchPipelineJob('my-multibranch-pipeline') {
displayName('My Multi-Branch Pipeline')
description('Multi-Branch Pipeline con Workflow Pipeline Project Factory')
branchSources {
git {
id('my-git-source')
remote('https://github/op/myrepo.git')
credentialsId('my-git-credentials')
includes('*')
}
}
factory {
pipelineFactory {
script("""
pipeline {
agent any
stages {
stage('Checkout') {
steps {
echo 'hello world'
}
}
}
}
""")
}
}
}
pipelineFactory don't exist, it's just to show you what i want to do. My question is, how can I actually implement this? I can also use scripts in my shared library if there is chance to do so.
Share asked Mar 7 at 16:55 Simone GhellerSimone Gheller 231 silver badge4 bronze badges1 Answer
Reset to default 0As far as I remember, it's not possible with multibranch pipeline, as its idea is to take the Jenkinsfile from the repository (because it might differ between different branches). But it might be possible with pipelineJob
.
With multibranchPipelineJob
you can only set the path to the Jenkinsfile within your myrepo.git
repository like this (a full example could be found in Setting pipeline description in declarative Jenkinsfile):
// ...
factory {
workflowBranchProjectFactory {
scriptPath("path/to/Jenkinsfile")
}
}
// ...
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744917020a4600897.html
评论列表(0条)