Skip to content

Modify jenkins steps to adjust 4.0 change #98

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

Merged
merged 3 commits into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 18 additions & 40 deletions features/step_definitions/images/jenkins.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#Use this step definition file to create image-specific steps

#This empty step will be removed once we can start updating the existing
#jenkins cases to use the new OAuth method; this way there is no
#'missing step' error here.
Given /^I save the jenkins password of dc #{QUOTED} into the#{OPT_SYM} clipboard$/ do
end

Given /^I have an?( ephemeral| persistent)? jenkins v#{NUMBER} application(?: from #{QUOTED})?$/ do |type, version, cust_templ|

if cust_templ && type
Expand All @@ -30,15 +24,14 @@
source = "| template | jenkins-#{type.strip} |"
end

lt34 = env.version_lt("3.4", user: user)
last_startup_check = monotonic_seconds

# On v3.4 and above, if we can login to OpenShift via password, then
# If we can login to OpenShift via password, then
# we can use SSO login.
# On 3.3 and earlier, or if we only know user token, then we must use
# If we only know user token, then we must use
# non-SSO login.
# Installation step also installs based on this.
if lt34 || !user.password?
if !user.password?
step %Q/I run the :new_app client command with:/, table(%{
#{source}
| p | ENABLE_OAUTH=false |
Expand All @@ -60,16 +53,13 @@
cb.jenkins_dns = cb.jenkins_route.dns
cb.jenkins_major_version = version

# wait for actual startup as in 3.10+ it is slow on only 512M pod
timeout = 300
if version == "1"
wait_string = "Jenkins is fully up and running"
else
# wait for actual startup as in 3.10+ it is slow on only 512M pod
# seems like recent jenkins has a delay caused by admin monitor
# here trying to wait for it's operation to finish
# possible remedy is DISABLE_ADMINISTRATIVE_MONITOR or give mor RAM to pod
wait_string = "Finished Download metadata."
end
timeout = 600
wait_string = "Finished Download metadata."

started = wait_for(timeout) {
since = monotonic_seconds - last_startup_check
res = user.cli_exec(
Expand All @@ -96,45 +86,33 @@
step 'I have a browser with:', table(opts)
end

# On v3.4 and above, if we can login to OpenShift via password, then
# If we can login to OpenShift via password, then
# we can use SSO login.
# On 3.3 and earlier, or if we only know user token, then we must use
# If we only know user token, then we must use
# non-SSO login.
# Installation step also installs based on this.
Given /^I log in to jenkins$/ do
if env.version_ge("3.4", user: user) && user.password?
step %Q/I perform the :jenkins_oauth_login web action with:/, table(%{
if env.version_gt("3.11", user: user) && user.password?
step %Q/I perform the :jenkins_multi_oauth_login web action with:/, table(%{
| username | <%= user.name %> |
| password | <%= user.password %> |
})
else
elsif !user.password?
step %Q/I perform the :jenkins_standard_login web action with:/, table(%{
| username | admin |
| password | password |
})
else
raise "Please switch to v3 branch to launch automation."
end
step 'the step should succeed'
end

Given /^I update #{QUOTED} slave image for jenkins #{NUMBER} server$/ do |slave_name,jenkins_version|
le39 = env.version_le("3.9", user: user)

step 'I store master major version in the clipboard'
if le39 or jenkins_version == '1'
step %Q/I perform the :jenkins_update_cloud_image web action with:/, table(%{
| currentimgval | registry.access.redhat.com/openshift3/jenkins-slave-#{slave_name}-rhel7 |
| cloudimage | <%= product_docker_repo %>openshift3/jenkins-slave-#{slave_name}-rhel7:v<%= cb.master_version %> |
})
elsif slave_name == 'maven'
step %Q/I perform the :jenkins_update_cloud_image web action with:/, table(%{
| currentimgval | openshift3/jenkins-agent-maven-35-rhel7 |
| cloudimage | <%= product_docker_repo %>openshift3/jenkins-agent-maven-35-rhel7:v<%= cb.master_version %> |
})
elsif slave_name == 'nodejs'
step %Q/I perform the :jenkins_update_cloud_image web action with:/, table(%{
| currentimgval | openshift3/jenkins-agent-nodejs-8-rhel7 |
| cloudimage | <%= product_docker_repo %>openshift3/jenkins-agent-nodejs-8-rhel7:v<%= cb.master_version %> |
})
if env.version_gt("3.11", user: user)
print "Skipped, agent images don't need update above openshift 4.0"
else
raise "Please switch to v3 branch to launch automation."
end

step 'the step should succeed'
Expand Down
7 changes: 4 additions & 3 deletions lib/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,11 @@ def get_version(user:)
if obtained[:request_opts][:url].include?("/version/openshift") &&
!obtained[:success]
# seems like pre-3.3 version, lets hardcode to 3.2
# After bug 1692670 fix, will recover hardcode to '3.2'.
obtained[:props] = {}
obtained[:props][:openshift] = "v3.2"
@major_version = obtained[:props][:major] = 3
@minor_version = obtained[:props][:minor] = 2
obtained[:props][:openshift] = "v4.0"
@major_version = obtained[:props][:major] = 4
@minor_version = obtained[:props][:minor] = 0
elsif obtained[:success]
@major_version = obtained[:props][:major].to_i
@minor_version = obtained[:props][:minor].to_i
Expand Down
39 changes: 37 additions & 2 deletions lib/rules/web/images/jenkins_2/jenkins_2.xyaml
Original file line number Diff line number Diff line change
Expand Up @@ -552,14 +552,47 @@ jenkins_standard_login:
name: j_password
op: send_keys <password>
type: input
scripts:
- command: return document.getElementsByName("Submit")[0].click()
expect_result: ~
action: jenkins_verify_logged_in

jenkins_oauth_login:
url: /securityRealm/commenceLogin?from=%2F
scripts:
- command: |
var Logtext = document.getElementsByClassName("btn btn-lg btn-primary")[0]
if (typeof(Logtext) == "undefined"){
return true;
}
Logtext.click();
return true;
expect_result: true
elements:
- selector:
id: yui-gen1-button
id: inputUsername
op: send_keys <username>
type: input
- selector:
id: inputPassword
op: send_keys <password>
type: input
- selector:
text: Log In
op: click
type: button
scripts:
- command: |
var Auth = document.getElementsByName("approve")[0]
if (typeof(Auth) == "undefined"){
return true;
}
Auth.click();
return true;
expect_result: true
action: jenkins_verify_logged_in

jenkins_oauth_login:
jenkins_multi_oauth_login:
url: /securityRealm/commenceLogin?from=%2F
scripts:
- command: |
Expand All @@ -570,6 +603,8 @@ jenkins_oauth_login:
Logtext.click();
return true;
expect_result: true
- command: return document.getElementsByClassName("idp")[1].click()
expect_result: ~
elements:
- selector:
id: inputUsername
Expand Down