I am running a test suite using Jenkins and I have configured a job to do that. I have a pipeline script that is doing all the steps, but it seems that with the latest release on LIVE by adding a new button on the LIVE, my tests run a version of the code that does not have that button and it seems that it's not pulling the latest code. What am I doing wrong in the script?

I have tried in pulling down the latest code from Bitbucket, but with no success and building the branch by doing 'docker-compose build --build-arg BRANCH=${branch} apache'

node {
   stage('Pull latest Docker repo') { 
      git credentialsId: 'xyz',
          url: '[email protected]:domain/myportal-docker.git'
   }
   stage('Install app') {
      sh 'docker-compose down'
      sh 'docker-compose build --no-cache mysql'
      if (params.buildapp == true){
        sh 'docker-compose build --build-arg BRANCH=${branch} apache'
      }
      sh 'docker-compose up -d'
   }
   stage('Set up Selenium') {
      try {
        sh 'docker rm selenium -f'
      }
      catch(exc) {
        echo 'No selenium container running'
      }
      sh 'docker pull selenium/standalone-chrome'
      sh 'docker run -d -p 4444:4444 --name=selenium --net=host -v /dev/shm:/dev/shm selenium/standalone-chrome:3.141.59-dubnium'
   }
   stage('Load tests') { 
      dir("../") {}
      git credentialsId: 'xyz',
          url: '[email protected]:domain/my-tests.git'
   }
   stage('Run tests') {
      sh 'composer install'
      sh 'vendor/bin/codecept --debug run --steps tests/jenkins'
   }
}

Tests are running fine, but somehow they don't run on the latest code, they run against the master branch but it does not have the latest code. Also I have an On demand job that I want to try and mess around with it once have some info maybe from some of you with this.

5 Answers

0
teddym6 On

probably has to do with your Dockerfile

you need to make sure you close your file with ADD ./yourcodefolder

0
Community On

@teddym6 now it looks like this, my Dockerfile:

FROM webdevops/php-apache:7.1

ARG WWW_ROOT ARG APP_DIR ARG APP_ROOT=${WWW_ROOT}/${APP_DIR} ARG BRANCH

ENV WEB_DOCUMENT_ROOT=${APP_ROOT}/htdocs

RUN mkdir /root/.ssh/ ADD ./.ssh/ /root/.ssh/ RUN chmod -R 0600 /root/.ssh/* RUN echo "Using branch ${BRANCH} for code" RUN git clone --branch ${BRANCH} --depth 1 [email protected]:domain/myportal-docker.git ${APP_ROOT}

WORKDIR ${APP_ROOT}

RUN mkdir -p runtime htdocs/assets RUN chmod -R a+w runtime htdocs/assets

WORKDIR /usr/src/app

COPY app/local.php ${APP_ROOT}/config/local.php

ADD . /usr/src/app WORKDIR /usr/src/app

0
Community On

Any other ideas with this one guys?

As I tried all of the above and nothing worked. Tests are running fine and all that, but not on the latest code.

As I said in the first post, I know because we have a new button on the first page and that one is not on my version where the tests run.

0
Community On

back to this as it's giving me a headache, so the console output looks like this:

  Started by timer
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/jobs/Autotest/workspace
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Pull latest Docker repo)
[Pipeline] git
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url [email protected]:domain/myportal-docker.git
 # timeout=10
Fetching upstream changes from [email protected]:domain/myportal-docker.git
 > git --version # timeout=10
using GIT_SSH to set credentials Jenkins Portal Tests Repo
 > git fetch --tags --progress [email protected]:domain/myportal-docker.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 20cdc207dc87e736983d6b28b5a81853c7c37f70 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 20cdc207dc87e736983d6b28b5a81853c7c37f70
 > git branch -a -v --no-abbrev # timeout=10
 > git branch -D master # timeout=10
 > git checkout -b master 20cdc207dc87e736983d6b28b5a81853c7c37f70
Commit message: "Got rid of the WORKDIR"
 > git rev-list --no-walk 20cdc207dc87e736983d6b28b5a81853c7c37f70 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Install app)
[Pipeline] sh
[workspace] Running shell script
+ docker-compose down
Stopping workspace_apache_1 ... 
Stopping workspace_mysql_1  ... 
[2A[2K
Stopping workspace_apache_1 ... [32mdone[0m
[2B[1A[2K
Stopping workspace_mysql_1  ... [32mdone[0m
[1BRemoving workspace_apache_1 ... 
Removing workspace_mysql_1  ... 
[1A[2K
Removing workspace_mysql_1  ... [32mdone[0m
[1B[2A[2K
Removing workspace_apache_1 ... [32mdone[0m
[2BRemoving network workspace_frontend
Removing network workspace_backend
[Pipeline] sh
[workspace] Running shell script
+ docker-compose build --no-cache mysql
Building mysql
Step 1/2 : FROM mysql:5.7.24
 ---> ba7a93aae2a8
Step 2/2 : ADD mysql.cnf /etc/mysql/mysql.conf.d/mysql.cnf
 ---> cd3843490228
Successfully built cd3843490228
Successfully tagged workspace_mysql:latest
[Pipeline] echo
Will deploy from feature/docker-enablement
[Pipeline] echo
BuildApp Param false
[Pipeline] sh
[workspace] Running shell script
+ docker-compose up -d
Creating network "workspace_frontend" with the default driver
Creating network "workspace_backend" with the default driver
Creating workspace_mysql_1 ... 
Creating workspace_mysql_1
[1A[2K
Creating workspace_mysql_1 ... [32mdone[0m
[1BCreating workspace_apache_1 ... 
Creating workspace_apache_1
[1A[2K
Creating workspace_apache_1 ... [32mdone[0m
[1B[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Set up Selenium)
[Pipeline] sh
[workspace] Running shell script
+ docker rm selenium -f
selenium
[Pipeline] sh
[workspace] Running shell script
+ docker pull selenium/standalone-chrome
Using default tag: latest
latest: Pulling from selenium/standalone-chrome
Digest: sha256:c478febf26729b7cc27e2fac7d10fa79cf2519b5ab83f9cf82705248258b6495
Status: Image is up to date for selenium/standalone-chrome:latest
[Pipeline] sh
[workspace] Running shell script
+ docker run -d -p 4444:4444 --name=selenium --net=host -v /dev/shm:/dev/shm selenium/standalone-chrome:3.141.59-dubnium
WARNING: Published ports are discarded when using host network mode
952481c15140f1b9fe797cbee495268d7fd191c4ec07194297e19b27109f829a
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Load tests)
[Pipeline] dir
Running in /var/lib/jenkins/jobs/Autotest
[Pipeline] {
[Pipeline] }
[Pipeline] // dir
[Pipeline] git
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url [email protected]:domain/myportal-docker.git
 # timeout=10
Fetching upstream changes from [email protected]:domain/myportal-docker.git
 > git --version # timeout=10
using GIT_SSH to set credentials Jenkins Portal Tests Repo
 > git fetch --tags --progress [email protected]:domain/myportal-docker.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision a5ddc6742c13e3b8c37e7ebda625fd8d89b1386a (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f a5ddc6742c13e3b8c37e7ebda625fd8d89b1386a
 > git branch -a -v --no-abbrev # timeout=10
 > git branch -D master # timeout=10
 > git checkout -b master a5ddc6742c13e3b8c37e7ebda625fd8d89b1386a
Commit message: "Commented out the forum request button test"
 > git rev-list --no-walk a5ddc6742c13e3b8c37e7ebda625fd8d89b1386a # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Run tests)
[Pipeline] sh
[workspace] Running shell script
+ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
[Pipeline] sh
[workspace] Running shell script
+ vendor/bin/codecept --debug run --steps tests/jenkins
Codeception PHP Testing Framework v2.5.2
Powered by PHPUnit 6.5.13 by Sebastian Bergmann and contributors.
Running with seed:

After all of the above, the tests run normally, but as this thread says, not on the latest code.

1
Community On

params.buildapp is false so it isn't building the apache container. The code only gets pulled from your repo when this container gets built.