Extending our Jenkinsfile

We're going to change up our Jenkinsfile to support our new RSpec test. We're going to remove our original Test stage and be more clear by creating the Validate and Unit Test stages. We'll simply incorporate the two as pdk validate and pdk test unit:

pipeline {
agent any

stages {
stage('Validate') {
steps {
sh '/usr/local/bin/pdk validate'
}
}
stage ('Unit Test') {
steps {
sh '/usr/local/bin/pdk test unit'
}
}
}
}

This will change our pipeline to three distinct phases: checkout SCM, Validate, and Unit Test. We'll be able to see where our build passes or fails along each step in Jenkins.

Now that we have a basic framework for our test laid out, let's get our code back to the remote repository:

[root@pe-puppet-master profile]# git commit -m 'Initial RSpec Framework'
[rspec 2bc4765] Initial RSpec Framework
3 files changed, 37 insertions(+), 1 deletion (-)
create mode 100644 .fixtures.yml
create mode 100644 spec/classes/jenkins_spec.rb
[root@pe-puppet-master profile]# git push origin rspec
Counting objects: 8, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 892 bytes | 0 bytes/s, done.
Total 6 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To [email protected]:RARYates/cicd-walkthrough-profile.git
* [new branch] rspec -> rspec

Back in our Jenkins instance, we can see the new RSpec branch and the new logs for our test. Notice each section, and that we're also seeing our Jenkins instance pass our four RSpec tests.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.141.6