-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding method for setitng build description and various detekt fixes (#…
…28) Co-authored-by: Caleb Reder <[email protected]>
- Loading branch information
Showing
6 changed files
with
99 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...c/main/kotlin/com/code42/jenkins/pipelinekt/internal/step/scripted/SetBuildDescription.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.code42.jenkins.pipelinekt.internal.step.scripted | ||
|
||
import com.code42.jenkins.pipelinekt.core.step.ScriptedStep | ||
import com.code42.jenkins.pipelinekt.core.step.SingletonStep | ||
import com.code42.jenkins.pipelinekt.core.writer.GroovyWriter | ||
|
||
/** | ||
* Set the description of a build. | ||
* | ||
* @param description The description of this build. | ||
*/ | ||
data class SetBuildDescription(val description: String) : ScriptedStep, SingletonStep { | ||
override fun scriptedGroovy(writer: GroovyWriter) { | ||
writer.writeln("currentBuild.description = \"${description}\"") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,20 +7,56 @@ import org.junit.Test | |
|
||
class MailTest : GroovyScriptTest() { | ||
@Test fun empty_email() { | ||
val expected = "mail to: '', subject: '', body: '', from: '', cc: '', bcc: '', replyTo: '', mimeType: '', charset: ''\n" | ||
val expected = "mail to: ''," + | ||
" subject: ''," + | ||
" body: ''," + | ||
" from: ''," + | ||
" cc: ''," + | ||
" bcc: ''," + | ||
" replyTo: ''," + | ||
" mimeType: ''," + | ||
" charset: ''\n" | ||
|
||
Mail().toGroovy(writer) | ||
assertEquals(expected, out.toString()) | ||
} | ||
|
||
@Test fun basic_email() { | ||
val expected = "mail to: '[email protected]', subject: 'Job Failure', body: 'Jenkins job build failure!', from: '', cc: '', bcc: '', replyTo: '', mimeType: '', charset: ''\n" | ||
Mail("[email protected]".strSingle(), "Job Failure".strSingle(), "Jenkins job build failure!".strSingle()).toGroovy(writer) | ||
val expected = "mail to: '[email protected]'," + | ||
" subject: 'Job Failure'," + | ||
" body: 'Jenkins job build failure!'," + | ||
" from: ''," + | ||
" cc: ''," + | ||
" bcc: ''," + | ||
" replyTo: ''," + | ||
" mimeType: ''," + | ||
" charset: ''\n" | ||
|
||
Mail("[email protected]".strSingle(), | ||
"Job Failure".strSingle(), | ||
"Jenkins job build failure!".strSingle()).toGroovy(writer) | ||
assertEquals(expected, out.toString()) | ||
} | ||
|
||
@Test fun all_parameters_email() { | ||
val expected = "mail to: '[email protected]', subject: 'Job Failure', body: 'Jenkins job build failure!', from: '[email protected]', cc: '[email protected]', bcc: '[email protected]', replyTo: '[email protected]', mimeType: 'text/plain', charset: 'UTF-8'\n" | ||
Mail("[email protected]".strSingle(), "Job Failure".strSingle(), "Jenkins job build failure!".strSingle(), "[email protected]".strSingle(), "[email protected]".strSingle(), "[email protected]".strSingle(), "[email protected]".strSingle(), "text/plain".strSingle(), "UTF-8".strSingle()).toGroovy(writer) | ||
val expected = "mail to: '[email protected]'," + | ||
" subject: 'Job Failure'," + | ||
" body: 'Jenkins job build failure!'," + | ||
" from: '[email protected]'," + | ||
" cc: '[email protected]'," + | ||
" bcc: '[email protected]'," + | ||
" replyTo: '[email protected]'," + | ||
" mimeType: 'text/plain', charset: 'UTF-8'\n" | ||
|
||
Mail("[email protected]".strSingle(), | ||
"Job Failure".strSingle(), | ||
"Jenkins job build failure!".strSingle(), | ||
"[email protected]".strSingle(), | ||
"[email protected]".strSingle(), | ||
"[email protected]".strSingle(), | ||
"[email protected]".strSingle(), | ||
"text/plain".strSingle(), | ||
"UTF-8".strSingle()).toGroovy(writer) | ||
assertEquals(expected, out.toString()) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...st/kotlin/com/code42/jenkins/pipelinekt/internal/step/scripted/SetBuildDescriptionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.code42.jenkins.pipelinekt.internal.step.scripted | ||
|
||
import com.code42.jenkins.pipelinekt.GroovyScriptTest | ||
import kotlin.test.assertEquals | ||
import org.junit.Test | ||
|
||
class SetBuildDescriptionTest : GroovyScriptTest() { | ||
@Test fun setBuildDescription() { | ||
val description = "Special Build Description Here!" | ||
SetBuildDescription(description).toGroovy(writer) | ||
val expected = "script {\n" + | ||
"\tcurrentBuild.description = \"Special Build Description Here!\"\n" + | ||
"}\n" | ||
assertEquals(expected, out.toString()) | ||
} | ||
} |