New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test Automation: Add Jenkins Pipeline Unit to the repository #93
Conversation
Needs an INFRA ticket to get Pipeline enabled for the repo. But thanks a lot! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. If we want to verify it, ci.jenkins.io-runner should be able to execute this pipeline
I already tried with the |
I already tried with the ci.jenkins.io-runner project but I was not able
to use the declarative pipeline out of the box but the scripted pipeline to
test the Jenkinsfile. It seems there are some clash dependencies when
running the jenkins-runne
Please report an issue so that I can take a look, thanks!
…On Mon, Jun 17, 2019 at 10:07 AM Victor Martinez ***@***.***> wrote:
I already tried with the ci.jenkins.io-runner project but I was not able
to use the declarative pipeline out of the box but the scripted pipeline to
test the Jenkinsfile. It seems there are some clash dependencies when
running the jenkins-runner. So, I haven't tried to solve them locally yet,
not sure if someone else could potentially give a go. My master branch is
now based on this PR: https://github.com/v1v/pipeline-library/ in case
someone would like to try the ci.jenkins.io-runner locally and easily.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#93?email_source=notifications&email_token=AAW4RIDP65536DRECKI3DYLP25A4XA5CNFSM4HXS3LQKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX2L5YI#issuecomment-502578913>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAW4RIHEI6VU3BTJBF4ZENDP25A4XANCNFSM4HXS3LQA>
.
|
…kerCredentialsOutsideInfra implementation as it does use the env variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we will see if this is helpful in preventing real regressions or not.
Jenkinsfile
Outdated
} | ||
stage('Test') { | ||
steps { | ||
sh 'mvn clean test' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least add -B
; also -ntp
after INFRA-2129.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave the -ntp
flag as a future change until that version of maven has not been updated in the infra side.
pom.xml
Outdated
<plugin> | ||
<groupId>org.codehaus.groovy</groupId> | ||
<artifactId>groovy-eclipse-compiler</artifactId> | ||
<version>2.9.2-01</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW there were some recent changes to the archetype here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After picking up the latest changes:
The test goal didn't execute anything and I managed to find implicit version changed of the surefire.
So I had to enforce the version as the previous one:
Not sure whether that's the expected behaviour in the archetype but with the latest commit everything seems to be back to business.
…e mvn goals and use the default surefire pattern
….12.4:test' by default with the latest changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 🎆
Added a basic test locally for testing #94, this already allows at least to catch compilation errors and so on, which is already a thing. So 👍 import com.lesfurets.jenkins.unit.BasePipelineTest
import org.junit.Before
import org.junit.Test
import org.yaml.snakeyaml.Yaml
import static com.lesfurets.jenkins.unit.MethodCall.callArgsToString
import static org.junit.Assert.assertTrue
class BuildPluginStepTests extends BasePipelineTest {
static final String scriptName = 'vars/buildPlugin.groovy'
Map env = [:]
/**
* Mock Infra step
*/
class Infra implements Serializable {
public String retrieveMavenSettingsFile(String location) { return location }
public String runWithMaven(String cmd) { return cmd }
public String runMaven(mvn, jdk, foo, settings) { return 'OK' }
}
@Override
@Before
void setUp() throws Exception {
super.setUp()
binding.setProperty('infra', new Infra())
binding.setVariable('env', env)
helper.registerAllowedMethod('archiveArtifacts', [Map.class], { m -> m })
helper.registerAllowedMethod('echo', [String.class], { s -> s })
helper.registerAllowedMethod('error', [String.class], {s ->
updateBuildStatus('FAILURE')
throw new Exception(s)
})
helper.registerAllowedMethod('findFiles', [Map.class], { String[] files = ["bom.yml", "d1/bom.yml"] })
helper.registerAllowedMethod('pwd', [], { '/foo' })
helper.registerAllowedMethod('pwd', [Map.class], { '/bar' })
helper.registerAllowedMethod('readYaml', [Map.class], {
Yaml yaml = new Yaml()
return yaml.load(default_config_metadata)
})
helper.registerAllowedMethod('sh', [String.class], { s -> s })
helper.registerAllowedMethod('writeYaml', [Map.class], { })
}
@Test
void test_loading() throws Exception {
def script = loadScript(scriptName)
}
} |
@rtyler That would be great if you can look into https://issues.jenkins-ci.org/browse/INFRA-2147 so the library can start being tested itself. Thanks! |
@rtyler sorry for asking you here directly here, I already asked twice in the infra mailing list about it, this PR is a kind of blocked as long as https://issues.jenkins-ci.org/browse/INFRA-2147 is not done. Are there any other requirements needed to be done before working on the above task? |
I pinged in chats. It looks @batmat did the same today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@v1v please accept the suggestions and then let's merge this and see how it works!
@@ -0,0 +1,25 @@ | |||
#!/usr/bin/env groovy | |||
pipeline { | |||
agent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can just work on the "maven" label, and use the Azure Container Instance agents which would be much faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for ACI
Co-Authored-By: R. Tyler Croy <rtyler@brokenco.de>
Done, please feel free to merge it, I just double check locally that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is pretty good as is., but bonus points for ACI
@@ -0,0 +1,25 @@ | |||
#!/usr/bin/env groovy | |||
pipeline { | |||
agent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for ACI
A bit YOLO, but 🚢 🇮🇹 |
|
This PR is just a PoC using the https://github.com/jenkinsci/JenkinsPipelineUnit for the
vars/infra.groovy
steps.Highlights
Tasks
Proposed
vars/infra.groovy
to simplify the UTs and the maintenance in the future.