Nexusartifactuploader bulk upload multiple artifacts - jenkins-pipeline

I have close to 60 artifacts(jar) created from a project I want to upload it to nexus ,I have tried diff wildcards it failed.
can I create a loop or is there a beter way to do this .
below is snippet from my jenkins file
nexusArtifactUploader artifacts: [
[artifactId: "test-services", classifier: '', file: "/server/services/deploy/*.jar', type: 'jar']
],
credentialsId: NEXUS_CREDENTIAL_ID,
groupId: "$group",
nexusUrl: NEXUS_URL,
nexusVersion: 'nexus3',
protocol: 'https',
repository: NEXUS_REPO ,
version: "$nexus_version${BUILD_NUMBER}-SNAPSHOT"
}
}

I added a for loop and let uploader iterate over the artifacts. Im not sure if its the right approach .but it does the job as of now . still looking for better options
let me know if i can improve the below.
def FILES_LIST = sh (script: """ls 'server/services/deploy/' """,returnStdout: true).trim()
//DEBUG
echo "FILES_LIST : ${FILES_LIST}"
//PARSING
for(String ele : FILES_LIST.split("\\r?\\n")){
nexusArtifactUploader artifacts: [
[artifactId: "$ele", classifier: '', file: "server/services/deploy/$ele", type: 'jar']
],
credentialsId: NEXUS_CREDENTIAL_ID,
groupId: "com.devops",
nexusUrl: NEXUS_URL,
nexusVersion: 'nexus3',
protocol: 'https',
repository: NEXUS_REPO ,
version: "1.0.0-${BUILD_NUMBER}-SNAPSHOT"

Related

In Jenkins display the directories from gitlab repo in build with parameters as a drop down

agent { label 'jenkins-slave' }
environment {
CRED_REPO_URL = 'gitcredentials.git'
SERVICES_REPO_URL = 'gitrepo'
ENV_NAME = 'dev_dev'
REGION = 'ap-south-1'
}
parameters {
choice name: 'ENV', choices: ['dev', 'qa'], description: 'Choose an env'
choice name: 'DIRS', choices: choiceArray, description: 'Choose a dir from branch'
gitParameter branchFilter: 'origin/(.*)',
tagFilter: '*',
defaultValue: 'main',
name: 'BRANCH',
type: 'BRANCHTAG',
quickFilterEnabled: 'true',
description: 'branch to execute',
useRepository: 'gitrepo'
}
}
facing some issue.so need to assist for this while select the branch in jenkins it has to shown that repo directories as a drop down.

Failed to parse the manifest file, in my Xcode Swift Package Manger

I am install Firebase via Swift Package Manager. I attempted to use the Swift Package Manager to automatically install this library from a Github repository.
When I build the project I received an error saying that "Failed to parse the manifest file". Package.swift file is in my "firebase-ios-sdk-master" subdirectory of my project.
Bellowing is my Package.swift file:
import PackageDescription
import class Foundation.ProcessInfo
let firebaseVersion = "9.3.0"
let package = Package(
name: "Firebase",
platforms: [.iOS(.v11), .macOS(.v10_12), .tvOS(.v12), .watchOS(.v7)],
products: [
.library(
name: "FirebaseAnalytics",
targets: ["FirebaseAnalyticsTarget"]
),
//...
],
dependencies: [
.package(name: "Firebase",
url: "https://github.com/firebase/firebase-ios-sdk.git",
from: "8.0"
),
.package(
name: "Promises",
url: "https://github.com/google/promises.git",
"2.1.0" ..< "3.0.0"
),
//...
],
targets: [
.target(
name: "Firebase",
dependencies: [
.product(name: "FirebaseAuth", package: "Firebase"),
],
path: "CoreOnly/Sources",
publicHeadersPath: "./"
),
.target(
name: "FirebaseCore",
dependencies: [
"Firebase",
"FirebaseCoreDiagnostics",
"FirebaseCoreInternal",
.product(name: "GULEnvironment", package: "GoogleUtilities"),
.product(name: "GULLogger", package: "GoogleUtilities"),
],
path: "FirebaseCore/Sources",
publicHeadersPath: "Public",
cSettings: [
.headerSearchPath("../.."),
.define("Firebase_VERSION", to: firebaseVersion),
// TODO: - Add support for cflags cSetting so that we can set the -fno-autolink option
],
linkerSettings: [
.linkedFramework("UIKit", .when(platforms: [.iOS, .tvOS])),
.linkedFramework("AppKit", .when(platforms: [.macOS])),
]
),
//...
],
cLanguageStandard: .c99,
cxxLanguageStandard: CXXLanguageStandard.gnucxx14
)
if ProcessInfo.processInfo.environment["FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT"] != nil {
if let GoogleAppMeasurementIndex = package.dependencies
.firstIndex(where: { $0.name == "GoogleAppMeasurement" }) {
package.dependencies[GoogleAppMeasurementIndex] = .package(
name: "GoogleAppMeasurement",
url: "https://github.com/google/GoogleAppMeasurement.git",
.branch("main")
)
}
}

Is it possible to push an image to AWS ECR using Google CloudBuild?

The following snippet (Node/Typescript) utilizes Google's CloudBuild API (v1) to build a container and push to Google's Container Registry (GCR). If it is possible, what's the right way to have CloudBuild push the image to AWS ECR instead of GCR?
import { cloudbuild_v1 } from "googleapis";
[...]
const manifestLocation = `gs://${manifestFile.bucket}/${manifestFile.fullpath}`;
const buildDestination = `gcr.io/${GOOGLE_PROJECT_ID}/xxx:yyy`;
const result = await builds.create({
projectId: GOOGLE_PROJECT_ID,
requestBody: {
steps: [
{
name: 'gcr.io/cloud-builders/gcs-fetcher',
args: [
'--type=Manifest',
`--location=${manifestLocation}`
]
},
{
name: 'docker',
args: ['build', '-t', buildDestination, '.'],
}
],
images: [buildDestination]
}
})```
Yes you can by setting a custom step where you do that.
for this you can have a step with the docker image that makes the build and pushes it to AWS ECR.
steps:
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', '<AWS_ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/<IMAGE_NAME>', '.' ]
Here is a guide on how to use cludbuild which can be useful to you.
BAsically on your usecase you can just change the value of destination to the AWS ECR URL like this:
import { cloudbuild_v1 } from "googleapis";
[...]
const manifestLocation = `gs://${manifestFile.bucket}/${manifestFile.fullpath}`;
const buildDestination = `<AWS_ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/<IMAGE_NAME>`;
const result = await builds.create({
projectId: GOOGLE_PROJECT_ID,
requestBody: {
steps: [
{
name: 'gcr.io/cloud-builders/gcs-fetcher',
args: [
'--type=Manifest',
`--location=${manifestLocation}`
]
},
{
name: 'docker',
args: ['build', '-t', buildDestination, '.'],
}
],
images: [buildDestination]
}
})```

Routing in Serverless nuxt app not working

So I'm getting a routing problem whenever I use nuxt ssr with serverless. When I use either deploy to AWS lambda or use serverless-offline it generates the url prefixed with /{stage}, but nuxt can't seem to handle this and either throws 403, 404 or 500 errors because the routes to static files aren't prefixed with /{stage}.
I have tried adding {stage} to the public path on build, the results in a 404 because now the static file path needs to prefixed with another /{stage}. If I go directly to {stage}/{stage}/_nuxt/{file} it works.
build: {
publicPath: '/{stage}/_nuxt'
}
So looking around I found that I can update the router base to the below
router: {
base: '/{stage}'
}
but now the file only loads if its {stage}/{stage}/{stage}/_nuxt/{file} and removing the publicPath code above doesn't make it work either.
And this is for the static files, when it comes to the actual routes the homepage set at '/' either works but any other pages don't because the nuxt-links to them aren't prefixed with /{stage} or if I add the prefix to the base I get a Cannot GET / error when I visit /{stage}.
I have tried many different ways of doing this such as using express however I have had no luck and any tutorials that I found online are at least 2 years old and the github repos have the same problem. The closest thing I have found on stackoverflow that is somewhat similar to what I have is here but this is for a static site.
Anybody have any ideas? Below is the code for the serverless.yaml, handler.js, nuxt.js, nuxt.config.js.
Github Repo
serverless.yaml
service: nuxt-ssr-lambda
provider:
name: aws
runtime: nodejs12.x
stage: ${env:STAGE}
region: eu-west-1
lambdaHashingVersion: 20201221
environment:
NODE_ENV: ${env:STAGE}
apiGateway:
shouldStartNameWithService: true
functions:
nuxt:
handler: handler.nuxt
events:
- http: ANY /
- http: ANY /{proxy+}
plugins:
- serverless-apigw-binary
- serverless-dotenv-plugin
- serverless-offline
custom:
apigwBinary:
types:
- '*/*'
handler.js
const sls = require('serverless-http')
const binaryMimeTypes = require('./binaryMimeTypes')
const nuxt = require('./nuxt')
module.exports.nuxt = sls(nuxt, {
binary: binaryMimeTypes
})
nuxt.js
const { Nuxt } = require('nuxt')
const config = require('./nuxt.config.js')
const nuxt = new Nuxt({ ...config, dev: false })
module.exports = (req, res) =>
nuxt.ready().then(() => nuxt.server.app(req, res))
nuxt.config.js
module.exports = {
telemetry: false,
head: {
htmlAttrs: {
lang: 'en'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
css: [
],
plugins: [
],
components: true,
buildModules: [
'#nuxtjs/tailwindcss',
],
modules: [
],
router: {
base: '/prod'
},
build: {
}
}
Are you passing it as
<p>Path: {{ $route.path }}</p>
<NuxtLink to="/">Back to Mountains</NuxtLink>
if Yes then it should work else try going with redirect('/{stage}/_nuxt')
for an if statement put this inside else , I think it should work.

How do use Sass in Docusaurus v2?

I followed the instructions to use Sass in my Docusaurus v2 project, but I get the following error when I run yarn start:
Error: Cannot find module 'docusaurus-plugin-sass'
My config file is straight out of the box:
module.exports = {
title: '...',
tagline: '...',
url: '...',
baseUrl: '/',
favicon: 'img/favicon.ico',
organizationName: '...', // Usually your GitHub org/user name.
projectName: '...', // Usually your repo name.
themeConfig: {
navbar: {...},
footer: {...},
},
presets: [
[
'#docusaurus/preset-classic',
{
docs: {...},
blog: {...},
theme: {
customCss: require.resolve('./src/scss/index.scss'),
},
},
],
],
plugins: ['docusaurus-plugin-sass'],
};
Is this a bug or am I missing something?
Few things to check
Did you add docusaurus-plugin-sass to your package.json?
If you're using alpha.56, take note of the following change - https://github.com/facebook/docusaurus/releases/tag/v2.0.0-alpha.56
If you refer to modules (plugins) in your config file in a string form, you will need to replace them with require.resolve calls, for example:
- plugins: ['#docusaurus/plugin-google-analytics']
+ plugins: [require.resolve('#docusaurus/plugin-google-analytics')]

Resources