Commit e13304bf authored by Adrien's avatar Adrien Committed by Romain Bioteau

feat(codesign) provide a zip archive to install the codesign application as a windows service (#7)

* document in the readme how to install the apps as a service
* add a zip archive which contains the artifacts used to install the app as a service
* use the gradle distribution plugin to create a zip at the end of the build, which contains all the artifacts needed to install the application as a service
parent a7376013
......@@ -17,7 +17,7 @@ node {
sh './gradlew clean build'
} finally {
junit '**/build/test-results/**/*.xml'
archiveArtifacts '**/build/libs/*.jar'
archiveArtifacts '**/build/distributions/*.zip'
}
}
......
......@@ -20,7 +20,13 @@ Provide a REST endpoint used by our CI to sign windows binaries with our EV Cert
## Retrieve and start the latest version
* Go to our [Artifactory](http://repositories.rd.lan/maven/releases/org/bonitasoft/releng/bonita-codesign-windows/) to retrieve the latest tag
* Go to our [Artifactory](http://repositories.rd.lan/maven/releases/org/bonitasoft/releng/bonita-codesign-windows/) to retrieve the latest tag (zip archive)
* Extract the bonita-codesign-windows jar
* Start the service using cmd : `java -jar path/to/bonita-codesign-windows-<version>.jar`
* Make sure the service is started on 8080 port as the URL on the CI are configured on this port.
* The endpoint should available at `http://codesign.rd.lan:8080/sign`, it accepts `POST` method with a parameter `exeFile`
\ No newline at end of file
* The endpoint should available at `http://codesign.rd.lan:8080/sign`, it accepts `POST` method with a parameter `exeFile`
## Install the codesign application as a windows service
* Go to our [Artifactory](http://repositories.rd.lan/maven/releases/org/bonitasoft/releng/bonita-codesign-windows/) to retrieve the latest tag (zip archive)
* Unzip it, and follow the instructions in the provided readme
\ No newline at end of file
......@@ -4,8 +4,8 @@ buildscript {
ext.kotlin_version = '1.2.40' // Required for Kotlin integration
ext.spring_boot_version = '2.0.1.RELEASE'
repositories {
jcenter()
maven { url 'http://repositories.rd.lan/maven/all/' }
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // Required for Kotlin integration
......@@ -22,6 +22,7 @@ apply plugin: "kotlin-spring" // See https://kotlinlang.org/docs/reference/compi
apply plugin: "org.springframework.boot"
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'maven-publish'
apply plugin: 'distribution'
group = 'org.bonitasoft.releng'
......@@ -32,11 +33,14 @@ junitPlatform {
}
repositories {
jcenter()
maven { url 'http://repositories.rd.lan/maven/all/' }
jcenter()
maven { url 'http://repository.jetbrains.com/all' }
maven { url 'http://repo.jenkins-ci.org/releases'}
}
configurations { mypackaging }
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
......@@ -47,6 +51,36 @@ dependencies {
testCompile 'org.jetbrains.spek:spek-junit-platform-engine:1.1.5'
testCompile 'org.junit.platform:junit-platform-runner:1.0.0'
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
mypackaging "com.sun.winsw:winsw:2.1.2:bin@exe"
}
task createServiceConfigurationFile (type: ConfigureBonitaCodesignXmlTask) {
def separator = System.getProperty("file.separator")
xmlFile = [buildDir, 'distributions', 'bonitaCodesign.xml'].join(separator)
argument = "-jar \"bonita-codesign-windows-" + project.version + ".jar\""
}
distZip {
dependsOn(bootJar, createServiceConfigurationFile)
doLast {
def xmlFile = [buildDir, 'distributions', 'bonitaCodesign.xml'].join(System.getProperty("file.separator"))
delete file(xmlFile)
}
}
distributions {
main {
contents {
def xmlFile = [buildDir, 'distributions', 'bonitaCodesign.xml'].join(System.getProperty("file.separator"))
from configurations.mypackaging
from {project.bootJar.outputs.files.first()}
from file(xmlFile)
rename (configurations.mypackaging.resolvedConfiguration.resolvedArtifacts.first().file.getName(), 'bonitaCodesign.exe')
}
}
}
spotless {
......@@ -75,7 +109,7 @@ publishing {
}
publications {
bootJava(MavenPublication) { artifact bootJar }
bootJava(MavenPublication) { artifact distZip }
}
}
......@@ -84,4 +118,25 @@ processResources {
include '*.txt'
filter(ReplaceTokens, tokens: [version: project.version])
}
}
class ConfigureBonitaCodesignXmlTask extends DefaultTask {
def xmlFile
def argument
@TaskAction
def addArgument() {
File file = new File(xmlFile)
file.createNewFile()
file.text ="""<service>
<id>bonita-codesign</id>
<name>Bonita codesign</name>
<description>This service runs the Bonita codesign windows application.</description>
<executable>java</executable>
<arguments>$argument</arguments>
</service>
"""
}
}
\ No newline at end of file
Install the codesign application as a service
* This zip archive contains the code signing jar, the executable 'bonitaCodesign.exe' and the xml configuration 'bonitaCodesign.xml'. The executable and the xml are used to install the service.
* Put the codesign jar, the exe file and the xml file in a given folder (the three files in the same folder).
* From a command line interface, run the following commands (It requires administrator rights): bonitaCodesign.exe install
* Go to the service pannel in the task manager, you should see your service in the service list. If so, then the service is now installed, and will be launched each time the system restart.
* After the install, the service isn't started. You can either restart the system or run the following command: bonitaCodesign.exe start
* Log files are be generated in the folder containing the jar, the exe and the xml
* You can find more details about the usage of the service here: https://github.com/kohsuke/winsw
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment