Div |
---|
|
Rp |
---|
External Tools: Bridge Tools: |
|
Based on a straightforward and repeatable process, the continuous delivery approach helps with building, testing and releasing software faster. On this page, we will show how you can automate your build, deploy, and testing processes using an automation tool together with the E2E Bridge command line tools.
To take full advantage of this scenario, you need the E2E xUML Command Line Compiler which is part of E2E Bridge 7.
Prerequisites
The following will guide you through an continuous delivery example. Here, we are using Jenkins, an open source automation tool, and Git, an open source version control tool. To set up a similar scenario, you need
Approach
- Set-up a job in Jenkins that checks minutely for changes to your git repository and triggers a build process in case of changes.
- The build process itself is defined in a Jenkinsfile that is part of the Git repository and contains the following steps:
- Building the xUML repository file using the E2E xUML Command Line Compiler.
- Deploying the compiled repository using the Bridge CLI.
- Running regression tests on the deployed services with the E2E Regression Test Runner.
Setting Up a Job in Jenkins
...
Expand |
---|
title | Click here to expand the complete code of the Jenkinsfile ... |
---|
|
Code Block |
---|
language | groovy |
---|
linenumbers | true |
---|
| #!groovy
pipeline {
agent {
node {
label 'Windows'
customWorkspace "workspace/test-xUML-project"
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '1'))
disableConcurrentBuilds()
}
parameters {
choice(name: 'E2ECXUMLC', choices: 'D:/jenkins/userContent/e2ecxumlc/e2ecxumlc-7.010.0-beta1.jar', description: 'Location of the E2ExUML Compiler')
choice(name: 'REGTEST', choices: 'D:/jenkins/userContent/RegTestRunner/RegTestRunner-nightly.jar', description: 'Location of the E2E Regression Test Runner')
}
stages {
stage('Build') {
steps {
dir('Advanced Modeling/E2ELibrary') {
bat """
java -jar ${E2ECXUMLC} -uml uml/librarySQLQuery.xml
copy repository\\librarySQLQuery\\librarySQLQuery.lrep libs\\
java -jar ${E2ECXUMLC} -uml uml/useLibrarySQLQuery.xml
"""
archiveArtifacts artifacts: 'repository/useLibrarySQLQuery/UseE2ELibraryExample.rep'
}
dir('Advanced Modeling/PState') {
bat """
java -jar ${E2ECXUMLC} -uml uml/pstatePurchaseOrder.xml
"""
archiveArtifacts artifacts: 'repository/pstatePurchaseOrder/PurchaseOrderExample.rep'
}
}
}
stage('Deploy') {
steps {
dir('Advanced Modeling') {
bat '''
e2ebridge deploy E2ELibrary/repository/useLibrarySQLQuery/UseE2ELibraryExample.rep -h <Bridge host> -u <user> -P <password> -o overwrite
e2ebridge deploy PState/repository/pstatePurchaseOrder/PurchaseOrderExample.rep -h <Bridge host> -u <user> -P <password> -o overwrite
'''
}
}
}
stage('Test') {
steps {
dir('Advanced Modeling') {
bat """
java -jar ${REGTEST} -project PState -suite "QA Tests/Tests" -logfile result.xml -host <Bridge host> -port <port> -username <user> -password <password>
"""
}
}
post {
always {
junit 'Advanced Modeling/result.xml'
}
}
}
}
} |
|
Code Snippet | Description |
---|
agent {
node {
label 'Windows'
customWorkspace "workspace/test-xUML-project"
}
} | Section agent defines - the name of the agent that should execute the build
- the common workspace directory on this agent for all branches within the Git repository. If not specified, Jenkins will create a separate workspace for every branch.
|
options {
buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '1'))
disableConcurrentBuilds()
}
| Section options defines - the count of build logs to keep
- the count of build artifacts to keep
- whether concurrent builds are allowed
|
parameters {
choice(name: 'E2ECXUMLC', choices: 'D:/jenkins/userContent/e2ecxumlc/e2ecxumlc-7.010.0-beta1.jar', description: 'Location of the E2ExUML Compiler')
choice(name: 'REGTEST', choices: 'D:/jenkins/userContent/RegTestRunner/RegTestRunner-nightly.jar', description: 'Location of the E2E Regression Test Runner')
}
| Section parameters defines parameters to use further below in the script. If you provide multiple choices, Jenkins will generate a dropdown list to select from. The first list item serves as the default value. This default will be selected, if the script is triggered automatically. Note |
---|
| A build with newly added parameters will always fail for the first time, because Jenkins needs the first run to add the parameters to the pipeline configuration. |
|
stages {
stage('Build') {
[...]
}
}
| In section stages, you can define named build stages. If the processing of one stage fails, the subsequent stages will not be processed. |
steps {
dir('Advanced Modeling/E2ELibrary') {
bat """
java -jar ${E2ECXUMLC} -uml uml/librarySQLQuery.xml
copy repository\\librarySQLQuery\\librarySQLQuery.lrep libs\\
java -jar ${E2ECXUMLC} -uml uml/useLibrarySQLQuery.xml
"""
archiveArtifacts artifacts: 'repository/useLibrarySQLQuery/UseE2ELibraryExample.rep'
}
| In section steps, you can define the tasks to process in this stage, e.g. |
java -jar ${E2ECXUMLC} -uml uml/librarySQLQuery.xml
| Call the E2E xUML Command Line Compiler. The location of the compiler is specified via a Jenkins parameter (see above). |
copy repository\\librarySQLQuery\\librarySQLQuery.lrep libs\\
| Copy the compiled library repository to the libs folder of the project, so it will be used when compiling the usage model. For more details, see Compiling Libraries and Library Usage Models. |
e2ebridge deploy E2ELibrary/repository/useLibrarySQLQuery/UseE2ELibraryExample.rep -h <Bridge host> -u <user> -P <password> -o overwrite
| Call the E2E Bridge CLI to deploy the compiled service to an E2E a Bridge. |
dir('Advanced Modeling') {
bat """
java -jar ${REGTEST} -project PState -suite "QA Tests/Tests" -logfile result.xml -host <Bridge host> -port <port> -username <user> -password <password>
"""
} | Call the E2E RegTestRunner to perform regression tests on the newly deployed service. The location of the RegTestRunner is specified via a Jenkins parameter (see above). |
...
Task | Description |
---|
change service preferences | You can use the E2E Bridge CLI to change the preferences of a service, e.g. to set the flag for automatic startup: Code Block |
---|
e2ebridge preferences <service name> --pref.automaticStartup=true -u <user> -P <password> |
You can list all available preferences with Code Block |
---|
e2ebridge preferences <service name> -u <user> -P <password> |
|
change service settings | You can call the Bridge API with cURL to change the settings of a service: Code Block |
---|
curl -X PUT --header "Content-Type: application/json" --upload "<JSON settings file>" -G "https://localhost:8080/bridge/rest/services/xuml/<service name>/settings" -u <user>:<password> -k -v |
To execute this PUT, you need a JSON file that contains the complete definition of all service settings. You can obtain this by executing a GET on the settings of the servicesaving the results of this GET to a filemanipulating this file with the setting changes you want to send to the servicee2ebridge settings <service name> [-n|--nodejs] [set <setting name> <settings value>]... [Bridge connection] |
|