1

My jenkinsfile looks like this:

 stage('Build Scala Code and Generate Dockerfile') {
   container('sbt') {
     sh "sbt -batch myapp/docker:stage"
   }
 }

For certain deployments [debugging] I would like to skip tests so that the build happens faster. Is there a way to do this in sbt? I am using the sbt docker plugin.

Anthony
  • 33,838
  • 42
  • 169
  • 278
  • How would you identify debugging deployments? – Michael Dec 22 '18 at 17:12
  • I need to deploy to server to do the debugging. I just need to skip the testing phase so the builds deploy faster – Anthony Dec 22 '18 at 17:15
  • I understand. How would the code know that you are doing a debug deployment? A parameter in Jenkins? – Michael Dec 22 '18 at 17:16
  • I am just looking to do this on one time basis. So I would just do it from `Replay` feature in Jenkins. I'm not looking to make this change for good or skip the tests based on a parameter. – Anthony Dec 22 '18 at 17:31
  • Possible duplicate of [How run sbt assembly command without tests from command line?](https://stackoverflow.com/questions/26499444/how-run-sbt-assembly-command-without-tests-from-command-line) – Michael Dec 22 '18 at 17:34

1 Answers1

0

If you are adding a boolean parameter DEBUG to tell Jenkins, that you are doing a debug deployment, you could change your stage like this:

stage('Build Scala Code and Generate Dockerfile') {
  container('sbt') {
    sh "sbt ${params.DEBUG ? 'set test in Test := {}' : ''} -batch myapp/docker:stage"
  }
}

Edit: since don't want a parameter, this might be better for you:

stage('Build Scala Code and Generate Dockerfile') {
  container('sbt') {
    sh "sbt 'set test in Test := {}' -batch myapp/docker:stage"
  }
}
Michael
  • 2,443
  • 1
  • 21
  • 21