- 浏览: 2486243 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
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 260I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 429NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 310Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 321Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 291Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 378Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 373Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 325Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 397VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 334Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 415NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 359Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 290Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 207GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 390GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 274GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 263Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 259Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 250Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 233Serverless with NodeJS and Tenc ...
相关推荐
开发项目必备的环境变量配置,其中包含java/maven/tomcat环境变量配置
jenkins的maven工具jenkins的maven工具 jenkins的maven工具 jenkins的maven工具 jenkins的maven工具 jenkins的maven工具jenkins的maven工具
第一步:docker search jenkins,找到评星最多的官方镜像,pull后创建容器,没想到无法启动,无奈放弃,选用第二个jenkins/jenkins,此为第一个坑:-( 第二步:创建容器: 新建目录 /data/jenkins_home,然后 ...
jenkins用于持续集成git中的maven工程,此时需要添加git-plugin插件。在线安装慢,从官网下载很慢。所以提供给大家。
jenkins实现maven项目自动部署到tomcat 实现自动部署,
Jenkinsfile调用jdk命令和maven或grandle编译命令工具配置
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/
4.Jenkins持续集成Maven讲解4.Jenkins持续集成Maven讲解
通过Jenkins完成docker的容器升级,镜像打包,上传仓库
maven、Java、vue、git等插件全部都有 下载后解压复制到 jenkins安装根目录下的plugins文件夹,重启jenkins即可使用
帮助测试人员搭建jenkins+testng+reportng+maven+java环境
Jenkins从安装到自动部署maven项目,包学会
Jmeter+Jenkins+maven接口自动化集成,超详细,环境大家围观
aws-codebuild-jenkins-plugin, 一个插件,允许Jenkins用户使用 AWS CodeBuild运行一个构建 AWS CodeBuild插件Jenkins CodeBuild插件为Jenkins项目提供了一个构建步骤。 设置 Jenkins我们已经写了一个博客帖子,以...
通过 Yum 安装 Jenkins 一、安装 # yum 源导入 wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo # 导入密钥 rpm --import ...
将压缩文件解压到 /var/lib/jenkins/plugins/ 执行命令 systemctl restart jenkins 重启jenkin服务即可
maven2 用于hudson插件开发的jar
jenkins2.138.1与maven3.5.0与Dockerfile, 还需要jdk1.8和tomcat8,由于上传大小限制,放在了另一个资源里 https://download.csdn.net/download/sdfiiiiii/10693805
maven_local_repositorymaven_local_repositorymaven_local_repositorymaven_local_repositorymaven_local_repositorymaven_local_repositorymaven_local_repositorymaven_local_repositorymaven_local_...
Windows平台搭建Jenkins+maven+git/github实现自动发布已经越过几道坑