Jv2 Jobs

Jenkins V2 - Call jobs on other systems

I am building up a few methods to work with other systems and just want to note down my general techniques here, how to get versions, run jobs, check ongoing status, report pass/fail etc.

First job, to call a Bamboo deployment

First step is to get the latest version that we want to deploy. I used Fiddler traces to get all the details after doing this by hand in a browser: URLs, Authentications and cookies have been updated here for security:

<br>
<a href=https://jira.atlassian.com/browse/BAM-13501?src=confmacro>https://jira.atlassian.com/browse/BAM-13501?src=confmacro</a><br>
<br>
Note: You only need releaseTypeOption environmentId and promoteVersion in the request body - versionName, planKey, buildNumber and altToken are optional!<br>
<br>
<a href=https://bamboo.adm.server/deploy/viewEnvironment.action?id=59604996>https://bamboo.adm.server/deploy/viewEnvironment.action?id=59604996</a><br>

---------------------------------------------------------------------------------------------------------

environmentId: 59604996
releaseTypeOption: PROMOTE
atl_token: c5dd6df341cd9a855743f99404aaacf0532d71f3

Recently added into this job:

Version: Latest
           1.0.5
           1.0.4
           1.0.3

(see the ‘if [ "${Version}" = "Latest" ]’ section of the script below)
---------------------------------------------------------------------------------------------------------

####!/bin/bash #bash not being picked up properly in my Jenkins V2

if [ "${Version}" = "Latest" ]; then

    echo get latest version from the site

    wget --header="Authorization: Basic bmdvZGZyZXk6QWhtZWUwQWk=" --header "Cookie: atl.xsrf.token=${atl_token}; JSESSIONID=61716178C187AE5B6DB63EEAFFBAB173" "https://bamboo.adm.server.net/rest/api/latest/search/versions?searchTerm=&start-index=0&chronologicalOrder=true&max-results=10&deploymentProjectId=106364929&branchKey=C4RCS-RCSB&_=1474450833045" -O master_.html

    R_num=$(grep '<name>' master_.html | awk 'BEGIN {FS="<name>"} {print $2}' | awk 'BEGIN {FS="</name>"} {print $1}')

    echo ${R_num}
    echo try using this captured version to build with: ${R_num}

else

    echo using version set to: ${Version}
    R_num=${Version}
    echo try using this DEFINED version to build with: ${R_num}

fi

wget --header="Authorization: Basic bmdvZGZyZXk6QWhtZWUwQWk=" --header "Cookie: atl.xsrf.token=${atl_token}; JSESSIONID=61716178C187AE5B6DB63EEAFFBAB173"  --post-data "environmentId=${environmentId}&releaseTypeOption=${releaseTypeOption}&promoteVersion=${R_num}&save=Start+deployment&atl_token=${atl_token}"  https://bamboo.adm.server.net/deploy/executeManualDeployment.action

sleep 60s

blue="0"
red="0"
while [ "$red" -eq "0" ] && [ "$blue" -eq "0" ]
do

    echo "sleeping for a while"
    sleep 60s

    wget --header="Authorization: Basic bmdvZGZyZXk6QWhtZWUwQWk=" --header "Cookie: JSESSIONID=4F23DB73EF3139B5FB844008F4DC41F0; atl.xsrf.token=${atl_token}; bamboo.dash.display.toggles=buildQueueActions-actions-queueControl; seraph.bambo=117407748%3A91a5888e8ddc355a61a5ca03e9be8f85b175bdc9" https://bamboo.adm.server.net/deploy/viewEnvironment.action?id=${environmentId} -O check.html

    grep '<dt>Completed' check.html | wc -l

    code=$(grep 'Deploying for' check.html | wc -l)
    echo code = ${code}
    if [[ $code =~ "1" ]] || [[ $code =~ "2" ]]; then #expecting 1

      echo "still deploying..."
      #passmark=1
      #echo passmark = $passmark - NOTE 0 = success -
      #exit 0 #adjust this if required

    else

      echo "completed ok"
      blue="1"
      exit 0

    fi

done


---------------------------------------------------------------------------------------------------------

*.*

---------------------------------------------------------------------------------------------------------

 


 

[Home] [About (CV)] [Contact Us] [JMeter Cloud] [webPageTest] [_64 images] [asset moniitor] [Linux Monitor] [Splunk ETL] [Splunk API] [AWS bash] [LR Rules OK] [LR Slave] [LR CI Graphs] [LoadRunner CI] [LR CI Variables] [LR Bamboo] [LR Methods] [LR CI BASH] [Bash methods] [Jenkins V2] [J V2 Pipeline1] [Jv2 Jobs] [Jv2 Analysis] [Jv2 Analysis2] [Streaming vid] [How fast] [Finding Issues] [Reporting] [Hand over] [VB Scripts] [JMeter tips] [JMeter RAW] [Dynatrace] [Documents] [FAQ] [Legal]

In the Cartesian Elements Ltd group of companies