-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional build parameter to build with saucelabs instead (#1952)
* Add optional build parameter to build with saucelabs instead * nobody is using the code-cov html reports, so stop them for now * use array of jenkins versions so its not copy and pasted
- Loading branch information
Showing
9 changed files
with
175 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM debian | ||
RUN apt update && \ | ||
apt install -y wget && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
wget -O - https://saucelabs.com/downloads/sc-4.5.3-linux.tar.gz | tar xvzf - | ||
ENV BUILD_TAG "" | ||
RUN printf "#!/bin/bash \n\ | ||
if [ -z \"\$BUILD_TAG\" ]; then\n\ | ||
/sc-4.5.3-linux/bin/sc -u \$SAUCE_USERNAME -k \$SAUCE_ACCESS_KEY \n\ | ||
else\n\ | ||
/sc-4.5.3-linux/bin/sc -u \$SAUCE_USERNAME -k \$SAUCE_ACCESS_KEY -i \$BUILD_TAG \n\ | ||
fi \n\ | ||
\n" > /entrypoint.sh && chmod 755 /entrypoint.sh | ||
ENTRYPOINT /entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,94 +8,121 @@ if (JENKINS_URL == 'https://ci.jenkins.io/') { | |
return | ||
} | ||
|
||
// only 20 builds | ||
properties([buildDiscarder(logRotator(artifactNumToKeepStr: '20', numToKeepStr: '20'))]) | ||
properties([ | ||
// only 20 builds, | ||
buildDiscarder(logRotator(artifactNumToKeepStr: '20', numToKeepStr: '20')), | ||
parameters([ | ||
booleanParam(name: 'USE_SAUCELABS', defaultValue: false) | ||
]) | ||
]) | ||
|
||
node() { | ||
stage('Setup') { | ||
deleteDir() | ||
checkout scm | ||
sh 'docker build -t blueocean_build_env --build-arg GID=$(id -g ${USER}) --build-arg UID=$(id -u ${USER}) - < Dockerfile.build' | ||
withCredentials([file(credentialsId: 'blueoceandeploy_ath', variable: 'FILE')]) { | ||
sh 'mv $FILE acceptance-tests/live.properties' | ||
} | ||
configFileProvider([configFile(fileId: 'blueocean-maven-settings', variable: 'MAVEN_SETTINGS')]) { | ||
sh 'mv $MAVEN_SETTINGS settings.xml' | ||
} | ||
withCredentials([file(credentialsId: 'blueocean-ath-private-repo-key', variable: 'FILE')]) { | ||
sh 'mv $FILE acceptance-tests/bo-ath.key' | ||
} | ||
sh "./acceptance-tests/runner/scripts/start-selenium.sh" | ||
sh "./acceptance-tests/runner/scripts/start-bitbucket-server.sh" | ||
} | ||
credentials = [ | ||
file(credentialsId: 'blueoceandeploy_ath', variable: 'LIVE_PROPERTIES_FILE'), | ||
file(credentialsId: 'blueocean-ath-private-repo-key', variable: 'BO_ATH_KEY_FILE') | ||
] | ||
|
||
try { | ||
docker.image('blueocean_build_env').inside("--net=container:blueo-selenium") { | ||
withEnv(['[email protected]','GIT_COMMITTER_NAME=Hates','GIT_AUTHOR_NAME=Cake','[email protected]']) { | ||
stage('Sanity check dependencies') { | ||
sh "node ./bin/checkdeps.js" | ||
sh "node ./bin/checkshrinkwrap.js" | ||
} | ||
envs = [ | ||
'[email protected]', | ||
'GIT_COMMITTER_NAME=Hates', | ||
'GIT_AUTHOR_NAME=Cake', | ||
'[email protected]' | ||
] | ||
|
||
stage('Building JS Libraries') { | ||
sh 'node -v && npm -v' | ||
sh 'npm --prefix ./js-extensions run build' | ||
} | ||
jenkinsVersions = ['2.138.4'] | ||
|
||
stage('Building BlueOcean') { | ||
timeout(time: 90, unit: 'MINUTES') { | ||
sh "mvn clean install -V -B -DcleanNode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dmaven.test.failure.ignore -s settings.xml -Dmaven.artifact.threads=30" | ||
} | ||
if (params.USE_SAUCELABS) { | ||
credentials.add(usernamePassword(credentialsId: 'saucelabs', passwordVariable: 'SAUCE_ACCESS_KEY', usernameVariable: 'SAUCE_USERNAME')) | ||
withCredentials([usernamePassword(credentialsId: 'saucelabs', passwordVariable: 'SAUCE_ACCESS_KEY', usernameVariable: 'SAUCE_USERNAME')]) { | ||
envs.add("webDriverUrl=https://${env.SAUCE_USERNAME}:${env.SAUCE_ACCESS_KEY}@ondemand.saucelabs.com/wd/hub") | ||
} | ||
envs.add("saucelabs=true") | ||
envs.add("TUNNEL_IDENTIFIER=${env.BUILD_TAG}") | ||
} | ||
|
||
if (env.JOB_NAME =~ 'blueocean-weekly-ath') { | ||
jenkinsVersions.add('2.121.1') | ||
jenkinsVersions.add('2.150.3') | ||
} | ||
|
||
node() { | ||
withCredentials(credentials) { | ||
withEnv(envs) { | ||
|
||
junit '**/target/surefire-reports/TEST-*.xml' | ||
junit '**/target/jest-reports/*.xml' | ||
jacoco execPattern: '**/target/jacoco.exec', classPattern : '**/target/classes', sourcePattern: '**/src/main/java', exclusionPattern: 'src/test*' | ||
archive '*/target/code-coverage/**/*' | ||
archive '*/target/*.hpi' | ||
archive '*/target/jest-coverage/**/*' | ||
stage('Setup') { | ||
deleteDir() | ||
checkout scm | ||
sh 'docker build -t blueocean_build_env --build-arg GID=$(id -g ${USER}) --build-arg UID=$(id -u ${USER}) - < Dockerfile.build' | ||
sh 'mv $LIVE_PROPERTIES_FILE acceptance-tests/live.properties' | ||
configFileProvider([configFile(fileId: 'blueocean-maven-settings', variable: 'MAVEN_SETTINGS')]) { | ||
sh 'mv $MAVEN_SETTINGS settings.xml' | ||
} | ||
sh 'mv $BO_ATH_KEY_FILE acceptance-tests/bo-ath.key' | ||
if (params.USE_SAUCELABS) { | ||
sh "./acceptance-tests/runner/scripts/start-sc.sh" | ||
} else { | ||
sh "./acceptance-tests/runner/scripts/start-selenium.sh" | ||
} | ||
sh "./acceptance-tests/runner/scripts/start-bitbucket-server.sh" | ||
} | ||
|
||
stage('ATH - Jenkins 2.138.4') { | ||
timeout(time: 90, unit: 'MINUTES') { | ||
sh "cd acceptance-tests && bash -x ./run.sh -v=2.138.4 --no-selenium --settings='-s ${env.WORKSPACE}/settings.xml'" | ||
junit 'acceptance-tests/target/surefire-reports/*.xml' | ||
archive 'acceptance-tests/target/screenshots/**/*' | ||
try { | ||
docker.image('blueocean_build_env').inside("--net=container:blueo-selenium") { | ||
ip = sh(returnStdout: true, script: "hostname -I | awk '{print \$1}'").trim() | ||
echo "IP: [${ip}]" | ||
stage('Sanity check dependencies') { | ||
sh "node ./bin/checkdeps.js" | ||
sh "node ./bin/checkshrinkwrap.js" | ||
} | ||
} | ||
|
||
if (env.JOB_NAME =~ 'blueocean-weekly-ath') { | ||
stage('ATH - Jenkins 2.73.2') { | ||
sh "cd acceptance-tests && bash -x ./run.sh -v=2.73.2 --no-selenium --settings='-s ${env.WORKSPACE}/settings.xml'" | ||
junit 'acceptance-tests/target/surefire-reports/*.xml' | ||
stage('Building JS Libraries') { | ||
sh 'node -v && npm -v' | ||
sh 'npm --prefix ./js-extensions run build' | ||
} | ||
stage('ATH - Jenkins 2.73.3') { | ||
sh "cd acceptance-tests && bash -x ./run.sh -v=2.73.3 --no-selenium --settings='-s ${env.WORKSPACE}/settings.xml'" | ||
junit 'acceptance-tests/target/surefire-reports/*.xml' | ||
|
||
stage('Building BlueOcean') { | ||
timeout(time: 90, unit: 'MINUTES') { | ||
sh "mvn clean install -V -B -DcleanNode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dmaven.test.failure.ignore -s settings.xml -Dmaven.artifact.threads=30" | ||
} | ||
|
||
junit '**/target/surefire-reports/TEST-*.xml' | ||
junit '**/target/jest-reports/*.xml' | ||
jacoco execPattern: '**/target/jacoco.exec', classPattern : '**/target/classes', sourcePattern: '**/src/main/java', exclusionPattern: 'src/test*' | ||
// archive '*/target/code-coverage/**/*' | ||
archive '*/target/*.hpi' | ||
// archive '*/target/jest-coverage/**/*' | ||
} | ||
stage('ATH - Jenkins 2.107.2') { | ||
sh "cd acceptance-tests && bash -x ./run.sh -v=2.107.2 --no-selenium --settings='-s ${env.WORKSPACE}/settings.xml'" | ||
junit 'acceptance-tests/target/surefire-reports/*.xml' | ||
|
||
jenkinsVersions.each { version -> | ||
stage("ATH - Jenkins ${version}") { | ||
timeout(time: 90, unit: 'MINUTES') { | ||
dir('acceptance-tests') { | ||
sh "bash -x ./run.sh -v=${version} --host=${ip} --no-selenium --settings='-s ${env.WORKSPACE}/settings.xml'" | ||
junit '**/target/surefire-reports/*.xml' | ||
archive '**/target/screenshots/**/*' | ||
} | ||
} | ||
} | ||
} | ||
stage('ATH - Jenkins 2.121.1') { | ||
sh "cd acceptance-tests && bash -x ./run.sh -v=2.121.1 --no-selenium --settings='-s ${env.WORKSPACE}/settings.xml'" | ||
junit 'acceptance-tests/target/surefire-reports/*.xml' | ||
} | ||
} catch(err) { | ||
echo(err) | ||
currentBuild.result = "FAILURE" | ||
|
||
if (err.toString().contains('exit code 143')) { | ||
currentBuild.result = "ABORTED" | ||
} | ||
} finally { | ||
stage('Cleanup') { | ||
if (params.USE_SAUCELABS) { | ||
sh "${env.WORKSPACE}/acceptance-tests/runner/scripts/stop-sc.sh" | ||
} else { | ||
sh "${env.WORKSPACE}/acceptance-tests/runner/scripts/stop-selenium.sh" | ||
} | ||
sh "${env.WORKSPACE}/acceptance-tests/runner/scripts/stop-bitbucket-server.sh" | ||
deleteDir() | ||
} | ||
} | ||
} | ||
|
||
} catch(err) { | ||
currentBuild.result = "FAILURE" | ||
|
||
if (err.toString().contains('exit code 143')) { | ||
currentBuild.result = "ABORTED" | ||
} | ||
} finally { | ||
stage('Cleanup') { | ||
sh "${env.WORKSPACE}/acceptance-tests/runner/scripts/stop-selenium.sh" | ||
sh "${env.WORKSPACE}/acceptance-tests/runner/scripts/stop-bitbucket-server.sh" | ||
deleteDir() | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
SCRIPT_DIR=$(dirname $0) | ||
$SCRIPT_DIR/stop-sc.sh | ||
|
||
echo "" | ||
echo " Starting Sauce Connect container..." | ||
echo "" | ||
docker run \ | ||
-d \ | ||
--name blueo-selenium \ | ||
--net host \ | ||
-e SAUCE_ACCESS_KEY \ | ||
-e SAUCE_USERNAME \ | ||
-e BUILD_TAG \ | ||
--rm \ | ||
blueocean/sauceconnect:4.5.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
echo "" | ||
echo " Stopping old Sauce Connect container, if any. This may take a few seconds..." | ||
docker stop blueo-selenium > /dev/null | ||
docker rm blueo-selenium > /dev/null | ||
echo " ... stopped" | ||
echo "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters