# disableRestartFromStage

**URL:** <https://community.jenkins.io/t/disablerestartfromstage/8826>\
**Category:** Using Jenkins\
**Tags:** question\
**Created:** [August 3, 2023, 9:05am UTC](https://community.jenkins.io/t/disablerestartfromstage/8826 "2023-08-03T09:05:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhinavgautam07](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/abhinavgautam07/32/5099_2.png) [@abhinavgautam07](https://community.jenkins.io/u/abhinavgautam07)\
**Post date:** [August 3, 2023, 9:05am UTC](https://community.jenkins.io/t/disablerestartfromstage/8826/1 "2023-08-03T09:05:43Z")

</div>

Jenkins setup:

## Jenkins: 2.361.4 OS: Linux - 5.4.241-150.347.amzn2.x86\_64 Java: 11.0.16.1 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)

ace-editor:1.1  
antisamy-markup-formatter:155.v795fb\_8702324  
apache-httpcomponents-client-4-api:4.5.14-150.v7a\_b\_9d17134a\_5  
authentication-tokens:1.4  
aws-credentials:191.vcb\_f183ce58b\_9  
aws-java-sdk-ec2:1.12.287-357.vf82d85a\_6eefd  
aws-java-sdk-minimal:1.12.287-357.vf82d85a\_6eefd  
blueocean:1.25.8  
blueocean-autofavorite:1.2.5  
blueocean-bitbucket-pipeline:1.27.3  
blueocean-commons:1.27.3  
blueocean-config:1.27.3  
blueocean-core-js:1.27.3  
blueocean-dashboard:1.27.3  
blueocean-display-url:2.4.1  
blueocean-events:1.27.3  
blueocean-git-pipeline:1.27.3  
blueocean-github-pipeline:1.27.3  
blueocean-i18n:1.27.3  
blueocean-jwt:1.27.3  
blueocean-personalization:1.27.3  
blueocean-pipeline-api-impl:1.27.3  
blueocean-pipeline-editor:1.27.3  
blueocean-pipeline-scm-api:1.27.3  
blueocean-rest:1.27.3  
blueocean-rest-impl:1.27.3  
blueocean-web:1.27.3  
bootstrap5-api:5.2.1-3  
bouncycastle-api:2.27  
branch-api:2.1071.v1a\_188a\_562481  
build-user-vars-plugin:1.9  
caffeine-api:2.9.3-65.v6a\_47d0f4d1fe  
checks-api:1.8.1  
cloudbees-bitbucket-branch-source:800.va\_b\_b\_9a\_a\_5035c1  
cloudbees-folder:6.758.vfd75d09eea\_a\_1  
command-launcher:1.2  
commons-httpclient3-api:3.1-3  
commons-lang3-api:3.12.0-36.vd97de6465d5b\_  
commons-text-api:1.10.0-36.vc008c8fcda\_7b\_  
configuration-as-code:1569.vb\_72405b\_80249  
credentials:1189.vf61b\_a\_5e2f62e  
credentials-binding:523.vd859a\_4b\_122e6  
cucumber-slack-notifier:0.10.0  
data-tables-api:1.12.1-4  
display-url-api:2.3.7  
durable-task:504.vb10d1ae5ba2f  
echarts-api:5.4.0-1  
extended-choice-parameter:359.v35dcfdd0c20d  
favorite:2.4.1  
font-awesome-api:6.2.1-1  
git:5.0.0  
git-client:4.2.0  
git-server:99.va\_0826a\_b\_cdfa\_d  
github:1.37.0  
github-api:1.303-417.ve35d9dd78549  
github-branch-source:1703.vd5a\_2b\_29c6cdc  
gitlab-plugin:1.7.8  
global-slack-notifier:1.5  
groovy:453.vcdb\_a\_c5c99890  
handy-uri-templates-2-api:2.1.8-22.v77d5b\_75e6953  
htmlpublisher:1.31  
instance-identity:142.v04572ca\_5b\_265  
ionicons-api:45.vf54fca\_5d2154  
jackson2-api:2.15.2-350.v0c2f3f8fc595  
jakarta-activation-api:2.0.1-3  
jakarta-mail-api:2.0.1-3  
javax-activation-api:1.2.0-6  
javax-mail-api:1.6.2-5  
jaxb:2.3.8-1  
jdk-tool:1.0  
jenkins-design-language:1.27.3  
jersey2-api:2.39.1-2  
jjwt-api:0.11.5-77.v646c772fddb\_0  
job-dsl:1.81  
jobConfigHistory:1176.v1b\_4290db\_41a\_5  
jquery3-api:3.6.1-2  
jsch:0.1.55.61.va\_e9ee26616e7  
junit:1189.v1b\_e593637fa\_e  
kubernetes:3900.va\_dce992317b\_4  
kubernetes-client-api:6.4.1-215.v2ed17097a\_8e9  
kubernetes-credentials:0.10.0  
ldap:659.v8ca\_b\_a\_fe79fa\_d  
lockable-resources:1106.vc9153f1a\_ff25  
mailer:448.v5b\_97805e3767  
matrix-auth:3.1.6  
matrix-project:785.v06b\_7f47b\_c631  
metrics:4.2.13-420.vea\_2f17932dd6  
mina-sshd-api-common:2.9.2-62.v199162f0a\_2f8  
mina-sshd-api-core:2.9.2-62.v199162f0a\_2f8  
momentjs:1.1.1  
okhttp-api:4.10.0-132.v7a\_7b\_91cef39c  
parameterized-scheduler:1.1  
pipeline-build-step:488.v8993df156e8d  
pipeline-graph-analysis:202.va\_d268e64deb\_3  
pipeline-groovy-lib:629.vb\_5627b\_ee2104  
pipeline-input-step:466.v6d0a\_5df34f81  
pipeline-milestone-step:111.v449306f708b\_7  
pipeline-model-api:2.2125.vddb\_a\_44a\_d605e  
pipeline-model-definition:2.2125.vddb\_a\_44a\_d605e  
pipeline-model-extensions:2.2125.vddb\_a\_44a\_d605e  
pipeline-rest-api:2.32  
pipeline-stage-step:305.ve96d0205c1c6  
pipeline-stage-tags-metadata:2.2125.vddb\_a\_44a\_d605e  
pipeline-stage-view:2.28  
plain-credentials:143.v1b\_df8b\_d3b\_e48  
plugin-util-api:2.20.0  
popper2-api:2.11.6-2  
prometheus:2.0.11  
pubsub-light:1.17  
rebuild:1.34  
remote-file:1.23  
scm-api:631.v9143df5b\_e4a\_a  
script-security:1229.v4880b\_b\_e905a\_6  
slack:631.v40deea\_40323b  
snakeyaml-api:1.33-95.va\_b\_a\_e3e47b\_fa\_4  
sse-gateway:1.26  
ssh-credentials:305.v8f4381501156  
sshd:3.275.v9e17c10f2571  
structs:324.va\_f5d6774f3a\_d  
token-macro:321.vd7cc1f2a\_52c8  
trilead-api:2.84.v72119de229b\_7  
uno-choice:2.6.4  
validating-string-parameter:2.8  
variant:59.vf075fe829ccb  
workflow-aggregator:590.v6a\_d052e5a\_a\_b\_5  
workflow-api:1208.v0cc7c6e0da\_9e  
workflow-basic-steps:1010.vf7a\_b\_98e847c1  
workflow-cps:3653.v07ea\_433c90b\_4  
workflow-cps-global-lib:609.vd95673f149b\_b  
workflow-durable-task-step:1241.v1a\_63e465f943  
workflow-job:1289.vd1c337fd5354  
workflow-multibranch:733.v109046189126  
workflow-scm-step:408.v7d5b\_135a\_b\_d49  
workflow-step-api:639.v6eca\_cd8c04a\_a\_  
workflow-support:839.v35e2736cfd5c

**ISSUE**  
I am not able to disable restart from stage using the option disableRestartFromStage

**Jenkinsfile**

```auto
pipeline {

  agent {
        kubernetes {
      yaml '''
            apiVersion: v1
            kind: Pod
            spec:
              serviceAccountName: jenkins-prod
              affinity:
                nodeAffinity:
                  requiredDuringSchedulingIgnoredDuringExecution:
                    nodeSelectorTerms:
                    - matchExpressions:
                      - key: nodetype
                        operator: In
                        values:
                        - jenkins
              containers:
              - name: jnlp
                resources:
                  requests:
                    cpu: "512m"
                    memory: "512Mi"
                    ephemeral-storage: "120Mi"
                  limits:
                    cpu: "512m"
                    memory: "512Mi"
                    ephemeral-storage: "240Mi"
              - name: node
                image: XXXXXXXXXX.dkr.ecr.ap-southeast-1.amazonaws.com/jenkins_base:single_image_v7
                command:
                - cat
                tty: true
                resources:
                  requests:
                    cpu: "3"
                    memory: "8Gi"
                    ephemeral-storage: "4Gi"
                  limits:
                    cpu: "3"
                    memory: "12Gi"
                    ephemeral-storage: "6Gi"
                volumeMounts:
                - name: shared-data
                  mountPath: /home/jenkins/urbanclap/workspace
              - name: "kaniko"
                image: "gcr.io/kaniko-project/executor:v1.7.0-debug"
                command:
                - /busybox/cat
                tty: true
                resources:
                  requests:
                    ephemeral-storage: "6Gi"
                  limits:
                    ephemeral-storage: "8Gi"
                volumeMounts:
                - name: shared-data
                  mountPath: /workspace
              restartPolicy: Never
              volumes:
                - name: shared-data
                  emptyDir: {}
        '''

    }
  }
  options {
    disableRestartFromStage()
  }

  stages {
      stage('Build') {
        steps {
          container('node'){
              withCredentials([[
                  $class: 'AmazonWebServicesCredentialsBinding',
                  credentialsId: "JenkinsAgent",
                  accessKeyVariable: 'AWS_ACCESS_KEY_ID',
                  secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
              ]]) {
              sh " \
                  sh $POS_BASE_PATH/scripts/deployment/cicd.sh ${env.JOB_NAME} \
                  sleep infinity \
              "
              }
          }
        }
      }

      stage('Build and Push Image') {
            steps {
              container('kaniko') {
                script {
                def image_tag = "master"
                 def dockerfileName = "${env.JOB_NAME}.dockerFile"

                  withCredentials([
                    [
                      $class: 'AmazonWebServicesCredentialsBinding',
                      credentialsId: "JenkinsAgent",
                      accessKeyVariable: 'AWS_ACCESS_KEY_ID',
                      secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
                    ]
                  ]) {
                    sh " \
                          /kaniko/executor --dockerfile=/workspace/${env.JOB_NAME}/${dockerfileName} \
                          --context=/workspace/${env.JOB_NAME}/ \
                          --destination=XXXXXXXXXX.dkr.ecr.ap-southeast-1.amazonaws.com/$DEV_ECR_REPO:${image_tag}-development-${env.BUILD_NUMBER} \
                          --destination=XXXXXXXXXX.dkr.ecr.ap-southeast-1.amazonaws.com/$STAGE_ECR_REPO:${image_tag}-staging-${env.BUILD_NUMBER} \
                          --destination=XXXXXXXXXX.dkr.ecr.ap-southeast-1.amazonaws.com/$PROD_ECR_REPO:${image_tag}-production-${env.BUILD_NUMBER} \
                          --cleanup \
                       "
                  }
                }
              }
            }
          }

    stage('Stage Environments') {
      parallel {
        stage('Development') {
          steps {
            script {
              def image_tag = "master-development-${env.BUILD_NUMBER}"
              container('node') {
                withCredentials([
                  [
                    $class: 'AmazonWebServicesCredentialsBinding',
                    credentialsId: "JenkinsAgent",
                    accessKeyVariable: 'AWS_ACCESS_KEY_ID',
                    secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
                  ]
                ]) {
                  sh " \
                          sh $POS_BASE_PATH/scripts/deployment/deploy-cicd.sh ${env.JOB_NAME} development ${image_tag} ${env.BUILD_URL} \
                      "
                }
              }
            }

          }
        }

        stage('Staging') {
          steps {
            script {
              def image_tag = "master-staging-${env.BUILD_NUMBER}"
              container('node') {
                withCredentials([
                  [
                    $class: 'AmazonWebServicesCredentialsBinding',
                    credentialsId: "JenkinsAgent",
                    accessKeyVariable: 'AWS_ACCESS_KEY_ID',
                    secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
                  ]
                ]) {
                  sh " \
                          sh $POS_BASE_PATH/scripts/deployment/deploy-cicd.sh ${env.JOB_NAME} staging ${image_tag} ${env.BUILD_URL} \
                      "
                }
              }
            }

          }
        }
      }
    }

    stage('Canary') {
      steps {
        container('node') {
          script {
            def image_tag = "master-production-${env.BUILD_NUMBER}"
            withCredentials([
              [
                $class: 'AmazonWebServicesCredentialsBinding',
                credentialsId: "JenkinsAgent",
                accessKeyVariable: 'AWS_ACCESS_KEY_ID',
                secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
              ]
            ]) {
              sh " \
                          sh $POS_BASE_PATH/scripts/deployment/deploy-cicd.sh ${env.JOB_NAME} production ${image_tag} ${env.BUILD_URL} \
                      "
            }
          }
        }

      }
    }

  }
  environment {
    POS_BASE_PATH = '/home/jenkins/urbanclap/platform-orchestration-service'
    DEV_ECR_REPO = 'mandalore-service'
    STAGE_ECR_REPO = 'mandalore-service-staging'
    PROD_ECR_REPO = 'mandalore-service-production'
  }
}

```
