diff --git a/Jenkinsfile b/Jenkinsfile index 02d247874..4ca9d87d6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,27 +1,50 @@ pipeline { - agent { - docker { - image 'maven:3.5.0' - args '--network=plumbing_default' - } - } + agent none stages { - stage ('Build') { - steps { - configFileProvider( - [configFile(fileId: 'nexus', variable: 'MAVEN_SETTINGS')]) { - sh 'mvn -s $MAVEN_SETTINGS clean deploy -DskipTests=true' - } - } - } - stage ('Deploy to Tomcat') { - steps { - sh 'cp target/petclinic.war /usr/share/jenkins/ref/petclinic/petclinic.war' - } - } - stage ('Sonar') { + stage('Build') { + agent { + docker { + image 'maven:3.5.0' + args '--network=plumbing_default' + } + } steps { - sh '/var/jenkins_home/sonar/bin/sonar-runner' + configFileProvider( + [configFile(fileId: 'nexus', variable: 'MAVEN_SETTINGS')]) { + sh 'mvn -s $MAVEN_SETTINGS clean deploy -DskipTests=true' + } + } + } + stage('Deploy to Tomcat') { + agent { + docker { + image 'alpine' + } + } + steps { + sh 'cp target/petclinic.war /usr/share/jenkins/ref/petclinic/petclinic.war' + } + } + stage('Sonar') { + agent { + docker { + image 'sebp/sonar-runner' + args '--network=plumbing_default' + } + } + steps { + sh '/opt/sonar-runner-2.4/bin/sonar-runner' + } + } + stage('Selenium') { + agent { + docker { + image 'stein321/selenium-firefox' + args '--network=plumbing_default' + } + } + steps { + sh 'ruby petclinic_spec.rb' } } } diff --git a/petclinic_spec.rb b/petclinic_spec.rb new file mode 100644 index 000000000..44d625a6b --- /dev/null +++ b/petclinic_spec.rb @@ -0,0 +1,37 @@ +require 'headless' +require 'selenium-webdriver' +require 'minitest/spec' +require 'minitest/autorun' + +describe 'Petlinic' do + before do + @headless = Headless.new + @headless.start + + @driver = Selenium::WebDriver.for :firefox + @driver.navigate.to 'http://dashboard:8080/petclinic' + @wait = Selenium::WebDriver::Wait.new(:timeout => 3) + end + + after do + @headless.destroy + end + + describe 'when homepage is available' do + it 'I should see Page title' do + puts "Title is: #{@driver.title}" + assert @driver.title == "PetClinic :: a Spring Framework demonstration" + end + end + + + # describe 'when homepage is available' do + # it 'click the find owners button' do + # @driver.find_element(:class, "icon-search").click + # form = @driver.find_element(:id, "lastName") + # puts "form is #{form.label}" + # assert @driver.title == "PetClinic :: a Spring Framework demonstration" + # end + # end + +end