lili
This commit is contained in:
parent
f067d2c0c2
commit
2fd55c56eb
|
@ -0,0 +1,105 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<artifactId>jenkins</artifactId>
|
||||
<groupId>cn.guange.app</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>jenkins-exec</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>jenkins-exec</name>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer>
|
||||
<resource>META-INF/spring.handlers</resource>
|
||||
</transformer>
|
||||
<transformer>
|
||||
<resource>META-INF/spring.schemas</resource>
|
||||
</transformer>
|
||||
<transformer>
|
||||
<mainClass>cn.guange.app.jenkins.App</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.tomcat.maven</groupId>
|
||||
<artifactId>tomcat7-maven-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<configuration>
|
||||
<address>0.0.0.0</address>
|
||||
<port>9001</port>
|
||||
<path>/</path>
|
||||
<uriEncoding>UTF-8</uriEncoding>
|
||||
<finalName>jenkins-exec</finalName>
|
||||
<server>tomcat7</server>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>testCompile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-api</artifactId>
|
||||
<version>7.0</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,178 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.guange.app</groupId>
|
||||
<artifactId>jenkins</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
|
||||
<artifactId>jenkins-exec</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>jenkins-exec</name>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.guange.app</groupId>
|
||||
<artifactId>jenkins-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.20</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
|
||||
<resource>META-INF/spring.handlers</resource>
|
||||
</transformer>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
|
||||
<resource>META-INF/spring.schemas</resource>
|
||||
</transformer>
|
||||
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>cn.guange.app.jenkins.App</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.tomcat.maven</groupId>
|
||||
<artifactId>tomcat7-maven-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<configuration>
|
||||
<address>0.0.0.0</address>
|
||||
<port>9001</port>
|
||||
<path>/</path>
|
||||
<uriEncoding>UTF-8</uriEncoding>
|
||||
<finalName>jenkins-exec</finalName>
|
||||
<server>tomcat7</server>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>testCompile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
|
||||
|
||||
|
||||
<context:annotation-config></context:annotation-config>
|
||||
<context:component-scan base-package="com.educoder.jenkins.api"/>
|
||||
<context:component-scan base-package="com.educoder.jenkins.settings"/>
|
||||
<context:component-scan base-package="com.educoder.jenkins.controller"/>
|
||||
|
||||
<!--导入配置-->
|
||||
<context:property-placeholder location="classpath:config.properties"/>
|
||||
</beans>
|
|
@ -0,0 +1,16 @@
|
|||
# trustieUrl=http://www.trustie.net/callback
|
||||
# trustieUrl=http://ucloudtest.trustie.net/shixuns/training_task_status
|
||||
|
||||
trustieUrl=http://192.168.0.238:8888/myshixuns/training_task_status
|
||||
|
||||
#jenkinsUrl
|
||||
#jenkinsUrl=http://localhost:8080/
|
||||
#jenkisUserName=admin
|
||||
#jenkisPassWord=wang199637
|
||||
jenkinsUrl=http://123.59.135.74:9999/jenkins
|
||||
jenkisUserName=guange
|
||||
jenkisPassWord=123456
|
||||
#jenkinsUrl=http://192.168.0.238:9999
|
||||
#jenkisUserName=guange
|
||||
#jenkisPassWord=123456
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
if (nowStep == STEP) {
|
||||
// 读取输入和预期输出
|
||||
def in = readFile '/home/pdl/.jenkins/workspace/testCases/SHIXUNID_STEP_In'
|
||||
def expectedOut = readFile '/home/pdl/.jenkins/workspace/testCases/SHIXUNID_STEP_Out'
|
||||
|
||||
// 编译程序
|
||||
sh script: 'echo "$(javac FILEPATH 2>&1)" > compile_result.txt'
|
||||
compileResult = readFile ('compile_result.txt')
|
||||
|
||||
// 如果编译错误
|
||||
if (compileResult.trim() == '') {
|
||||
postResultToBDWeb(compileResult: compileResult, out: '', in:in, expectedOut:expectedOut)
|
||||
return ;
|
||||
}
|
||||
|
||||
// 从in.txt读入,程序运行输出重定向到out.txt
|
||||
sh script: 'echo "$(java SOURCECLASSNAME < /home/pdl/.jenkins/workspace/testCases/SHIXUNID_STEP_In 2>&1)" > out.txt'
|
||||
def out = readFile "out.txt"
|
||||
|
||||
// 由中间层判断结果之后发送给BDWeb
|
||||
postResultToBDWeb(compileResult: compileResult, out: out, in:in, expectedOut:expectedOut)
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
node() {
|
||||
git url: gitUrl
|
||||
|
||||
withDockerContainer(language) {
|
||||
def nowStep = Integer.parseInt(step)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 传送运行结果到BDWeb
|
||||
def postResultToBDWeb(def arg){
|
||||
def s = 'compileResult=' + arg.compileResult + '&out=' + arg.out +
|
||||
'&in=' + arg.in + '&expectedOut=' + arg.expectedOut
|
||||
def response = httpRequest acceptType: 'APPLICATION_JSON_UTF8', consoleLogResponseBody: true, contentType: 'APPLICATION_FORM',
|
||||
httpMode: 'POST', requestBody: s, url: "http://123.59.135.74:9999/jenkins-exec/pipeline/call?taskId=${taskId}"
|
||||
|
||||
if (response.status==299){
|
||||
error response.content
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<flow-definition plugin="workflow-job@2.10">
|
||||
<actions/>
|
||||
<description></description>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<properties>
|
||||
<hudson.model.ParametersDefinitionProperty>
|
||||
<parameterDefinitions>
|
||||
PARAMS_CONTENT
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
<org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
|
||||
<triggers/>
|
||||
</org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
|
||||
</properties>
|
||||
<definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="workflow-cps@2.26">
|
||||
<script>PIPELINE_CONTENT</script>
|
||||
<sandbox>false</sandbox>
|
||||
</definition>
|
||||
<triggers/>
|
||||
</flow-definition>
|
|
@ -0,0 +1,11 @@
|
|||
### 设置###
|
||||
log4j.rootLogger = debug,stdout
|
||||
|
||||
### 输出信息到控制抬 ###
|
||||
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target = System.out
|
||||
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
|
||||
#log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
|
||||
log4j.appender.stdout.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} %m%n
|
||||
|
||||
log4j.logger.org.springframework=INFO
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
|
||||
|
||||
|
||||
<!--指明 controller 所在包,并扫描其中的注解-->
|
||||
<context:component-scan base-package="cn.guange.app.jenkins.controller"/>
|
||||
|
||||
<!-- 静态资源(js、image等)的访问 -->
|
||||
<mvc:default-servlet-handler/>
|
||||
|
||||
<!-- 开启注解 -->
|
||||
<mvc:annotation-driven/>
|
||||
|
||||
<bean class="springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration" id="swagger2Config"/>
|
||||
<mvc:resources location="classpath:/META-INF/resources/" mapping="swagger-ui.html"/>
|
||||
<mvc:resources location="classpath:/META-INF/resources/webjars/" mapping="/webjars/**"/>
|
||||
|
||||
</beans>
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
|
||||
version="3.1">
|
||||
|
||||
<display-name>SpringMVCDemo Web Application</display-name>
|
||||
|
||||
<!-- Spring 上下文参数 -->
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>classpath:applicationContext.xml</param-value>
|
||||
</context-param>
|
||||
|
||||
<listener>
|
||||
<listener-class>
|
||||
org.springframework.web.context.ContextLoaderListener
|
||||
</listener-class>
|
||||
</listener>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>mvc-dispatcher</servlet-name>
|
||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>mvc-dispatcher</servlet-name>
|
||||
<url-pattern>/</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
<filter>
|
||||
<filter-name>encodingFilter</filter-name>
|
||||
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
|
||||
<init-param>
|
||||
<param-name>encoding</param-name>
|
||||
<param-value>UTF-8</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>forceEncoding</param-name>
|
||||
<param-value>true</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
<filter-name>encodingFilter</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
</web-app>
|
|
@ -0,0 +1 @@
|
|||
<meta http-equiv="refresh" content="0; url=/swagger-ui.html" />
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
|
||||
|
||||
|
||||
<context:annotation-config></context:annotation-config>
|
||||
<context:component-scan base-package="com.educoder.jenkins.api"/>
|
||||
<context:component-scan base-package="com.educoder.jenkins.settings"/>
|
||||
<context:component-scan base-package="com.educoder.jenkins.controller"/>
|
||||
|
||||
<!--导入配置-->
|
||||
<context:property-placeholder location="classpath:config.properties"/>
|
||||
</beans>
|
|
@ -0,0 +1,18 @@
|
|||
# trustieUrl=http://www.trustie.net/callback
|
||||
# trustieUrl=http://ucloudtest.trustie.net/shixuns/training_task_status
|
||||
|
||||
trustieUrl=http://192.168.0.238:8888/myshixuns/training_task_status
|
||||
|
||||
#jenkinsUrl
|
||||
#jenkinsUrl=http://localhost:8080/
|
||||
#jenkisUserName=admin
|
||||
#jenkisPassWord=wang199637
|
||||
#jenkinsUrl=http://106.75.33.219:30001
|
||||
#jenkisUserName=root
|
||||
#jenkisPassWord=root
|
||||
jenkinsUrl=http://123.59.135.74:9999/jenkins
|
||||
jenkisUserName=guange
|
||||
jenkisPassWord=123456
|
||||
#jenkinsUrl=http://106.75.78.183:8888
|
||||
#jenkisUserName=root
|
||||
#jenkisPassWord=root
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<flow-definition plugin="workflow-job@2.10">
|
||||
<actions/>
|
||||
<description></description>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<properties>
|
||||
<hudson.model.ParametersDefinitionProperty>
|
||||
<parameterDefinitions>
|
||||
PARAMS_CONTENT
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
<org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
|
||||
<triggers/>
|
||||
</org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
|
||||
</properties>
|
||||
<definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="workflow-cps@2.26">
|
||||
<script>PIPELINE_CONTENT</script>
|
||||
<sandbox>false</sandbox>
|
||||
</definition>
|
||||
<triggers/>
|
||||
</flow-definition>
|
|
@ -0,0 +1,11 @@
|
|||
### 设置###
|
||||
log4j.rootLogger = stdout
|
||||
|
||||
### 输出信息到控制抬 ###
|
||||
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target = System.out
|
||||
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
|
||||
#log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
|
||||
log4j.appender.stdout.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} %m%n
|
||||
|
||||
log4j.logger.org.springframework=INFO
|
|
@ -0,0 +1,3 @@
|
|||
node(){
|
||||
echo "helloworld"
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
import com.fasterxml.jackson.databind.*
|
||||
import java.io.*
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
node(){
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
||||
println("jenkins start build time:" + df.format(new Date()) + " taskId:" + taskId);
|
||||
Thread.sleep(10000);
|
||||
executeCmd(commitType:'commitSuccess',
|
||||
jsonTypeArg: '{"msg":"' + '1' + '", "outPut": "' + '1' + '"}')
|
||||
|
||||
println("jenkins build finished time:" + df.format(new Date()) + " taskId:" + taskId);
|
||||
}
|
||||
|
||||
|
||||
def executeCmd(def arg){
|
||||
def s = 'commitType=' + arg.commitType + "&jsonTypeArg=" + arg.jsonTypeArg
|
||||
println(s)
|
||||
def response = httpRequest acceptType: 'APPLICATION_JSON_UTF8', consoleLogResponseBody: true, contentType: 'APPLICATION_FORM',
|
||||
httpMode: 'POST', requestBody: s, url: "http://123.59.135.74:9999/jenkins-exec/pipeline/call?taskId=${taskId}"
|
||||
|
||||
if (response.status==299){
|
||||
error response.content
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
WEB-INF/classes/config.properties
|
|
@ -0,0 +1 @@
|
|||
rsync --stats --exclude-from="`pwd`/sync_exclude.list" --rsh=ssh -P -r target/jenkins-exec-1.0-SNAPSHOT/ jenkins:/home/pdl/apache-tomcat-8.5.11/webapps/jenkins-exec/
|
|
@ -107,6 +107,17 @@ public class JenkinsApi {
|
|||
job.build(buildParams);
|
||||
}
|
||||
|
||||
public void buildJob(String jobName, String taskId, String step, String gitUrl) throws IOException {
|
||||
JobWithDetails job = jenkins.getJob(jobName);
|
||||
Map<String, String> buildParams = new HashMap();
|
||||
buildParams.put("taskId", taskId);
|
||||
buildParams.put("step", step);
|
||||
buildParams.put("gitUrl", gitUrl);
|
||||
|
||||
job.build(buildParams);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取job的xml配置文件
|
||||
* @param jobName
|
||||
|
|
|
@ -32,9 +32,24 @@ public class JenkinsController {
|
|||
@Autowired
|
||||
JenkinsApi jenkinsApi;
|
||||
|
||||
@ApiOperation(value = "创建一个job", httpMethod = "POST", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||
@ApiOperation(value = "开始一个实训", httpMethod = "POST", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||
@ApiResponse(code = 200, message = "success", response = JSONObject.class)
|
||||
@RequestMapping(path="/createJob",method = RequestMethod.POST)
|
||||
@RequestMapping(path="/openGameTraining",method = RequestMethod.POST)
|
||||
public JSONObject openTrainingInstance(String jobNameForInstance, String gamePipelineScript, String InstanceGitURL){
|
||||
JSONObject response = new JSONObject();
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "保存输入输出到文件", httpMethod = "POST", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||
public JSONObject saveTestCases (String shixunId, String cases){
|
||||
|
||||
JSONObject response = new JSONObject();
|
||||
return response;
|
||||
}
|
||||
|
||||
// @ApiOperation(value = "创建一个job", httpMethod = "POST", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||
// @ApiResponse(code = 200, message = "success", response = JSONObject.class)
|
||||
// @RequestMapping(path="/createJob",method = RequestMethod.POST)
|
||||
public JSONObject createJob(@ApiParam(name = "jobName", required = true, value = "job的名字,不能重复") @RequestParam String jobName,
|
||||
@ApiParam(name = "pipeLine", required = true, value = "pipeLine脚本,用base64编码") @RequestParam String pipeLine,
|
||||
@ApiParam(name = "params", required = true, value = "job的参数,以json字符串的形式") @RequestParam String params){
|
||||
|
@ -70,6 +85,30 @@ public class JenkinsController {
|
|||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "构建一个job", httpMethod = "POST", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||
@RequestMapping(path="/buildJob")
|
||||
public JSONObject buildJob(@ApiParam(name = "jobName", required = true, value = "job的名字") @RequestParam String jobName,
|
||||
@ApiParam(name = "gitUrl", required = true, value = "学员对应当前实训版本库地址") @RequestParam String gitUrl,
|
||||
@ApiParam(name = "taskId", required = true, value = "本次评测ID") @RequestParam String taskId,
|
||||
@ApiParam(name = "step", required = true, value = "当前处在第几关") @RequestParam String step
|
||||
){
|
||||
JSONObject response = new JSONObject();
|
||||
try {
|
||||
logger.debug("调用[buildJob]: jobName=" + jobName + "taskId "+taskId+" step "+step+" gitUrl "+gitUrl);
|
||||
gitUrl = Base64Helper.decode(gitUrl);
|
||||
jenkinsApi.buildJob(jobName, taskId, step, gitUrl);
|
||||
}catch (Exception e){
|
||||
logger.error("buildJob", e);
|
||||
response.put("code", -1);
|
||||
response.put("msg", e.getMessage());
|
||||
return response;
|
||||
}
|
||||
|
||||
response.put("code", 0);
|
||||
response.put("msg", "run job success");
|
||||
return response;
|
||||
}
|
||||
/**
|
||||
@ApiOperation(value = "构建一个job", httpMethod = "POST", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||
@RequestMapping(path="/buildJob")
|
||||
public JSONObject buildJob(@ApiParam(name = "jobName", required = true, value = "job的名字") @RequestParam String jobName,
|
||||
|
@ -93,4 +132,5 @@ public class JenkinsController {
|
|||
response.put("msg", "run job success");
|
||||
return response;
|
||||
}
|
||||
**/
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue