How to run multi stages at the same time using multi parallel blocks?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Here, I need to execute both Parallel test 1
and Parallel test 2
at the same time.
When I tried to put a parallel block on top of these, it throws an error since it mentioned like this in the official site Note: that a stage must have one and only one of steps, stages, or parallel
.
pipeline {
agent any
stages {
stage('Parallel Test 1') {
parallel {
stage('Block 1 - Stage 1') {
steps {
echo "Block 1 - Stage 1"
build(job: 'jenkins_job_1')
}
}
stage('Block 1 - Stage 2') {
steps {
echo "Block 1 - Stage 2"
build(job: 'jenkins_job_2')
}
}
}
}
stage('Parallel Test 2') {
parallel {
stage('Block 2 - Stage 1') {
steps {
echo "Block 2 - Stage 1"
build(job: "jenkins_job_3")
}
}
stage('Block 2 - Stage 2') {
steps {
echo "Block 2 - Stage 2"
build(job: "jenkins_job_4")
}
}
}
}
}
}
jenkins jenkins-plugins jenkins-pipeline devops
add a comment |
Here, I need to execute both Parallel test 1
and Parallel test 2
at the same time.
When I tried to put a parallel block on top of these, it throws an error since it mentioned like this in the official site Note: that a stage must have one and only one of steps, stages, or parallel
.
pipeline {
agent any
stages {
stage('Parallel Test 1') {
parallel {
stage('Block 1 - Stage 1') {
steps {
echo "Block 1 - Stage 1"
build(job: 'jenkins_job_1')
}
}
stage('Block 1 - Stage 2') {
steps {
echo "Block 1 - Stage 2"
build(job: 'jenkins_job_2')
}
}
}
}
stage('Parallel Test 2') {
parallel {
stage('Block 2 - Stage 1') {
steps {
echo "Block 2 - Stage 1"
build(job: "jenkins_job_3")
}
}
stage('Block 2 - Stage 2') {
steps {
echo "Block 2 - Stage 2"
build(job: "jenkins_job_4")
}
}
}
}
}
}
jenkins jenkins-plugins jenkins-pipeline devops
@RaoslawSzamszur any help on this please
– Prashanth Sams
Nov 24 '18 at 12:47
add a comment |
Here, I need to execute both Parallel test 1
and Parallel test 2
at the same time.
When I tried to put a parallel block on top of these, it throws an error since it mentioned like this in the official site Note: that a stage must have one and only one of steps, stages, or parallel
.
pipeline {
agent any
stages {
stage('Parallel Test 1') {
parallel {
stage('Block 1 - Stage 1') {
steps {
echo "Block 1 - Stage 1"
build(job: 'jenkins_job_1')
}
}
stage('Block 1 - Stage 2') {
steps {
echo "Block 1 - Stage 2"
build(job: 'jenkins_job_2')
}
}
}
}
stage('Parallel Test 2') {
parallel {
stage('Block 2 - Stage 1') {
steps {
echo "Block 2 - Stage 1"
build(job: "jenkins_job_3")
}
}
stage('Block 2 - Stage 2') {
steps {
echo "Block 2 - Stage 2"
build(job: "jenkins_job_4")
}
}
}
}
}
}
jenkins jenkins-plugins jenkins-pipeline devops
Here, I need to execute both Parallel test 1
and Parallel test 2
at the same time.
When I tried to put a parallel block on top of these, it throws an error since it mentioned like this in the official site Note: that a stage must have one and only one of steps, stages, or parallel
.
pipeline {
agent any
stages {
stage('Parallel Test 1') {
parallel {
stage('Block 1 - Stage 1') {
steps {
echo "Block 1 - Stage 1"
build(job: 'jenkins_job_1')
}
}
stage('Block 1 - Stage 2') {
steps {
echo "Block 1 - Stage 2"
build(job: 'jenkins_job_2')
}
}
}
}
stage('Parallel Test 2') {
parallel {
stage('Block 2 - Stage 1') {
steps {
echo "Block 2 - Stage 1"
build(job: "jenkins_job_3")
}
}
stage('Block 2 - Stage 2') {
steps {
echo "Block 2 - Stage 2"
build(job: "jenkins_job_4")
}
}
}
}
}
}
jenkins jenkins-plugins jenkins-pipeline devops
jenkins jenkins-plugins jenkins-pipeline devops
edited Nov 24 '18 at 14:43
Prashanth Sams
asked Nov 24 '18 at 12:37
Prashanth SamsPrashanth Sams
7,199105176
7,199105176
@RaoslawSzamszur any help on this please
– Prashanth Sams
Nov 24 '18 at 12:47
add a comment |
@RaoslawSzamszur any help on this please
– Prashanth Sams
Nov 24 '18 at 12:47
@RaoslawSzamszur any help on this please
– Prashanth Sams
Nov 24 '18 at 12:47
@RaoslawSzamszur any help on this please
– Prashanth Sams
Nov 24 '18 at 12:47
add a comment |
1 Answer
1
active
oldest
votes
You don't have to put each call to a parallel-job inside a stage, so you can do it as such:
pipeline {
agent any
stages {
stage('single run') {
parallel {
stage('Parallel Test 1') {
steps {
script {
def group1 = [:]
group1["test_1"] = {
echo "test_1"
sh(script: "date -u")
build(job: 'jenkins_job_1')
}
group1["test_2"] = {
echo "test_2"
sh(script: "date -u")
build(job: 'jenkins_job_2')
}
parallel group1
}
}
}
stage('Parallel Test 2') {
steps {
script {
def group2 = [:]
group2["test_3"] = {
echo "test_3"
sh(script: "date -u")
build(job: 'jenkins_job_3')
}
group2["test_4"] = {
echo "test_4"
sh(script: "date -u")
build(job: 'jenkins_job_4')
}
parallel group2
}
}
}
}
}
}
}
It did work; but I made few changes in the script to make it perfect. Thank you :)
– Prashanth Sams
Nov 25 '18 at 4:26
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53458217%2fhow-to-run-multi-stages-at-the-same-time-using-multi-parallel-blocks%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You don't have to put each call to a parallel-job inside a stage, so you can do it as such:
pipeline {
agent any
stages {
stage('single run') {
parallel {
stage('Parallel Test 1') {
steps {
script {
def group1 = [:]
group1["test_1"] = {
echo "test_1"
sh(script: "date -u")
build(job: 'jenkins_job_1')
}
group1["test_2"] = {
echo "test_2"
sh(script: "date -u")
build(job: 'jenkins_job_2')
}
parallel group1
}
}
}
stage('Parallel Test 2') {
steps {
script {
def group2 = [:]
group2["test_3"] = {
echo "test_3"
sh(script: "date -u")
build(job: 'jenkins_job_3')
}
group2["test_4"] = {
echo "test_4"
sh(script: "date -u")
build(job: 'jenkins_job_4')
}
parallel group2
}
}
}
}
}
}
}
It did work; but I made few changes in the script to make it perfect. Thank you :)
– Prashanth Sams
Nov 25 '18 at 4:26
add a comment |
You don't have to put each call to a parallel-job inside a stage, so you can do it as such:
pipeline {
agent any
stages {
stage('single run') {
parallel {
stage('Parallel Test 1') {
steps {
script {
def group1 = [:]
group1["test_1"] = {
echo "test_1"
sh(script: "date -u")
build(job: 'jenkins_job_1')
}
group1["test_2"] = {
echo "test_2"
sh(script: "date -u")
build(job: 'jenkins_job_2')
}
parallel group1
}
}
}
stage('Parallel Test 2') {
steps {
script {
def group2 = [:]
group2["test_3"] = {
echo "test_3"
sh(script: "date -u")
build(job: 'jenkins_job_3')
}
group2["test_4"] = {
echo "test_4"
sh(script: "date -u")
build(job: 'jenkins_job_4')
}
parallel group2
}
}
}
}
}
}
}
It did work; but I made few changes in the script to make it perfect. Thank you :)
– Prashanth Sams
Nov 25 '18 at 4:26
add a comment |
You don't have to put each call to a parallel-job inside a stage, so you can do it as such:
pipeline {
agent any
stages {
stage('single run') {
parallel {
stage('Parallel Test 1') {
steps {
script {
def group1 = [:]
group1["test_1"] = {
echo "test_1"
sh(script: "date -u")
build(job: 'jenkins_job_1')
}
group1["test_2"] = {
echo "test_2"
sh(script: "date -u")
build(job: 'jenkins_job_2')
}
parallel group1
}
}
}
stage('Parallel Test 2') {
steps {
script {
def group2 = [:]
group2["test_3"] = {
echo "test_3"
sh(script: "date -u")
build(job: 'jenkins_job_3')
}
group2["test_4"] = {
echo "test_4"
sh(script: "date -u")
build(job: 'jenkins_job_4')
}
parallel group2
}
}
}
}
}
}
}
You don't have to put each call to a parallel-job inside a stage, so you can do it as such:
pipeline {
agent any
stages {
stage('single run') {
parallel {
stage('Parallel Test 1') {
steps {
script {
def group1 = [:]
group1["test_1"] = {
echo "test_1"
sh(script: "date -u")
build(job: 'jenkins_job_1')
}
group1["test_2"] = {
echo "test_2"
sh(script: "date -u")
build(job: 'jenkins_job_2')
}
parallel group1
}
}
}
stage('Parallel Test 2') {
steps {
script {
def group2 = [:]
group2["test_3"] = {
echo "test_3"
sh(script: "date -u")
build(job: 'jenkins_job_3')
}
group2["test_4"] = {
echo "test_4"
sh(script: "date -u")
build(job: 'jenkins_job_4')
}
parallel group2
}
}
}
}
}
}
}
edited Nov 25 '18 at 4:43
Prashanth Sams
7,199105176
7,199105176
answered Nov 24 '18 at 20:10
yorammiyorammi
3,3751625
3,3751625
It did work; but I made few changes in the script to make it perfect. Thank you :)
– Prashanth Sams
Nov 25 '18 at 4:26
add a comment |
It did work; but I made few changes in the script to make it perfect. Thank you :)
– Prashanth Sams
Nov 25 '18 at 4:26
It did work; but I made few changes in the script to make it perfect. Thank you :)
– Prashanth Sams
Nov 25 '18 at 4:26
It did work; but I made few changes in the script to make it perfect. Thank you :)
– Prashanth Sams
Nov 25 '18 at 4:26
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53458217%2fhow-to-run-multi-stages-at-the-same-time-using-multi-parallel-blocks%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@RaoslawSzamszur any help on this please
– Prashanth Sams
Nov 24 '18 at 12:47