Skip to content

Instantly share code, notes, and snippets.

@dyno
Last active January 18, 2019 03:32
Show Gist options
  • Save dyno/c2bce24dc89d667b9d2931c26e248392 to your computer and use it in GitHub Desktop.
Save dyno/c2bce24dc89d667b9d2931c26e248392 to your computer and use it in GitHub Desktop.
publish Pipfile.lock Poetry.lock as artifacts
logging.captureStandardOutput LogLevel.INFO
def nexusUsername = "builder"
def nexusPassword = 'password'
repositories {
maven {
name = "example-releases"
url 'https://nexus.example.com/nexus/content/repositories/releases'
credentials {
username "$nexusUsername"
password "$nexusPassword"
}
}
maven {
name = "example-snapshots"
url 'https://nexus.example.com/nexus/content/repositories/snapshots'
credentials {
username "$nexusUsername"
password "$nexusPassword"
}
}
}
// ---------------------------------------------------------------------------
configurations {
venv
}
dependencies {
// latest published CI-version
venv "${project.groupId}:${venvArtifactId}:CI-+"
}
task venvFileJar(type: Jar) {
from(".") {
include "Pipfile"
include "Pipfile.lock"
}
}
// publish: local -> nexus
publishing.publications {
mavenJar(MavenPublication) {
artifact venvFileJar
artifactId venvArtifactId
groupId project.groupId
version project.publicationVersion
}
}
// fetchJar: nexus -> local
task fetchJar(type:Copy) {
dependsOn configurations.venv
// Download published venv configurations if available.
from configurations.venv.resolvedConfiguration.lenientConfiguration.getFiles(Specs.satisfyAll()).collect {zipTree(it)}
into "tmp/"
doLast {
def ciPipfile = file("tmp/Pipfile")
def ciPipfileLock = file("tmp/Pipfile.lock")
def pipfile = file("Pipfile")
if (ciPipfile.exists() && ciPipfile.text == pipfile.text) {
println "Overwrite Pipfile.lock with CI one."
ciPipfileLock.renameTo("Pipfile.lock")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment