Branches not being ignored on CircleCi jobs - circleci

I am attempting to ignore ALL branches and only start the jobs on a tagged build if the tag contains the correct value.
I am using
workflows:
version: 2
deploy_staging:
jobs:
- ios_deploy_staging:
filters:
tags:
only: /^staging-[0-9]+(\.[0-9]+)*$/
branches:
ignore: /.*/
- android_deploy_staging:
filters:
tags:
only: /^staging-[0-9]+(\.[0-9]+)*$/
branches:
ignore: /.*/
- ios_deploy_prod:
filters:
tags:
only: /^prod-[0-9]+(\.[0-9]+)*$/
branches:
ignore: /.*/
- android_deploy_prod:
filters:
tags:
only: /^prod-[0-9]+(\.[0-9]+)*$/
branches:
ignore: /.*/
Weirdly only the
android_deploy_prod
is being ignored, all the remaining jobs run on all branches.
Has anyone seen this before?

Turns out this was due to formatting. It should have been:
workflows:
version: 2
deploy_staging:
jobs:
- ios_deploy_staging:
filters:
tags:
only: /^staging-[0-9]+(\.[0-9]+)*$/
branches:
ignore: /.*/
- android_deploy_staging:
filters:
tags:
only: /^staging-[0-9]+(\.[0-9]+)*$/
branches:
ignore: /.*/
- ios_deploy_prod:
filters:
tags:
only: /^prod-[0-9]+(\.[0-9]+)*$/
branches:
ignore: /.*/
- android_deploy_prod:
filters:
tags:
only: /^prod-[0-9]+(\.[0-9]+)*$/
branches:
ignore: /.*/

Related

error during helmfile.yaml.part.0 parsing :

I am running my pipeline in gitlab .. and this pipeline pull a helmfile from a github repo.. and when i am trying to deploy this error appears when start to put parsing because my values file like that
kubeContext: cech027
this is the helmfile
`
# Make sure we have the ENV variable set: {{ requiredEnv "ENV" }}
environments:
default:
values:
- environments/defaults.yaml.gotmpl
- versions.yaml
- {{ env "ENVCONFIG" |default ".." }}/config/defaults.yaml.gotmpl
- {{ env "ENVCONFIG" |default ".." }}/config/{{ requiredEnv "ENV" }}/values.yaml.gotmpl
- systemVersion: {{ (exec "./utils/git-version.sh" (list "")) }}
- kubeVersion: {{ (exec "./utils/kube-version.sh" (list .Values.kubeContext)) }}
secrets:
- {{ env "ENVCONFIG" |default ".." }}/config/secrets.yaml
- {{ env "ENVCONFIG" |default ".." }}/config/{{ requiredEnv "ENV" }}/secrets.yaml
local:
values:
- environments/defaults.yaml.gotmpl
- versions.yaml
- environments/local/values.yaml.gotmpl
- environments/local/secrets.yaml
{{- if eq (exec "./utils/fileexists.sh" (list "overrides.yaml.gotmpl")) "true"}}
- overrides.yaml.gotmpl
{{- end }}
{{- if eq (exec "./utils/fileexists.sh" (list "overrides.yaml")) "true"}}
- overrides.yaml
{{- end }}
- systemVersion: {{ (exec "./utils/git-version.sh" (list "dev")) }}
- kubeVersion: {{ (exec "./utils/kube-version.sh" (list .Values.kubeContext)) }}
---
repositories:
{{- if .Values.helm }}
- name: softsense
url: {{ .Values.helm.url }}
username: {{ .Values.helm.username }}
password: {{ .Values.helm.password }}
{{- if .Values.allowSnapshots }}
- name: softsense-dev
url: {{ .Values.helm.devURL }}
username: {{ .Values.helm.username }}
password: {{ .Values.helm.password }}
{{- end }}
{{- end }}
helmDefaults:
cleanupOnFail: true
verify: false # does not work with charts in directories
wait: true
timeout: 900
recreatePods: false # recreatePods is not supported in helm3
force: false
kubeContext: {{ .Values.kubeContext }} # force usage of a specific kube-context
createNamespace: false
`
but i have this error since a week ( and we did not do any changes) ..
the gitlab uses a runner to run this pipeline..
this is the error : rror during helmfile.yaml.part.0 parsing: template: stringTemplate:11:69: executing "stringTemplate" at <.Values.kubeContext>: map has no entry for key "kubeContext"
and when i run from my local machine it deployed successfully

How to specify nested json body in POST request

I'm trying to set Artillery config to be able to send nested JSON body. This is how my configuration looks like:
config:
target: <URL>
phases:
- duration: 10
arrivalRate: 20
processor: "./input-parser.js"
scenarios:
- flow:
- function: "parseJsonFile"
- post:
url: /workflow-instance
headers:
Content-Type: "application/json"
json:
name: "{{ name }}"
namespace: "{{ namespace }}"
template_name: "{{ template_name }}"
attributes: "{{ attributes }}"
- get:
url: "/workflow-instance/status?name={{ template_name }}&namespace={{ namespace }}"
I have a problem with "attributes" because the content of attributes is:
{ pod_name: 'POD_NAME', port: 'PORT_NUMBER' }
So basically, this will not work:
attributes: "{ pod_name: 'POD_NAME', port: 'PORT_NUMBER' }"
as well as this:
attributes:
pod_name: 'POD_NAME'
port: 'PORT_NUMBER'
I didn't found good examples for this particular case in Artillery docs.
The following workaround worked for me Embedding JSON Data into YAML file
Then you'd have to change your attributes for:
attributes: '{ pod_name: "POD_NAME", port: "PORT_NUMBER" }'
I'm using:
Artillery: 1.7.9
Artillery Pro: not installed (https://artillery.io/pro)
Node.js: v14.6.0
OS: darwin/x64
For future readers looking for hardcoding nested JSON, this worked for me:
...
scenarios:
-
flow:
-
post:
url: "/"
json:
text: {"filter": {"enabled": true}}

SCM polling with includedRegions in Jenkins pipeline job

I am using GitLab. Given multiple directories, e.g. folder1, folder2, folder3. I would like the job run only if there is any changes under folder1 only. Does anyone able to get includedRegions to work in Jenkins pipeline job.
checkout(
[
$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'PathRestriction', excludedRegions: '', includedRegions: 'folder1/.*']],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'user', url: 'ssh://something/experiment.git']]
]
)
If you use a pipeline the checkout step performs after the build was launched.
The only way to manage this is to check the changeset with the groovy and skip the build if there were no changes at the included directory.
I managed to get it working. Since the checkout will be used across projects in our Jenkins, I wrote shared libraries to make it handy to use.
Example: strToSparseCheckout.groovy
#!/usr/bin/env groovy
import hudson.plugins.git.extensions.impl.SparseCheckoutPath
def call(paths) {
def list = paths.split('\n')
def sparsePaths = []
def isDefaultAdded = false
list.each {
def path = it - '/.*'
def sparsePath = new SparseCheckoutPath(path)
sparsePaths.push(sparsePath)
}
return sparsePaths
}
Example: sparseCheckout.groovy
#!/usr/bin/env groovy
def call(Map namedargs) {
checkout(
[
$class: 'GitSCM',
branches: [[name: "${namedargs.branch}"]],
extensions: [
[$class: 'LocalBranch', localBranch: '**'],
[$class: 'RelativeTargetDirectory', relativeTargetDir: "${namedargs.target_dir}"],
[$class: 'SparseCheckoutPaths', sparseCheckoutPaths: strToSparseCheckout("${namedargs.included_regions}")],
[$class: 'PathRestriction', excludedRegions: """${namedargs.excluded_regions}""", includedRegions: """${namedargs.included_regions}"""]
],
userRemoteConfigs: [[credentialsId: 'user', url: "${namedargs.url}"]]
]
)
}
In the pipeline, we can call the sparseCheckout shared library.
pipeline {
stage('Checkout') {
sparseCheckout(
[
url: 'ssh://path.to.git/something.git',
branch: 'refs/heads/master',
target_dir: 'something',
excluded_regions: "${params.excluded_regions}",
included_regions: "${params.included_regions}"
]
)
}
}

Rails 6/Webpacker not serving static assets to React

I have a React frontend using Rails 6 as an API. Webpacker is configured to package image files in app/javascript/media to app/javascript/packs. As far as I can tell, Webpack is creating the packs correctly; the packs folder contains my bundle.js, bundle.js map, and the .svg file bundled by webpack. Bundle.js is running fine, but when I try and import the image in a component, I'm getting a routing error stating:
ActionController::RoutingError (No route matches [GET] "/img.svg")
All of the questions I've seen about this mention that static assets don't get served by Rails in production mode without further configuration, but I have Rails in development mode and webpack-dev-server running.
Here's my webpack.config.js:
const path = require('path');
module.exports = {
context: __dirname,
entry: './frontend/app_name.jsx',
output: {
path: path.resolve(__dirname, 'app', 'javascript', 'packs'),
publicPath: path.resolve(__dirname, 'app', 'javascript', 'packs'),
filename: 'bundle.js'
},
resolve: {
extensions: ['.js', '.jsx', '*']
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
query: {
presets: ['#babel/env', '#babel/react']
}
},
},
{
test: /\.(png|svg)?$/,
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
}
]
},
devtool: 'source-map'
};
Update: My routes.rb contains:
Rails.application.routes.draw do
root 'static#index'
namespace :api, defaults: { format: :json } do
resources :search, only: [:index]
end
end
and my static controller is
class StaticController < ApplicationController
def index
render :index
end
end
Should requests for static assets compiled by webpacker even be making it to the backend in a one page app?

DynamicReferenceParameter defined in Pipeline

I use the DynamicReferenceParameter for some advanced parameter inputs in Jenkins.
Here is a tiny example, which I entered using the UI:
This works fine, my checkboxes and input fields do show up!
But when I try to define my parameters in my Jenkinsfile, I get an error. My Jenkinsfile looks like this:
properties([parameters([
[
$class: 'DynamicReferenceParameter',
name: 'SFM',
script: [
$class: 'GroovyScript',
fallbackScript: '',
script: """
def services = ['service1',
'service2',
'service3']
def html =
'''
<!DOCTYPE html>
<html>
<body>
<table id="serviceTable">
'''
for (service in services){
html += "<tr>"
html += "<td><input type=\"checkbox\" id=\"checkbox_$service\">$service</td>"
html += "<td><div id=\"version_$service\" >version: <input type=\"text\"></div></td>"
html += "</tr>"
}
html += '''
</table>
</body>
</html>
'''
return html
"""
]
]
])])
You see, I just copy&pasted the script from the UI input and surrounded it with """.
This results in error no. 1:
Groovy.lang.MissingPropertyException: No such property: service for class: WorkflowScript
So there is an error parsing my variables.
So I just tried to delete all variables and set static values (replace $service with service1). This results in error no. 2:
java.lang.ClassCastException: org.biouno.unochoice.model.GroovyScript.script expects class org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript but received class java.lang.String
at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:416)
at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:340)
at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:281)
Caused: java.lang.IllegalArgumentException: Could not instantiate {fallbackScript=, script=[...]
What do I do wrong?
script and fallbackScript are not really String's. They are using the Security Script Plugin classes (it's been like that for a while already).
Here's some code snippet that may help.
properties([parameters([
[
$class: 'DynamicReferenceParameter',
name: 'TEST',
script: [
$class: 'GroovyScript',
fallbackScript: [
classpath: [], sandbox: true, script: ''
],
script: [
classpath: [], sandbox: true, script:
"""
def html =
'''
<!DOCTYPE html>
<html>
<body>
<table id="serviceTable">
<tr>
<td><input type="checkbox" id="checkbox">service1</td>
<td><div id="version" >version: <input type="text"></div></td>
</tr>
</table>
</body>
</html>
'''
return html
"""
]
]
]
])])
ps: take it with a grain of salt, as I normally use only FreeStyle jobs. I think some people tried using the plug-in with pipelines, but as far as I know, it's still a work-in-progress (see https://issues.jenkins-ci.org/browse/JENKINS-39742 for example)
Hope that helps,
Bruno
properties([parameters([
[$class: 'DynamicReferenceParameter',
choiceType: 'ET_FORMATTED_HTML',
omitValueField: true,
description: 'Editable field when PARENT_PARAM is Others',
name: 'ACTIVE_PARAM',
randomName: 'choice-parameter-5631314456178624',
referencedParameters: 'PARENT_PARAM',
script: [
$class: 'GroovyScript',
fallbackScript: [
classpath: [],
sandbox: true,
script: "return['undefined']"
],
script: [
classpath: [],
sandbox: true,
script:
"""
inputBox="<input class='setting-input' name='value' type='text' value=''>"
"""
]
]
]
])])

Resources