- 浏览: 2539921 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Jenkins Configuration(2)Build Enviroment with maven/ivy
1. Some Linux Commands
1.1 tee
append the console output to file
-a append the file
eg:
>echo " " | tee -a $BUILD_HOME/logs/all.log
1.2 cp
cp file and directory
-f --force
-p --preserve keep the information of the file and directory
-r do the same things to the sub directory
eg:
>cp -pfr directory1 directory2
2. Build the Project with Maven
I should have this kind of confirmation in my pom.xml.
<distributionManagement>
<repository>
<id>central</id>
<name>libs-snapshot-local</name>
<url>http://some.server.com/artifactory/libs-snapshot-local</url>
</repository>
</distributionManagement>
And set the username and password in settings.xml
<servers>
<server>
<id>central</id>
<username>builder</username>
<password>password</password>
</server>
<server>
<id>snapshots</id>
<username>builder</username>
<password>password</password>
</server>
</servers>
When I execute the maven command as follow:
>clean source:jar package deploy:deploy --update-snapshots
The package will deploy to my artifactory.
Uploaded: http://some.server.com/artifactory/libs-snapshot-local/com/sillycat/1.0.1-SNAPSHOT/somclass.jar
3. Build the Project with Ivy
Here are the configuration in build.xml:
<propertyname="ivy.install.version"value="2.2.0"/>
<propertyname="ivy.home"value="${user.home}/.ant"/>
<propertyname="ivy.jar.dir"value="${ivy.home}/lib"/>
<propertyname="ivy.jar.file"value="${ivy.jar.dir}/ivy.jar"/>
<ivy:settingsfile="${store.dir}/ivy.settings.xml"/>
<ivy:resolvefile="${store.dir}/ivy.xml"/>
<taskdefresource="org/apache/ivy/ant/antlib.xml"uri="antlib:org.apache.ivy.ant"classpath="${ivy.jar.file}"/>
<targetname="download-ivy"]]>
<mkdirdir="${ivy.jar.dir}"/>
<getsrc="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"dest="${ivy.jar.file}"usetimestamp="true"/>
</target]]>
<!-- ================================= target: resolve ================================= -->
<targetname="resolve"depends="download-ivy"description="--> retreive dependencies with ivy"]]>
<ivy:retrievepattern="${deploy.dir}/lib/[artifact]-[revision].[ext]"type="jar,bundle"sync="true"/>
</target]]>
<!-- ================================= target: clean-cache ================================= -->
<targetname="clean-cache-lib"description="--> clean the ivy cache"]]>
<deletedir="${ivy.home}/cache"/>
</target]]>
<targetname="publish"depends="download-ivy"description="publish package to artifactory"]]>
<ivy:publishresolver="sillycat-snapshots"forcedeliver="true"overwrite="true"publishivy="false"]]>
<artifactspattern="${deploy.dir}/[artifact].[ext]"/>
</ivy:publish]]>
</target]]>
I can run the command to manage the jar package
>ant resolve
I can run the command to push my release package to artifactory
>ant publish
Here are the configuration in ivy.settings.xml:
<ivysettings]]>
<settingsdefaultResolver="main"/>
<credentialshost="repository.sillycat.com"realm="ArtifactoryRealm"username="builder"passwd="password"/>
<propertyname="sillycat-snapshots"value="http://repository.sillycat.com/artifactory/libs-snapshot-local"/>
<resolvers]]>
<chain name="main"returnFirst="true"]]>
<filesystem name="libraries"]]>
<artifact pattern="${ivy.conf.dir}/lib/[artifact]-[revision].[type]"/>
</filesystem]]>
<ibiblio name="ibiblio" m2compatible="true"/>
<ibiblio name="java-net-maven1"root="http://download.java.net/maven/1"pattern="${java.net.maven.pattern}"m2compatible="false"/>
<ibiblio name="java-net-maven2"root="http://download.java.net/maven/2/"m2compatible="true"/>
<ibiblio name="sillycat-snapshots"m2compatible="true"root="${sillycat-snapshots}"/>
</chain]]>
</resolvers]]>
</ivysettings]]>
And my ivy.xml will be like this:
<ivy-module version="2.0"]]>
<info organisation="com.sillycat.stores" module="storename" revision="1.0.0-SNAPSHOT"/>
<configurations]]>
<conf name="sillycat-snapshots"/>
<conf name="compile"/>
<conf name="runtime" extends="compile"/>
</configurations]]>
<publications]]>
<artifact type="war" ext="war"conf="sillycat-snapshots"/>
</publications]]>
<dependencies]]>
<dependencyorg="commons-lang"name="commons-lang"rev="2.4"conf="runtime->default"/>
<dependencyorg="net.sf.dozer"name="dozer"rev="5.2.1"conf="runtime->default"]]>
<excludeorg="commons-logging"name="commons-logging"/>
<excludeorg="org.springframework"name="spring"/>
<excludeorg="commons-beanutils"name="commons-beanutils"/>
</dependency]]>
<dependencyorg="org.freemarker"name="freemarker"rev="2.3.15"conf="runtime->default"/>
<dependencyorg="ognl"name="ognl"rev="2.7.3"conf="runtime->default"]]>
<excludeorg="jboss"name="javassist"/>
</dependency]]>
<dependencyorg="org.hamcrest"name="hamcrest-core"rev="1.1"]]>
<excludeorg="jmock"name="jmock"/>
<excludeorg="org.easymock"name="easymock"/>
<excludeorg="junit"name="junit"/>
</dependency]]>
</dependencies]]>
</ivy-module]]>
Every thing works fine on my local machine. But on the server I got this error message.
Error Message:
Problem: failed to create task or type antlib:org.apache.ivy.ant:settings
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet
Solution:
>wget http://archive.apache.org/dist/ant/ivy/2.2.0/apache-ivy-2.2.0-bin.tar.gz
>tar zxvf apache-ivy-2.2.0-bin.tar.gz
>cd apache-ivy-2.2.0
>cp ./ivy-2.2.0.jar /opt/apache-ant-1.8.1/lib/
It is working now.
When you want to resolve the war package from artifactory. Do like this:
<dependency org="com.sillycat.stores" name="storename" rev="1.0.0-SNAPSHOT"conf="runtime->default"]]>
<artifact name="storename" type="war"/>
</dependency]]>
And change the build.xml statements like this:
<target name="resolve" depends="download-ivy" description="--> retreive dependencies with ivy"]]>
<ivy:retrieve pattern="${basedir}/war/[artifact]-[revision].[ext]" type="war,jar,bundle"sync="true"/>
</target]]>
4. Some Tips in Jenkins
Poll SCM using this pattern * * * * *
Execute the maven command base on this >clean source:jar package deploy:deploy --update-snapshots
Trigger another project base on this configuration:
Post-build Actions---> Build other projects ----> Trigger only if build succeeds
Only get the dependency from this maven command >clean dependency:copy-dependencies
Execute the shell script here:
Build ----> Execute shell --->
Command ----> chmod 755 * .; ./some-shell.sh
references:
http://hi.baidu.com/hongszh/item/ae48d648ea62190be93504ee
http://www.2cto.com/os/201112/113221.html
http://www.ningoo.net/html/2007/shell_scripts_stderr_stdout.html
ivy
https://support.sonatype.com/entries/21612333-how-do-i-configure-my-ivy-build-to-publish-artifacts-to-nexus
http://sillycat.iteye.com/blog/564051
http://sillycat.iteye.com/blog/611299
http://www.draconianoverlord.com/2010/07/18/publishing-to-maven-repos-with-ivy.html
1. Some Linux Commands
1.1 tee
append the console output to file
-a append the file
eg:
>echo " " | tee -a $BUILD_HOME/logs/all.log
1.2 cp
cp file and directory
-f --force
-p --preserve keep the information of the file and directory
-r do the same things to the sub directory
eg:
>cp -pfr directory1 directory2
2. Build the Project with Maven
I should have this kind of confirmation in my pom.xml.
<distributionManagement>
<repository>
<id>central</id>
<name>libs-snapshot-local</name>
<url>http://some.server.com/artifactory/libs-snapshot-local</url>
</repository>
</distributionManagement>
And set the username and password in settings.xml
<servers>
<server>
<id>central</id>
<username>builder</username>
<password>password</password>
</server>
<server>
<id>snapshots</id>
<username>builder</username>
<password>password</password>
</server>
</servers>
When I execute the maven command as follow:
>clean source:jar package deploy:deploy --update-snapshots
The package will deploy to my artifactory.
Uploaded: http://some.server.com/artifactory/libs-snapshot-local/com/sillycat/1.0.1-SNAPSHOT/somclass.jar
3. Build the Project with Ivy
Here are the configuration in build.xml:
<propertyname="ivy.install.version"value="2.2.0"/>
<propertyname="ivy.home"value="${user.home}/.ant"/>
<propertyname="ivy.jar.dir"value="${ivy.home}/lib"/>
<propertyname="ivy.jar.file"value="${ivy.jar.dir}/ivy.jar"/>
<ivy:settingsfile="${store.dir}/ivy.settings.xml"/>
<ivy:resolvefile="${store.dir}/ivy.xml"/>
<taskdefresource="org/apache/ivy/ant/antlib.xml"uri="antlib:org.apache.ivy.ant"classpath="${ivy.jar.file}"/>
<targetname="download-ivy"]]>
<mkdirdir="${ivy.jar.dir}"/>
<getsrc="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"dest="${ivy.jar.file}"usetimestamp="true"/>
</target]]>
<!-- ================================= target: resolve ================================= -->
<targetname="resolve"depends="download-ivy"description="--> retreive dependencies with ivy"]]>
<ivy:retrievepattern="${deploy.dir}/lib/[artifact]-[revision].[ext]"type="jar,bundle"sync="true"/>
</target]]>
<!-- ================================= target: clean-cache ================================= -->
<targetname="clean-cache-lib"description="--> clean the ivy cache"]]>
<deletedir="${ivy.home}/cache"/>
</target]]>
<targetname="publish"depends="download-ivy"description="publish package to artifactory"]]>
<ivy:publishresolver="sillycat-snapshots"forcedeliver="true"overwrite="true"publishivy="false"]]>
<artifactspattern="${deploy.dir}/[artifact].[ext]"/>
</ivy:publish]]>
</target]]>
I can run the command to manage the jar package
>ant resolve
I can run the command to push my release package to artifactory
>ant publish
Here are the configuration in ivy.settings.xml:
<ivysettings]]>
<settingsdefaultResolver="main"/>
<credentialshost="repository.sillycat.com"realm="ArtifactoryRealm"username="builder"passwd="password"/>
<propertyname="sillycat-snapshots"value="http://repository.sillycat.com/artifactory/libs-snapshot-local"/>
<resolvers]]>
<chain name="main"returnFirst="true"]]>
<filesystem name="libraries"]]>
<artifact pattern="${ivy.conf.dir}/lib/[artifact]-[revision].[type]"/>
</filesystem]]>
<ibiblio name="ibiblio" m2compatible="true"/>
<ibiblio name="java-net-maven1"root="http://download.java.net/maven/1"pattern="${java.net.maven.pattern}"m2compatible="false"/>
<ibiblio name="java-net-maven2"root="http://download.java.net/maven/2/"m2compatible="true"/>
<ibiblio name="sillycat-snapshots"m2compatible="true"root="${sillycat-snapshots}"/>
</chain]]>
</resolvers]]>
</ivysettings]]>
And my ivy.xml will be like this:
<ivy-module version="2.0"]]>
<info organisation="com.sillycat.stores" module="storename" revision="1.0.0-SNAPSHOT"/>
<configurations]]>
<conf name="sillycat-snapshots"/>
<conf name="compile"/>
<conf name="runtime" extends="compile"/>
</configurations]]>
<publications]]>
<artifact type="war" ext="war"conf="sillycat-snapshots"/>
</publications]]>
<dependencies]]>
<dependencyorg="commons-lang"name="commons-lang"rev="2.4"conf="runtime->default"/>
<dependencyorg="net.sf.dozer"name="dozer"rev="5.2.1"conf="runtime->default"]]>
<excludeorg="commons-logging"name="commons-logging"/>
<excludeorg="org.springframework"name="spring"/>
<excludeorg="commons-beanutils"name="commons-beanutils"/>
</dependency]]>
<dependencyorg="org.freemarker"name="freemarker"rev="2.3.15"conf="runtime->default"/>
<dependencyorg="ognl"name="ognl"rev="2.7.3"conf="runtime->default"]]>
<excludeorg="jboss"name="javassist"/>
</dependency]]>
<dependencyorg="org.hamcrest"name="hamcrest-core"rev="1.1"]]>
<excludeorg="jmock"name="jmock"/>
<excludeorg="org.easymock"name="easymock"/>
<excludeorg="junit"name="junit"/>
</dependency]]>
</dependencies]]>
</ivy-module]]>
Every thing works fine on my local machine. But on the server I got this error message.
Error Message:
Problem: failed to create task or type antlib:org.apache.ivy.ant:settings
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet
Solution:
>wget http://archive.apache.org/dist/ant/ivy/2.2.0/apache-ivy-2.2.0-bin.tar.gz
>tar zxvf apache-ivy-2.2.0-bin.tar.gz
>cd apache-ivy-2.2.0
>cp ./ivy-2.2.0.jar /opt/apache-ant-1.8.1/lib/
It is working now.
When you want to resolve the war package from artifactory. Do like this:
<dependency org="com.sillycat.stores" name="storename" rev="1.0.0-SNAPSHOT"conf="runtime->default"]]>
<artifact name="storename" type="war"/>
</dependency]]>
And change the build.xml statements like this:
<target name="resolve" depends="download-ivy" description="--> retreive dependencies with ivy"]]>
<ivy:retrieve pattern="${basedir}/war/[artifact]-[revision].[ext]" type="war,jar,bundle"sync="true"/>
</target]]>
4. Some Tips in Jenkins
Poll SCM using this pattern * * * * *
Execute the maven command base on this >clean source:jar package deploy:deploy --update-snapshots
Trigger another project base on this configuration:
Post-build Actions---> Build other projects ----> Trigger only if build succeeds
Only get the dependency from this maven command >clean dependency:copy-dependencies
Execute the shell script here:
Build ----> Execute shell --->
Command ----> chmod 755 * .; ./some-shell.sh
references:
http://hi.baidu.com/hongszh/item/ae48d648ea62190be93504ee
http://www.2cto.com/os/201112/113221.html
http://www.ningoo.net/html/2007/shell_scripts_stderr_stdout.html
ivy
https://support.sonatype.com/entries/21612333-how-do-i-configure-my-ivy-build-to-publish-artifacts-to-nexus
http://sillycat.iteye.com/blog/564051
http://sillycat.iteye.com/blog/611299
http://www.draconianoverlord.com/2010/07/18/publishing-to-maven-repos-with-ivy.html
发表评论
-
Stop Update Here
2020-04-28 09:00 310I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 467NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 361Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 363Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 328Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 419Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 428Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 364Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 444VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 376Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 464NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 413Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 330Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 242GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 443GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 320GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 306Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 310Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 285Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 302Serverless with NodeJS and Tenc ...
相关推荐
开发项目必备的环境变量配置,其中包含java/maven/tomcat环境变量配置
2. 在Jenkins管理界面手动上传插件并安装。 3. 配置Git全局设置和SSH密钥。 4. 配置Maven全局工具。 5. 创建Jenkins作业,设置构建触发器和Maven目标。 通过以上步骤,你可以成功地在Jenkins中集成Git和Maven,实现...
jenkins 2.346.1,jdk8 适用 git maven ssh插件
2、启用Jenkins存储库。运行以下命令下载并导入GPG密钥 sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo sudo rpm –import https://jenkins-ci.org/
Jenkinsfile 调用 JDK 命令和 Maven 或 Gradle 编译命令工具配置 Jenkinsfile 调用 JDK 命令和 Maven 或 Gradle 编译命令工具配置 在 Jenkins pipeline 中,我们经常需要使用 JDK 命令和 Maven 或 Gradle 编译命令...
jenkins的maven工具jenkins的maven工具 jenkins的maven工具 jenkins的maven工具 jenkins的maven工具 jenkins的maven工具jenkins的maven工具
在大多数Linux系统中,该目录为`/var/lib/jenkins/plugins`。确保你有足够的权限执行此操作,如果没有,可能需要以root身份或者使用sudo执行。 3. **重启Jenkins服务**: 完成解压后,需要重启Jenkins服务以加载新...
### Jenkins 实现 Maven 项目自动部署到 Tomcat 在当今快速发展的软件开发环境中,持续集成(CI)与持续部署(CD)已经成为不可或缺的部分。本文将详细介绍如何利用 Jenkins 实现 Maven 项目的自动部署到 Tomcat ...
jenkins+testng+reportng+maven+java环境搭建 本文将指导测试人员搭建jenkins+testng+reportng+maven+java环境,涵盖了Eclipse环境准备、Maven配置、TestNG插件安装、ReportNG报告引入等内容。 一、Eclipse 环境...
- **Build配置**: 指定Maven命令(如`install`、`package`等)。 - **构建后操作**: 选择`Deploy war/ear to a container`,以部署到Tomcat容器中。 **注意事项**: - **坑1**: 确保Git配置正确,尤其是指向`.exe`...
第一步:docker search jenkins,找到评星最多的官方镜像,pull后创建容器,没想到无法启动,无奈放弃,选用第二个jenkins/jenkins,此为第一个坑:-( 第二步:创建容器: 新建目录 /data/jenkins_home,然后 ...
### Jenkins、Maven与Git在CentOS上的持续集成与自动化部署 #### 一、环境搭建概述 本篇文章主要介绍如何在CentOS系统上通过Jenkins、Maven与Git实现持续集成(CI)与自动化部署的过程。Jenkins作为CI/CD流水线的...
【Jenkins持续集成Maven讲解】 在现代软件开发过程中,持续集成(Continuous Integration,简称CI)扮演着至关重要的角色。Jenkins作为一款广泛使用的开源持续集成工具,它可以帮助开发团队快速、频繁地集成代码,...
jenkins用于持续集成git中的maven工程,此时需要添加git-plugin插件。在线安装慢,从官网下载很慢。所以提供给大家。
在“maven2 用于hudson插件开发的jar”这个场景中,我们可以推断这是关于使用Maven2版本来构建Jenkins(前身Hudson)插件的实践。开发者可能需要在他们的环境中安装特定的Maven插件,如`maven-hpi-plugin`,这个插件...
解决jenkins 升级后报:FATAL: org/apache/commons/digester/Digester java.lang.ClassNotFoundException: org.apache.commons.digester.Digester 的问题
2. **配置Maven**:在Jenkins的构建环境中,指定Maven的路径并添加任何必要的Maven配置,如pom.xml文件的位置、构建目标等。例如,可以使用`mvn clean install`命令进行构建。 3. **连接Gitlab**:在Gitlab项目中...
【Jmeter+Jenkins+maven接口自动化集成】 接口自动化测试是现代软件开发中不可或缺的一环,它可以有效地提高测试效率,确保系统的稳定性和可靠性。在这个项目中,我们将利用JMeter、Jenkins和Maven三个强大的工具...