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.

5
  • How would you identify debugging deployments?
    – Michael
    Commented Dec 22, 2018 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
    Commented Dec 22, 2018 at 17:15
  • I understand. How would the code know that you are doing a debug deployment? A parameter in Jenkins?
    – Michael
    Commented Dec 22, 2018 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
    Commented Dec 22, 2018 at 17:31
  • Possible duplicate of How run sbt assembly command without tests from command line?
    – Michael
    Commented Dec 22, 2018 at 17:34

1 Answer 1

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"
  }
}
2
  • hmm Doesn't seem to be skipping tests
    – Anthony
    Commented Dec 22, 2018 at 18:14
  • No, I tried locally too but it doesn't work. I think it has something to do with the sbt docker plugin.
    – Anthony
    Commented Dec 23, 2018 at 7:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.