pipeline { agent any stages { stage('build') { steps { git credentialsId: 'fetch-dht-pull', url: 'git@git.keganmyers.com:terribleplan/fetch-dht.git' script { def kubeCa = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJd01ETXlNVEU0TkRrd05Wb1hEVE13TURNeE9URTRORGt3TlZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTklWClJoaDMzVVd2Yk4vS0VzZTFSY2tkM0R0VitmR251RC9yOVhmdU1BRThzaW9vT1gwQjVzcjdOVi9TWFA2dDB0ak8KQkRTRnJpODczejd0SWtMcktvNmFWNGpOcDdNUXNDbllydk9ob0EwWnJIdmpmbUljbFlXRnhwclNWWkFRZ1JpbgpiU2VRMkY2d3MwdnlTSjluMy8zTmV2RlRHT0V5WVBjWko0cGZCNjJnWkk5OFR6ZU9NWTV0QWJRQmJsRW0wdGx6ClVJSWJYTmhCVXNnWnZxU3dwTG5LMHorUVBsdkRRd0FLRCt6dmNmdlZaQk1tNGZ1bFprYkxHdGNUbUtBcVhQMWQKbGtkMUxYN205cEVoUDhKVGUvVW9WWWh5ZTRRNG0xbWQvTHgrNXJUTEg0TXBjYkV0dTR0MklPZjZTZ0l2WkJ0dwpIbnRuVG1HMTdQdjJUUzJ4WWEwQ0F3RUFBYU1qTUNFd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dFQkFBYkRpOXZNT085akN0WGU5WCtHNDZGdkpnVEgKMkVQb2NOUDdIcHZGNFYzQVd4eWRSaGZSK2o1eHRldG1sem5uNktjVE41WUVoenE2VXVGMlpPS1NjVUp0Yi8ydgpnQVhCTjF3SVdSZ0p2bWdVTTRLVVVwc1FpWjRsY0o1TS9IT1ByZmJrL21pdERzd01XZDlIVTZ3ZVN4NVJ6eVFGCmEvNVhtSGlSUTZRc1Q2SnovMGNIQmNCbjMwRkZCTzVudVdRMjRnVjNBTlE2NXUvUFhkalBwRExBT3d6bmV4QmYKRUZLMk1aNC9Nd0xNUjlDcGk3TWovWHUwVkxLTWhUWVVCSWQwQ0EwMllKems1RzVSbmpZVlRxWnp3L2QvaUVXQQpta1k3d1Y2d0tUV25jRDM1MVlmWjJtWGtGa293WGVDL1lHVVpEQmUza0hlQTJRVFFkMmEzMEt6dnpvOD0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=" def kubeUrl = "https://45.79.61.115:443" def appName = "fetch-dht" def kubectl = docker.image("bitnami/kubectl:1.18") def registryHost = "registry.terrible.network" def imageName = "${registryHost}/terribleplan/${appName}" def betaImageName = "${imageName}:beta" def betaAppName = "${appName}-beta" def betaHost = "${betaAppName}.terrible.network" def beta docker.withRegistry("https://${registryHost}", "registry-terrible-network") { beta = docker.build(betaImageName) beta.inside { sh "cp package.json /app/package.json" sh "cp yarn.lock /app/yarn.lock" sh "cd /app && yarn" sh "cd /app && ls" sh "cd /app/lib && ls" sh "cd /app/lib/binaryQuerystring && ls" sh "cd /app && node lib/binaryQuerystring/index.test.js" } beta.push() } kubectl.inside("--entrypoint=''") { env.NAMESPACE = betaAppName env.HOST = betaHost env.APP_NAME = betaAppName env.IMAGE = env.IMAGE_PULL_SECRET = "registry-terrible-network-pull-secret" sh "install_packages gettext" sh "set -euo pipefail" sh "mkdir -p ~/.kube" withCredentials([string(credentialsId: 'fetch-dht-beta-token', variable: 'token')]) { sh "cat deploy/kubeconfig.envsubst.yml | CA='${kubeCa}' URL='${kubeUrl}' TOKEN='${token}' envsubst '\$CA,\$URL,\$TOKEN,\$NAMESPACE' > ~/.kube/config" } sh "cat deploy/manifest.envsubst.yml | IMAGE='${beta.imageName()}' APP_NAME='${betaAppName}' REVISION='${env.GIT_COMMIT}' envsubst '\${NAMESPACE}' | kubectl apply -f -" sh "kubectl rollout status 'deployments/${betaAppName}'" } // def prodImageName = "${imageName}:latest" // beta.push(prodImageName) // beta.run("-e ENDPOINT=https://${betaHost}", "yarn && yarn integration") // latest = beta.tag("latest") // latest.push() // kubectl.inside { // env.NAMESPACE = appName // env.HOST = "dht.terrible.network" // env.APP_NAME = appName // env.IMAGE = latest.imageName() // env.IMAGE_PULL_SECRET = "registry-terrible-network-pull-secret" // sh "kubectl rollout restart 'deployments/${env.APP_NAME}'" // sh "kubectl -n '${env.NAMESPACE}' rollout status 'deployments/${env.APP_NAME}'" // } } } } } }