Gradle 如何将jar发布到NEXUS存储库
我想从Gradle项目中构建一个jar,并将其推送到nexus存储库。作为其中的一部分,我创建了一个Jenkins文件,并在build.gradle中添加了一个任务“publishing”任务 我的詹金斯档案:Gradle 如何将jar发布到NEXUS存储库,gradle,jenkins-pipeline,build.gradle,Gradle,Jenkins Pipeline,Build.gradle,我想从Gradle项目中构建一个jar,并将其推送到nexus存储库。作为其中的一部分,我创建了一个Jenkins文件,并在build.gradle中添加了一个任务“publishing”任务 我的詹金斯档案: pipeline { agent any environment { NEXUS = credentials('nexus-user') } options { ansiColor('xterm')
pipeline {
agent any
environment {
NEXUS = credentials('nexus-user')
}
options {
ansiColor('xterm')
buildDiscarder logRotator(daysToKeepStr: '30', numToKeepStr: '100')
}
triggers { pollSCM('H/5 * * * *') }
stages {
stage('Checkout'){
steps { checkout scm }
}
stage('Build') {
steps { sh "./gradlew assemble" }
}
stage('deploy') {
steps {
sh "gradle -Duser.home=\"$WORKSPACE\" --gradle-user-home=\"$WORKSPACE/.gradle\" -PnexusUsername=$NEXUS_USR -PnexusPassword=$NEXUS_PSW publish"
}
}
}
}
还有格雷德尔先生
publishing {
publications{
maven(MavenPublication){
artifactId = "testApp"
from components.java
}
}
repositories {
maven {
url = "http://localhost:8081/nexus/content/repositories/${version.endsWith('-SNAPSHOT') ? "snapshots" : "releases"}"
credentials {
username = "Dont know how to pass the username here"
password = "Dont know how to pass the password here"
}
}
}
}
谁能告诉我如何从Gradle获得用户名和密码,并在此处设置,以便将jar发布到nexus。答案是:
publishing {
publications{
maven(MavenPublication){
artifactId = "testApp"
from components.java
}
}
repositories {
maven {
url = "http://localhost:8081/nexus/content/repositories/${version.endsWith('-SNAPSHOT') ? "snapshots" : "releases"}"
credentials {
username = "nexusUsername"
password = "nexusPassword"
}
}
}
}