jenkins java_具有WildFly,Arquillian,Jenkins和OpenShift的Java EE 7部署管道
jenkins java
技術(shù)提示#54展示了如何Arquillianate(Arquillianize?)一個(gè)現(xiàn)有的Java EE項(xiàng)目并在WildFly在已知主機(jī)和端口上運(yùn)行的遠(yuǎn)程模式下運(yùn)行這些測(cè)試。 技術(shù)提示#55展示了當(dāng)WildFly在OpenShift中運(yùn)行時(shí)如何運(yùn)行這些測(cè)試。 這兩個(gè)技巧都使用Maven配置文件來分隔“ pom.xml”中的相應(yīng)Arquillian依賴項(xiàng)和“ arquillian.xml”中的<container>配置,以定義WildFy在何處運(yùn)行以及如何連接。
本技巧將展示如何在OpenShift中配置Jenkins以及如何從Jenkins調(diào)用這些測(cè)試。 讓我們首先來看它!
從OpenShift上的Jenkins連接到OpenShift上的WildFly實(shí)例所需的配置與從本地計(jì)算機(jī)到OpenShift上的WildFly連接所需的配置相似。 此配置在“ arquillian.xml”中指定,我們可以指定一些參數(shù),然后可以在Jenkins中定義這些參數(shù)。
概括地說,這是我們要做的:
- 使用在技術(shù)提示#54和#55中創(chuàng)建的代碼,并為Arquillian / Jenkins / OpenShift添加配置
- 啟用詹金斯
- 創(chuàng)建一個(gè)新的WildFly Test實(shí)例
- 配置Jenkins在測(cè)試實(shí)例上運(yùn)行測(cè)試
- 僅當(dāng)測(cè)試通過測(cè)試實(shí)例時(shí),才將應(yīng)用程序推入生產(chǎn)環(huán)境
讓我們開始吧!
這將帶來所有源代碼,包括我們的REST端點(diǎn),網(wǎng)頁,測(cè)試,更新的“ pom.xml”和“ arquillian.xml”。 更新的“ pom.xml”具有兩個(gè)新的配置文件。
openshiftorg.apache.maven.pluginsmaven-war-plugin2.3falsedeploymentsROOTjenkins-openshiftmaven-surefire-plugin2.14.1jenkins-openshiftorg.jboss.arquillian.containerarquillian-openshift1.0.0.Final-SNAPSHOTtest這里要注意的幾點(diǎn):
更新的“ src / test / resources / arquillian.xml”具有以下容器:
<container qualifier="jenkins-openshift"><configuration><property name="namespace">${env.ARQ_DOMAIN}</property><property name="application">${env.ARQ_APPLICATION}</property><property name="libraDomain">rhcloud.com</property><property name="sshUserName">${env.ARQ_SSH_USER_NAME}</property><property name="login">arungupta@redhat.com</property><property name="deploymentTimeoutInSeconds">300</property><property name="disableStrictHostChecking">true</property> </configuration> </container>此容器配置類似于技術(shù)提示#55中添加的容器配置。 唯一的區(qū)別是,已對(duì)域名,應(yīng)用程序名稱和SSH用戶名進(jìn)行了參數(shù)設(shè)置。 這些屬性的值在Jenkins實(shí)例的配置中定義,并允許針對(duì)單獨(dú)的測(cè)試節(jié)點(diǎn)運(yùn)行測(cè)試。
請(qǐng)注意,這里的域是milestogo ,應(yīng)用程序名稱是mywildflytest ,SSH用戶名稱是546e3743ecb8d49ca9000014 。 這些將傳遞給Arquillian進(jìn)行測(cè)試。
請(qǐng)記住,這不是您的Test實(shí)例,因?yàn)樗性创a都位于先前創(chuàng)建的實(shí)例上。提供適當(dāng)?shù)拿Q,例如jenkins-milestogo.rhcloud.com(在我的情況下),然后單擊“添加Jenkins”按鈕。 這將提供一個(gè)Jenkins實(shí)例(如果尚未存在的話),并使用腳本配置項(xiàng)目以構(gòu)建和部署應(yīng)用程序。 記下名稱和密碼憑據(jù)。
單擊“保存”以保存配置。 這將允許在Test實(shí)例上運(yùn)行Arquillian測(cè)試。 如果測(cè)試通過,則將部署該應(yīng)用程序。 如果測(cè)試失敗,則該步驟之后的所有步驟均不會(huì)執(zhí)行,因此不會(huì)部署該應(yīng)用程序。
點(diǎn)的數(shù)量表示等待特定任務(wù),并且很可能會(huì)因運(yùn)行不同而有所不同。 而Jenkins控制臺(tái)( jenkins-milestogo.rhcloud.com/job/mywildfly-build/1/console )將輸出顯示為:
-------------------------------------------------------T E S T S ------------------------------------------------------- Running org.javaee7.sample.PersonTest Nov 20, 2014 2:54:56 PM org.jboss.arquillian.container.openshift.OpenShiftContainer start INFO: Preparing Arquillian OpenShift container at http://mywildflytest-milestogo.rhcloud.com Nov 20, 2014 2:55:48 PM org.jboss.arquillian.container.openshift.OpenShiftRepository push INFO: Pushed to the remote repository ssh://546e3743ecb8d49ca9000014@mywildflytest-milestogo.rhcloud.com/~/git/mywildflytest.git/ Nov 20, 2014 2:56:37 PM org.jboss.arquillian.container.openshift.OpenShiftRepository push INFO: Pushed to the remote repository ssh://546e3743ecb8d49ca9000014@mywildflytest-milestogo.rhcloud.com/~/git/mywildflytest.git/ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 103.056 sec Nov 20, 2014 2:56:37 PM org.jboss.arquillian.container.openshift.OpenShiftContainer stop INFO: Shutting down Arquillian OpenShift container at http://mywildflytest-milestogo.rhcloud.com Results :Tests run: 2, Failures: 0, Errors: 0, Skipped: 0[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3:13.069s [INFO] Finished at: Thu Nov 20 14:57:34 EST 2014 [INFO] Final Memory: 10M/101M [INFO] ------------------------------------------------------------------------ + /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh 546e36e5e0b8cd4e2a000007@mywildfly-milestogo.rhcloud.com 'gear stop --conditional' Warning: Permanently added 'mywildfly-milestogo.rhcloud.com,10.5.171.43' (RSA) to the list of known hosts. Stopping gear... Stopping wildfly cart Sending SIGTERM to wildfly:418673 ... + rsync --delete-after -azO -e /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh /var/lib/openshift/546e46304382ec3f29000012//.m2/ '546e36e5e0b8cd4e2a000007@mywildfly-milestogo.rhcloud.com:~/.m2/' Warning: Permanently added 'mywildfly-milestogo.rhcloud.com,10.5.171.43' (RSA) to the list of known hosts. + rsync --delete-after -azO -e /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh /var/lib/openshift/546e46304382ec3f29000012/app-root/runtime/repo/deployments/ '546e36e5e0b8cd4e2a000007@mywildfly-milestogo.rhcloud.com:${OPENSHIFT_REPO_DIR}deployments/' Warning: Permanently added 'mywildfly-milestogo.rhcloud.com,10.5.171.43' (RSA) to the list of known hosts. + rsync --delete-after -azO -e /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh /var/lib/openshift/546e46304382ec3f29000012/app-root/runtime/repo/.openshift/ '546e36e5e0b8cd4e2a000007@mywildfly-milestogo.rhcloud.com:${OPENSHIFT_REPO_DIR}.openshift/' Warning: Permanently added 'mywildfly-milestogo.rhcloud.com,10.5.171.43' (RSA) to the list of known hosts. + /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh 546e36e5e0b8cd4e2a000007@mywildfly-milestogo.rhcloud.com 'gear remotedeploy' Warning: Permanently added 'mywildfly-milestogo.rhcloud.com,10.5.171.43' (RSA) to the list of known hosts. Preparing build for deployment Deployment id is dff28e58 Activating deployment Deploying WildFly Starting wildfly cart Found 127.12.255.129:8080 listening port Found 127.12.255.129:9990 listening port /var/lib/openshift/546e36e5e0b8cd4e2a000007/wildfly/standalone/deployments /var/lib/openshift/546e36e5e0b8cd4e2a000007/wildfly /var/lib/openshift/546e36e5e0b8cd4e2a000007/wildfly CLIENT_MESSAGE: Artifacts deployed: ./ROOT.war Archiving artifacts Finished: SUCCESS可以查看Jenkins的日志文件,如下所示:
Nov 20, 2014 2:51:11 PM hudson.plugins.openshift.OpenShiftCloud provision INFO: Provisioning new node for workload = 2 and label = mywildfly-build in domain milestogo Nov 20, 2014 2:51:11 PM hudson.plugins.openshift.OpenShiftCloud getOpenShiftConnection INFO: Initiating Java Client Service - Configured for OpenShift Server https://openshift.redhat.com Nov 20, 2014 2:51:11 PM com.openshift.internal.client.RestService request INFO: Requesting GET with protocol 1.2 on https://openshift.redhat.com/broker/rest/api Nov 20, 2014 2:51:11 PM com.openshift.internal.client.RestService request INFO: Requesting GET with protocol 1.2 on https://openshift.redhat.com/broker/rest/user Nov 20, 2014 2:51:11 PM com.openshift.internal.client.RestService request. . .INFO: Checking availability of computer hudson.plugins.openshift.OpenShiftSlave@8ce21115 Nov 20, 2014 2:53:35 PM com.openshift.internal.client.RestService request INFO: Requesting GET with protocol 1.2 on https://openshift.redhat.com/broker/rest/domain/milestogo/application/mywildflybldr/gear_groups Nov 20, 2014 2:53:35 PM hudson.plugins.openshift.OpenShiftComputerLauncher launch INFO: Checking SSH access to application mywildflybldr-milestogo.rhcloud.com Nov 20, 2014 2:53:35 PM hudson.plugins.openshift.OpenShiftComputerLauncher launch INFO: Connecting via SSH '546e46304382ec3f29000012' 'mywildflybldr-milestogo.rhcloud.com' '/var/lib/openshift/546e393e5973ca0492000070/app-root/data/.ssh/jenkins_id_rsa' Nov 20, 2014 2:53:35 PM hudson.slaves.NodeProvisioner update INFO: mywildfly-build provisioningE successfully completed. We have now 2 computer(s) Nov 20, 2014 2:53:35 PM hudson.plugins.openshift.OpenShiftComputerLauncher launch INFO: Connected via SSH. Nov 20, 2014 2:53:35 PM hudson.plugins.openshift.OpenShiftComputerLauncher launch INFO: Exec mkdir -p $OPENSHIFT_DATA_DIR/jenkins && cd $OPENSHIFT_DATA_DIR/jenkins && rm -f slave.jar && wget -q --no-check-certificate https://jenkins-milestogo.rhcloud.com/jnlpJars/slave.jar Nov 20, 2014 2:53:42 PM hudson.plugins.openshift.OpenShiftComputerLauncher launch INFO: Slave connected. Nov 20, 2014 2:58:24 PM hudson.model.Run execute INFO: mywildfly-build #1 main build action completed: SUCCESS 這表明該應(yīng)用程序已成功部署在mywildfly-milestogo.rhcloud.com/index.jsp上 ,如下所示:
現(xiàn)在更改“ src / main / webapp / index.jsp”以顯示不同的標(biāo)題。 并更改“ src / test / java / org / javaee7 / sample / PersonTest.java”以使其中一項(xiàng)測(cè)試失敗。 進(jìn)行“ git commit”和“ git push”會(huì)在命令行上顯示以下結(jié)果:
mywildfly> git commit . -m"breaking the test" [master ff2de09] breaking the test2 files changed, 2 insertions(+), 2 deletions(-) mywildfly> git push Counting objects: 23, done. Delta compression using up to 8 threads. Compressing objects: 100% (8/8), done. Writing objects: 100% (12/12), 771 bytes | 0 bytes/s, done. Total 12 (delta 5), reused 0 (delta 0) remote: Executing Jenkins build. remote: remote: You can track your build at https://jenkins-milestogo.rhcloud.com/job/mywildfly-build remote: remote: Waiting for build to schedule.......Done remote: Waiting for job to complete.....................................................................................................................................................................Done remote: FAILED remote: !!!!!!!! remote: Deployment Halted! remote: If the build failed before the deploy step, your previous remote: build is still running. Otherwise, your application may be remote: partially deployed or inaccessible. remote: Fix the build and try again. remote: !!!!!!!! remote: An error occurred executing 'gear postreceive' (exit code: 1) remote: Error message: CLIENT_ERROR: Failed to execute: 'control post-receive' for /var/lib/openshift/546e36e5e0b8cd4e2a000007/jenkins-client remote: remote: For more details about the problem, try running the command again with the '--trace' option. To ssh://546e36e5e0b8cd4e2a000007@mywildfly-milestogo.rhcloud.com/~/git/mywildfly.git/d618fad..ff2de09 master -> master要注意的關(guān)鍵聲明是,測(cè)試失敗后,將停止部署。 您可以通過重新訪問mywildfly-milestogo.rhcloud.com/index.jsp并檢查更新后的“ index.jsp”是否不可見來驗(yàn)證這一點(diǎn)。
簡(jiǎn)而言之,測(cè)試通過,網(wǎng)站已更新。 測(cè)試失敗,該網(wǎng)站未更新。 因此,您已經(jīng)使用WildFly,OpenShift,Arquillian和Jenkins為Java EE 7建立了一個(gè)簡(jiǎn)單的部署管道!
翻譯自: https://www.javacodegeeks.com/2014/12/deployment-pipeline-for-java-ee-7-with-wildfly-arquillian-jenkins-and-openshift.html
jenkins java
總結(jié)
以上是生活随笔為你收集整理的jenkins java_具有WildFly,Arquillian,Jenkins和OpenShift的Java EE 7部署管道的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 果粉是啥意思 果粉简单介绍
- 下一篇: 响应式多级菜单 侧边菜单栏_使用纯HTM