I want to execute multiple jobs from a single pipeline using declarative syntax in parallel. Can this be possible!! I know we can make a declarative parallel pipeline using "parallel" parameter.
pipeline {
agent any
parallel{
stages {
stage('Test1') {
steps {
sh 'pip install -r requirements.txt'
}
}
stage('Test2') {
steps {
echo 'Stage 2'
sh 'behave -f allure_behave.formatter:AllureFormatter -o allure-results features/scenarios/**/*.feature'
}
}
stage('Test3') {
steps {
script {
allure([
includeProperties: false,
jdk: '',
properties: [],
reportBuildPolicy: 'ALWAYS',
results: [[path: 'allure-results']]
])
}
}
}
}
}
}
Below image will show you the proper flow that I want. Any approach how to do it?
// Pipeline project: SO-69680107-1-parallel-downstream-jobs
pipeline {
agent any
stages {
stage('Clean Workspace') {
steps {
cleanWs()
}
}
stage('Parallel stage') {
parallel {
stage('Stage 2') {
steps {
build 'SO-69680107-2'
copyFiles( "$WORKSPACE\\..\\SO-69680107-2", "$WORKSPACE")
}
}
stage('Stage 3') {
steps {
build 'SO-69680107-3'
copyFiles( "$WORKSPACE\\..\\SO-69680107-3", "$WORKSPACE")
}
}
stage('Stage k') {
steps {
build 'SO-69680107-k'
copyFiles( "$WORKSPACE\\..\\SO-69680107-k", "$WORKSPACE")
}
}
} // parallel
}
}
}
def copyFiles( downstreamWkspc, upstreamWkspc ) {
dir("$downstreamWkspc") {
bat """
@set prompt=\$g\$s
dir
xcopy /f *.* \"$upstreamWkspc\\\"
dir \"$upstreamWkspc\"
"""
}
}
Template for downstream projects SO-69680107-2
, SO-69680107-3
, SO-69680107-k
:
// Pipeline project: SO-69680107-X
pipeline {
agent any
stages {
stage('Stage X') {
steps {
sh 'set +x; echo "Step X" | tee SO-69680107-X.log; date; sleep 3; date'
}
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.